@koine/i18n 2.0.0-beta.216 → 2.0.0-beta.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,24 +12,24 @@ var types = require('./types.cjs.js');
|
|
|
12
12
|
|
|
13
13
|
let c = "count";
|
|
14
14
|
function getTFunction(t, r) {
|
|
15
|
-
let { params: n, plural: o } = t, { single: l } = r, { body:
|
|
16
|
-
let { values: n, params: o, plural: l, typeValue:
|
|
17
|
-
|
|
15
|
+
let { params: n, plural: o } = t, { single: l } = r, { body: s, imports: m } = function(t, r) {
|
|
16
|
+
let { values: n, params: o, plural: l, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = r, y = !u && !p, h = [
|
|
17
|
+
d.types
|
|
18
18
|
];
|
|
19
|
-
return l && h.push(
|
|
19
|
+
return l && h.push(d.pluralise), o && ("Primitive" === s ? h.push(d.interpolateParams) : ("Array" === s || "Object" === s) && h.push(d.interpolateParamsDeep)), {
|
|
20
20
|
imports: h,
|
|
21
21
|
body: (t)=>{
|
|
22
22
|
let r = y ? "locale = locale || globalThis." + constants.GLOBAL_I18N_IDENTIFIER + "; " : "";
|
|
23
23
|
r += "return ";
|
|
24
|
-
let
|
|
25
|
-
return utils.isPrimitive(n) ?
|
|
24
|
+
let p = "";
|
|
25
|
+
return utils.isPrimitive(n) ? p += f(n, t) : p += function(t, r, n, a) {
|
|
26
26
|
let o = "";
|
|
27
27
|
if (n) for(let n in r){
|
|
28
28
|
let i = r[n];
|
|
29
|
-
n === t || utils.areEqual(i, r[t]) || (o += `locale === "${n}" ? ${
|
|
29
|
+
n === t || utils.areEqual(i, r[t]) || (o += `locale === "${n}" ? ${f(i, a)} : `);
|
|
30
30
|
}
|
|
31
|
-
return o +
|
|
32
|
-
}(m, n, y, t), l && (
|
|
31
|
+
return o + f(r[t], a);
|
|
32
|
+
}(m, n, y, t), l && (p = `pluralise(${p}, params.${c}${y ? ", locale" : ""})`), o && ("Primitive" === s ? p = `interpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `interpolateParamsDeep(${p}, params)`)), r + p;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}(t, r), u = [], y = n ? o ? {
|
|
@@ -50,16 +50,16 @@ function getTFunction(t, r) {
|
|
|
50
50
|
description: "Use this to override the current locale" + (l ? " (in case you add other locales to your project)" : ""),
|
|
51
51
|
defaultComment: "current locale"
|
|
52
52
|
}), {
|
|
53
|
-
body:
|
|
53
|
+
body: s,
|
|
54
54
|
args: u,
|
|
55
55
|
imports: m
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function f(e, { format: a }) {
|
|
59
59
|
let i = "ts" === a ? " as const" : "";
|
|
60
|
-
return utils.isString(e)
|
|
60
|
+
return utils.isString(e) ? `${JSON.stringify(e)}${i}` : utils.isNumber(e) ? `${e}${i}` : utils.isBoolean(e) ? `${e}` : utils.isArray(e) ? JSON.stringify(e) + i : `(${JSON.stringify(e)}${i})`;
|
|
61
61
|
}
|
|
62
|
-
let
|
|
62
|
+
let d = {
|
|
63
63
|
types: types.getImportTypes(),
|
|
64
64
|
interpolateParams: new imports.ImportsCompiler({
|
|
65
65
|
path: "internal/interpolateParams",
|
|
@@ -87,15 +87,16 @@ let f = {
|
|
|
87
87
|
})
|
|
88
88
|
};
|
|
89
89
|
var y = createAdapter.createGenerator("js", (e)=>{
|
|
90
|
-
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports:
|
|
90
|
+
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports: p } = ((e, t)=>{
|
|
91
91
|
let r = [], n = new Set();
|
|
92
|
-
for(let a in n.add(
|
|
93
|
-
let o = e[a], { imports: i, args: l, body:
|
|
94
|
-
|
|
92
|
+
for(let a in n.add(d.types), e){
|
|
93
|
+
let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
|
|
94
|
+
for (let e of i)n.add(e);
|
|
95
|
+
r.push(new functions.FunctionsCompiler({
|
|
95
96
|
imports: i,
|
|
96
97
|
name: o.fnName,
|
|
97
98
|
args: l,
|
|
98
|
-
body:
|
|
99
|
+
body: p,
|
|
99
100
|
comment: {
|
|
100
101
|
tags: [
|
|
101
102
|
{
|
|
@@ -133,7 +134,7 @@ var y = createAdapter.createGenerator("js", (e)=>{
|
|
|
133
134
|
index: false,
|
|
134
135
|
content: ()=>{
|
|
135
136
|
let e = "";
|
|
136
|
-
return e += imports.ImportsCompiler.outMany("ts",
|
|
137
|
+
return e += imports.ImportsCompiler.outMany("ts", p, {
|
|
137
138
|
folderUp: 0
|
|
138
139
|
}), e += functions.FunctionsCompiler.outMany("ts", l, {
|
|
139
140
|
imports: false,
|
|
@@ -8,24 +8,24 @@ import { getImportTypes } from './types.esm.js';
|
|
|
8
8
|
|
|
9
9
|
let c = "count";
|
|
10
10
|
function getTFunction(t, r) {
|
|
11
|
-
let { params: n, plural: o } = t, { single: l } = r, { body:
|
|
12
|
-
let { values: n, params: o, plural: l, typeValue:
|
|
13
|
-
|
|
11
|
+
let { params: n, plural: o } = t, { single: l } = r, { body: s, imports: m } = function(t, r) {
|
|
12
|
+
let { values: n, params: o, plural: l, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = r, y = !u && !p, h = [
|
|
13
|
+
d.types
|
|
14
14
|
];
|
|
15
|
-
return l && h.push(
|
|
15
|
+
return l && h.push(d.pluralise), o && ("Primitive" === s ? h.push(d.interpolateParams) : ("Array" === s || "Object" === s) && h.push(d.interpolateParamsDeep)), {
|
|
16
16
|
imports: h,
|
|
17
17
|
body: (t)=>{
|
|
18
18
|
let r = y ? "locale = locale || globalThis." + GLOBAL_I18N_IDENTIFIER + "; " : "";
|
|
19
19
|
r += "return ";
|
|
20
|
-
let
|
|
21
|
-
return isPrimitive(n) ?
|
|
20
|
+
let p = "";
|
|
21
|
+
return isPrimitive(n) ? p += f(n, t) : p += function(t, r, n, a) {
|
|
22
22
|
let o = "";
|
|
23
23
|
if (n) for(let n in r){
|
|
24
24
|
let i = r[n];
|
|
25
|
-
n === t || areEqual(i, r[t]) || (o += `locale === "${n}" ? ${
|
|
25
|
+
n === t || areEqual(i, r[t]) || (o += `locale === "${n}" ? ${f(i, a)} : `);
|
|
26
26
|
}
|
|
27
|
-
return o +
|
|
28
|
-
}(m, n, y, t), l && (
|
|
27
|
+
return o + f(r[t], a);
|
|
28
|
+
}(m, n, y, t), l && (p = `pluralise(${p}, params.${c}${y ? ", locale" : ""})`), o && ("Primitive" === s ? p = `interpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `interpolateParamsDeep(${p}, params)`)), r + p;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}(t, r), u = [], y = n ? o ? {
|
|
@@ -46,16 +46,16 @@ function getTFunction(t, r) {
|
|
|
46
46
|
description: "Use this to override the current locale" + (l ? " (in case you add other locales to your project)" : ""),
|
|
47
47
|
defaultComment: "current locale"
|
|
48
48
|
}), {
|
|
49
|
-
body:
|
|
49
|
+
body: s,
|
|
50
50
|
args: u,
|
|
51
51
|
imports: m
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function f(e, { format: a }) {
|
|
55
55
|
let i = "ts" === a ? " as const" : "";
|
|
56
|
-
return isString(e)
|
|
56
|
+
return isString(e) ? `${JSON.stringify(e)}${i}` : isNumber(e) ? `${e}${i}` : isBoolean(e) ? `${e}` : isArray(e) ? JSON.stringify(e) + i : `(${JSON.stringify(e)}${i})`;
|
|
57
57
|
}
|
|
58
|
-
let
|
|
58
|
+
let d = {
|
|
59
59
|
types: getImportTypes(),
|
|
60
60
|
interpolateParams: new ImportsCompiler({
|
|
61
61
|
path: "internal/interpolateParams",
|
|
@@ -83,15 +83,16 @@ let f = {
|
|
|
83
83
|
})
|
|
84
84
|
};
|
|
85
85
|
var y = createGenerator("js", (e)=>{
|
|
86
|
-
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports:
|
|
86
|
+
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports: p } = ((e, t)=>{
|
|
87
87
|
let r = [], n = new Set();
|
|
88
|
-
for(let a in n.add(
|
|
89
|
-
let o = e[a], { imports: i, args: l, body:
|
|
90
|
-
|
|
88
|
+
for(let a in n.add(d.types), e){
|
|
89
|
+
let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
|
|
90
|
+
for (let e of i)n.add(e);
|
|
91
|
+
r.push(new FunctionsCompiler({
|
|
91
92
|
imports: i,
|
|
92
93
|
name: o.fnName,
|
|
93
94
|
args: l,
|
|
94
|
-
body:
|
|
95
|
+
body: p,
|
|
95
96
|
comment: {
|
|
96
97
|
tags: [
|
|
97
98
|
{
|
|
@@ -129,7 +130,7 @@ var y = createGenerator("js", (e)=>{
|
|
|
129
130
|
index: false,
|
|
130
131
|
content: ()=>{
|
|
131
132
|
let e = "";
|
|
132
|
-
return e += ImportsCompiler.outMany("ts",
|
|
133
|
+
return e += ImportsCompiler.outMany("ts", p, {
|
|
133
134
|
folderUp: 0
|
|
134
135
|
}), e += FunctionsCompiler.outMany("ts", l, {
|
|
135
136
|
imports: false,
|
|
@@ -11,19 +11,19 @@ var types = require('./types.cjs.js');
|
|
|
11
11
|
|
|
12
12
|
function getToFunction(o, e) {
|
|
13
13
|
let { id: r, params: n } = o, s = function(o, e) {
|
|
14
|
-
let { params: r, pathnames: n
|
|
14
|
+
let { params: r, pathnames: n } = o, { defaultLocale: s, single: l } = e, i = !l, u = l ? '""' : "locale", d = r ? ", params" : "";
|
|
15
15
|
return (o)=>{
|
|
16
|
-
let e =
|
|
16
|
+
let e = i ? `locale = locale || globalThis.${constants.GLOBAL_I18N_IDENTIFIER}; ` : "";
|
|
17
17
|
e += "return ";
|
|
18
18
|
let r = "";
|
|
19
|
-
return utils.isString(n) ? r += `formatTo(${
|
|
19
|
+
return utils.isString(n) ? r += `formatTo(${u}, "${n}"${d})` : r += `formatTo(${u}, ${function(t, o, { format: e }) {
|
|
20
20
|
let a = "ts" === e ? " as const" : "", r = "";
|
|
21
21
|
for(let e in o){
|
|
22
22
|
let n = o[e];
|
|
23
23
|
e !== t && n !== o[t] && (r += `locale === "${e}" ? "${n}"${a} : `);
|
|
24
24
|
}
|
|
25
|
-
return r +
|
|
26
|
-
}(
|
|
25
|
+
return r + `"${o[t]}"${a}`;
|
|
26
|
+
}(s, n, o)}${d})`, e + r;
|
|
27
27
|
};
|
|
28
28
|
}(o, e), l = [];
|
|
29
29
|
return n && l.push({
|
|
@@ -7,19 +7,19 @@ import { getImportTypes } from './types.esm.js';
|
|
|
7
7
|
|
|
8
8
|
function getToFunction(o, e) {
|
|
9
9
|
let { id: r, params: n } = o, s = function(o, e) {
|
|
10
|
-
let { params: r, pathnames: n
|
|
10
|
+
let { params: r, pathnames: n } = o, { defaultLocale: s, single: l } = e, i = !l, u = l ? '""' : "locale", d = r ? ", params" : "";
|
|
11
11
|
return (o)=>{
|
|
12
|
-
let e =
|
|
12
|
+
let e = i ? `locale = locale || globalThis.${GLOBAL_I18N_IDENTIFIER}; ` : "";
|
|
13
13
|
e += "return ";
|
|
14
14
|
let r = "";
|
|
15
|
-
return isString(n) ? r += `formatTo(${
|
|
15
|
+
return isString(n) ? r += `formatTo(${u}, "${n}"${d})` : r += `formatTo(${u}, ${function(t, o, { format: e }) {
|
|
16
16
|
let a = "ts" === e ? " as const" : "", r = "";
|
|
17
17
|
for(let e in o){
|
|
18
18
|
let n = o[e];
|
|
19
19
|
e !== t && n !== o[t] && (r += `locale === "${e}" ? "${n}"${a} : `);
|
|
20
20
|
}
|
|
21
|
-
return r +
|
|
22
|
-
}(
|
|
21
|
+
return r + `"${o[t]}"${a}`;
|
|
22
|
+
}(s, n, o)}${d})`, e + r;
|
|
23
23
|
};
|
|
24
24
|
}(o, e), l = [];
|
|
25
25
|
return n && l.push({
|
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"node": ">=18.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@koine/dom": "2.0.0-beta.
|
|
9
|
-
"@koine/node": "2.0.0-beta.
|
|
10
|
-
"@koine/utils": "2.0.0-beta.
|
|
8
|
+
"@koine/dom": "2.0.0-beta.217",
|
|
9
|
+
"@koine/node": "2.0.0-beta.217",
|
|
10
|
+
"@koine/utils": "2.0.0-beta.217",
|
|
11
11
|
"comment-json": "^4.2.4",
|
|
12
12
|
"consola": "^3.2.3",
|
|
13
13
|
"glob": "^11.0.0",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"module": "./index.esm.js",
|
|
131
131
|
"main": "./index.cjs.js",
|
|
132
132
|
"types": "./index.d.ts",
|
|
133
|
-
"version": "2.0.0-beta.
|
|
133
|
+
"version": "2.0.0-beta.217"
|
|
134
134
|
}
|