@koine/i18n 2.0.0-beta.176 → 2.0.0-beta.179
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.
- package/adapter-js/generators/getI18nMetadata.cjs.js +2 -2
- package/adapter-js/generators/getI18nMetadata.esm.js +2 -2
- package/adapter-js/generators/getT.cjs.js +2 -2
- package/adapter-js/generators/getT.esm.js +2 -2
- package/adapter-js/generators/interpolate.cjs.js +113 -0
- package/adapter-js/generators/{tInterpolateParams.d.ts → interpolate.d.ts} +11 -2
- package/adapter-js/generators/interpolate.esm.js +107 -0
- package/adapter-js/generators/isLocale.cjs.js +2 -2
- package/adapter-js/generators/isLocale.esm.js +2 -2
- package/adapter-js/generators/loadTranslations.cjs.js +2 -2
- package/adapter-js/generators/loadTranslations.esm.js +2 -2
- package/adapter-js/generators/pathnameToRouteId.cjs.js +2 -2
- package/adapter-js/generators/pathnameToRouteId.esm.js +2 -2
- package/adapter-js/generators/routes.cjs.js +2 -2
- package/adapter-js/generators/routes.esm.js +2 -2
- package/adapter-js/generators/setLocale.cjs.js +2 -2
- package/adapter-js/generators/setLocale.esm.js +2 -2
- package/adapter-js/generators/t.cjs.js +2 -2
- package/adapter-js/generators/t.esm.js +2 -2
- package/adapter-js/generators/tPluralise.cjs.js +2 -2
- package/adapter-js/generators/tPluralise.esm.js +2 -2
- package/adapter-js/generators/to.cjs.js +2 -2
- package/adapter-js/generators/to.esm.js +2 -2
- package/adapter-js/index.cjs.js +2 -4
- package/adapter-js/index.d.ts +16 -16
- package/adapter-js/index.esm.js +12 -14
- package/adapter-next/generators/webpack-define.cjs.js +25 -26
- package/adapter-next/generators/webpack-define.esm.js +25 -26
- package/package.json +3 -3
- package/adapter-js/generators/tInterpolateParams.cjs.js +0 -61
- package/adapter-js/generators/tInterpolateParams.esm.js +0 -56
- package/adapter-js/generators/tInterpolateParamsDeep.cjs.js +0 -63
- package/adapter-js/generators/tInterpolateParamsDeep.d.ts +0 -13
- package/adapter-js/generators/tInterpolateParamsDeep.esm.js +0 -58
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var i = createAdapter.createGenerator("js", (e)=>{
|
|
6
6
|
let { routes: { dynamicRoutes: a, staticRoutes: o } } = e;
|
|
7
7
|
return {
|
|
8
8
|
getI18nMetadata: {
|
|
@@ -63,4 +63,4 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
63
63
|
};
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
module.exports =
|
|
66
|
+
module.exports = i;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var i = createGenerator("js", (e)=>{
|
|
4
4
|
let { routes: { dynamicRoutes: a, staticRoutes: o } } = e;
|
|
5
5
|
return {
|
|
6
6
|
getI18nMetadata: {
|
|
@@ -61,4 +61,4 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
export {
|
|
64
|
+
export { i as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var n = createAdapter.createGenerator("js", (a)=>({
|
|
6
6
|
getT: {
|
|
7
7
|
name: "getT",
|
|
8
8
|
ext: "ts",
|
|
@@ -31,4 +31,4 @@ export default getT;
|
|
|
31
31
|
}
|
|
32
32
|
}));
|
|
33
33
|
|
|
34
|
-
module.exports =
|
|
34
|
+
module.exports = n;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var n = createGenerator("js", (a)=>({
|
|
4
4
|
getT: {
|
|
5
5
|
name: "getT",
|
|
6
6
|
ext: "ts",
|
|
@@ -29,4 +29,4 @@ export default getT;
|
|
|
29
29
|
}
|
|
30
30
|
}));
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { n as default };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
|
+
var functions = require('../../compiler/functions.cjs.js');
|
|
7
|
+
var helpers = require('../../compiler/helpers.cjs.js');
|
|
8
|
+
var imports = require('../../compiler/imports.cjs.js');
|
|
9
|
+
|
|
10
|
+
const i18nInterpolateParamsCompiler = ({ start: e, end: r })=>new functions.FunctionsCompiler({
|
|
11
|
+
imports: [],
|
|
12
|
+
comment: {
|
|
13
|
+
internal: !0
|
|
14
|
+
},
|
|
15
|
+
name: "i18nInterpolateParams",
|
|
16
|
+
generics: [
|
|
17
|
+
{
|
|
18
|
+
name: "T",
|
|
19
|
+
type: "string | number | boolean"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
args: [
|
|
23
|
+
{
|
|
24
|
+
name: "value",
|
|
25
|
+
type: "T",
|
|
26
|
+
optional: !1
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "params",
|
|
30
|
+
type: "object",
|
|
31
|
+
optional: !0
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
returns: {
|
|
35
|
+
name: "T"
|
|
36
|
+
},
|
|
37
|
+
body: ({ format: a })=>`params ? value.replace(
|
|
38
|
+
/${helpers.escapeEachChar(e)}(.*?)${helpers.escapeEachChar(r)}/g,
|
|
39
|
+
(_, key) =>
|
|
40
|
+
(params[key.trim()${"ts" === a ? " as keyof typeof params" : ""}] || "{{" + key + "}}") + "",
|
|
41
|
+
) : value`,
|
|
42
|
+
implicitReturn: !0
|
|
43
|
+
});
|
|
44
|
+
const i18nInterpolateParamsDeepCompiler = ()=>new functions.FunctionsCompiler({
|
|
45
|
+
imports: [
|
|
46
|
+
new imports.ImportsCompiler({
|
|
47
|
+
path: "i18nInterpolateParams",
|
|
48
|
+
named: [
|
|
49
|
+
{
|
|
50
|
+
name: "i18nInterpolateParams"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
],
|
|
55
|
+
comment: {
|
|
56
|
+
internal: !0
|
|
57
|
+
},
|
|
58
|
+
name: "i18nInterpolateParamsDeep",
|
|
59
|
+
generics: [
|
|
60
|
+
{
|
|
61
|
+
name: "T",
|
|
62
|
+
type: "string | object | unknown[]"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
args: [
|
|
66
|
+
{
|
|
67
|
+
name: "value",
|
|
68
|
+
type: "T",
|
|
69
|
+
optional: !1
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "params",
|
|
73
|
+
type: "object",
|
|
74
|
+
optional: !0
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
returns: {
|
|
78
|
+
name: "T"
|
|
79
|
+
},
|
|
80
|
+
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = i18nInterpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = i18nInterpolateParamsDeep(value[key], params); } } else { value = i18nInterpolateParams(value, params); } return value;'
|
|
81
|
+
});
|
|
82
|
+
var p = createAdapter.createGenerator("js", (a)=>{
|
|
83
|
+
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
84
|
+
return {
|
|
85
|
+
i18nInterpolateParams: {
|
|
86
|
+
dir: createAdapter.createGenerator.dirs.internal,
|
|
87
|
+
name: "i18nInterpolateParams",
|
|
88
|
+
ext: "ts",
|
|
89
|
+
index: !1,
|
|
90
|
+
disabled: !0,
|
|
91
|
+
content: ()=>i18nInterpolateParamsCompiler(r).$out("ts", {
|
|
92
|
+
imports: !1,
|
|
93
|
+
exports: "named"
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
i18nInterpolateParamsDeep: {
|
|
97
|
+
dir: createAdapter.createGenerator.dirs.internal,
|
|
98
|
+
name: "i18nInterpolateParamsDeep",
|
|
99
|
+
ext: "ts",
|
|
100
|
+
index: !1,
|
|
101
|
+
disabled: !0,
|
|
102
|
+
content: ()=>i18nInterpolateParamsDeepCompiler().$out("ts", {
|
|
103
|
+
imports: {},
|
|
104
|
+
exports: "named",
|
|
105
|
+
style: "function"
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
exports.default = p;
|
|
112
|
+
exports.i18nInterpolateParamsCompiler = i18nInterpolateParamsCompiler;
|
|
113
|
+
exports.i18nInterpolateParamsDeepCompiler = i18nInterpolateParamsDeepCompiler;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { FunctionsCompiler } from "../../compiler/functions";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const i18nInterpolateParamsCompiler: ({ start, end, }: {
|
|
3
3
|
start: string;
|
|
4
4
|
end: string;
|
|
5
5
|
}) => FunctionsCompiler;
|
|
6
|
+
export declare const i18nInterpolateParamsDeepCompiler: () => FunctionsCompiler;
|
|
6
7
|
declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"js">) => {
|
|
7
|
-
|
|
8
|
+
i18nInterpolateParams: {
|
|
9
|
+
dir: string;
|
|
10
|
+
name: string;
|
|
11
|
+
ext: "ts";
|
|
12
|
+
index: false;
|
|
13
|
+
disabled: true;
|
|
14
|
+
content: () => string;
|
|
15
|
+
};
|
|
16
|
+
i18nInterpolateParamsDeep: {
|
|
8
17
|
dir: string;
|
|
9
18
|
name: string;
|
|
10
19
|
ext: "ts";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
|
+
import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
3
|
+
import { escapeEachChar } from '../../compiler/helpers.esm.js';
|
|
4
|
+
import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
5
|
+
|
|
6
|
+
const i18nInterpolateParamsCompiler = ({ start: e, end: r })=>new FunctionsCompiler({
|
|
7
|
+
imports: [],
|
|
8
|
+
comment: {
|
|
9
|
+
internal: !0
|
|
10
|
+
},
|
|
11
|
+
name: "i18nInterpolateParams",
|
|
12
|
+
generics: [
|
|
13
|
+
{
|
|
14
|
+
name: "T",
|
|
15
|
+
type: "string | number | boolean"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
args: [
|
|
19
|
+
{
|
|
20
|
+
name: "value",
|
|
21
|
+
type: "T",
|
|
22
|
+
optional: !1
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "params",
|
|
26
|
+
type: "object",
|
|
27
|
+
optional: !0
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
returns: {
|
|
31
|
+
name: "T"
|
|
32
|
+
},
|
|
33
|
+
body: ({ format: a })=>`params ? value.replace(
|
|
34
|
+
/${escapeEachChar(e)}(.*?)${escapeEachChar(r)}/g,
|
|
35
|
+
(_, key) =>
|
|
36
|
+
(params[key.trim()${"ts" === a ? " as keyof typeof params" : ""}] || "{{" + key + "}}") + "",
|
|
37
|
+
) : value`,
|
|
38
|
+
implicitReturn: !0
|
|
39
|
+
});
|
|
40
|
+
const i18nInterpolateParamsDeepCompiler = ()=>new FunctionsCompiler({
|
|
41
|
+
imports: [
|
|
42
|
+
new ImportsCompiler({
|
|
43
|
+
path: "i18nInterpolateParams",
|
|
44
|
+
named: [
|
|
45
|
+
{
|
|
46
|
+
name: "i18nInterpolateParams"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
],
|
|
51
|
+
comment: {
|
|
52
|
+
internal: !0
|
|
53
|
+
},
|
|
54
|
+
name: "i18nInterpolateParamsDeep",
|
|
55
|
+
generics: [
|
|
56
|
+
{
|
|
57
|
+
name: "T",
|
|
58
|
+
type: "string | object | unknown[]"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
args: [
|
|
62
|
+
{
|
|
63
|
+
name: "value",
|
|
64
|
+
type: "T",
|
|
65
|
+
optional: !1
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "params",
|
|
69
|
+
type: "object",
|
|
70
|
+
optional: !0
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
returns: {
|
|
74
|
+
name: "T"
|
|
75
|
+
},
|
|
76
|
+
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = i18nInterpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = i18nInterpolateParamsDeep(value[key], params); } } else { value = i18nInterpolateParams(value, params); } return value;'
|
|
77
|
+
});
|
|
78
|
+
var p = createGenerator("js", (a)=>{
|
|
79
|
+
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
80
|
+
return {
|
|
81
|
+
i18nInterpolateParams: {
|
|
82
|
+
dir: createGenerator.dirs.internal,
|
|
83
|
+
name: "i18nInterpolateParams",
|
|
84
|
+
ext: "ts",
|
|
85
|
+
index: !1,
|
|
86
|
+
disabled: !0,
|
|
87
|
+
content: ()=>i18nInterpolateParamsCompiler(r).$out("ts", {
|
|
88
|
+
imports: !1,
|
|
89
|
+
exports: "named"
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
i18nInterpolateParamsDeep: {
|
|
93
|
+
dir: createGenerator.dirs.internal,
|
|
94
|
+
name: "i18nInterpolateParamsDeep",
|
|
95
|
+
ext: "ts",
|
|
96
|
+
index: !1,
|
|
97
|
+
disabled: !0,
|
|
98
|
+
content: ()=>i18nInterpolateParamsDeepCompiler().$out("ts", {
|
|
99
|
+
imports: {},
|
|
100
|
+
exports: "named",
|
|
101
|
+
style: "function"
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export { p as default, i18nInterpolateParamsCompiler, i18nInterpolateParamsDeepCompiler };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var f = createAdapter.createGenerator("js", (e)=>({
|
|
6
6
|
isLocale: {
|
|
7
7
|
name: "isLocale",
|
|
8
8
|
ext: "ts",
|
|
@@ -19,4 +19,4 @@ export default isLocale;
|
|
|
19
19
|
}
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
-
module.exports =
|
|
22
|
+
module.exports = f;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var f = createGenerator("js", (e)=>({
|
|
4
4
|
isLocale: {
|
|
5
5
|
name: "isLocale",
|
|
6
6
|
ext: "ts",
|
|
@@ -17,4 +17,4 @@ export default isLocale;
|
|
|
17
17
|
}
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export { f as default };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var helpers = require('../../compiler/helpers.cjs.js');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var g = createAdapter.createGenerator("js", (n)=>({
|
|
7
7
|
loadTranslations: {
|
|
8
8
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
9
9
|
name: "loadTranslations",
|
|
@@ -26,4 +26,4 @@ export const loadTranslations = (
|
|
|
26
26
|
}
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
|
-
module.exports =
|
|
29
|
+
module.exports = g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { getTranslationsDir } from '../../compiler/helpers.esm.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var g = createGenerator("js", (n)=>({
|
|
5
5
|
loadTranslations: {
|
|
6
6
|
dir: createGenerator.dirs.internal,
|
|
7
7
|
name: "loadTranslations",
|
|
@@ -24,4 +24,4 @@ export const loadTranslations = (
|
|
|
24
24
|
}
|
|
25
25
|
}));
|
|
26
26
|
|
|
27
|
-
export {
|
|
27
|
+
export { g as default };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var utils = require('@koine/utils');
|
|
4
4
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var l = createAdapter.createGenerator("js", (t)=>{
|
|
7
7
|
let { options: a } = t, { idDelimiter: r, optionalCatchAll: o, catchAll: n } = a.routes.tokens;
|
|
8
8
|
return {
|
|
9
9
|
pathnameToRouteId: {
|
|
@@ -30,4 +30,4 @@ export default pathnameToRouteId;
|
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
module.exports =
|
|
33
|
+
module.exports = l;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { escapeRegExp } from '@koine/utils';
|
|
2
2
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var l = createGenerator("js", (t)=>{
|
|
5
5
|
let { options: a } = t, { idDelimiter: r, optionalCatchAll: o, catchAll: n } = a.routes.tokens;
|
|
6
6
|
return {
|
|
7
7
|
pathnameToRouteId: {
|
|
@@ -28,4 +28,4 @@ export default pathnameToRouteId;
|
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { l as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var d = createAdapter.createGenerator("js", (t)=>{
|
|
6
6
|
let { routes: e } = t, n = (r)=>JSON.stringify(Object.fromEntries(Object.entries(e.byId).map(([t, e])=>[
|
|
7
7
|
t,
|
|
8
8
|
r(e)
|
|
@@ -84,4 +84,4 @@ export const routesSpa = ${r} as Record<string, string | Record<I18n.Locale, str
|
|
|
84
84
|
};
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
module.exports =
|
|
87
|
+
module.exports = d;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var d = createGenerator("js", (t)=>{
|
|
4
4
|
let { routes: e } = t, n = (r)=>JSON.stringify(Object.fromEntries(Object.entries(e.byId).map(([t, e])=>[
|
|
5
5
|
t,
|
|
6
6
|
r(e)
|
|
@@ -82,4 +82,4 @@ export const routesSpa = ${r} as Record<string, string | Record<I18n.Locale, str
|
|
|
82
82
|
};
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
export {
|
|
85
|
+
export { d as default };
|
|
@@ -29,7 +29,7 @@ const setGlobalLocale = (e)=>new functions.FunctionsCompiler({
|
|
|
29
29
|
body: `global.${helpers.GLOBAL_I18N_IDENTIFIER} = value`,
|
|
30
30
|
implicitReturn: !0
|
|
31
31
|
});
|
|
32
|
-
var
|
|
32
|
+
var c = createAdapter.createGenerator("js", (o)=>({
|
|
33
33
|
globals: {
|
|
34
34
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
35
35
|
name: "globals",
|
|
@@ -55,5 +55,5 @@ declare global {
|
|
|
55
55
|
}
|
|
56
56
|
}));
|
|
57
57
|
|
|
58
|
-
exports.default =
|
|
58
|
+
exports.default = c;
|
|
59
59
|
exports.setGlobalLocale = setGlobalLocale;
|
|
@@ -25,7 +25,7 @@ const setGlobalLocale = (e)=>new FunctionsCompiler({
|
|
|
25
25
|
body: `global.${GLOBAL_I18N_IDENTIFIER} = value`,
|
|
26
26
|
implicitReturn: !0
|
|
27
27
|
});
|
|
28
|
-
var
|
|
28
|
+
var c = createGenerator("js", (o)=>({
|
|
29
29
|
globals: {
|
|
30
30
|
dir: createGenerator.dirs.internal,
|
|
31
31
|
name: "globals",
|
|
@@ -51,4 +51,4 @@ declare global {
|
|
|
51
51
|
}
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
|
-
export {
|
|
54
|
+
export { c as default, setGlobalLocale };
|
|
@@ -108,7 +108,7 @@ let d = {
|
|
|
108
108
|
allImports: r
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
|
-
var
|
|
111
|
+
var u = createAdapter.createGenerator("js", (e)=>{
|
|
112
112
|
let { config: t, options: { translations: n, adapter: { modularize: r } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = y(a, t);
|
|
113
113
|
return r ? i.reduce((e, t)=>(e[t.name] = {
|
|
114
114
|
dir: o,
|
|
@@ -140,5 +140,5 @@ var c$1 = createAdapter.createGenerator("js", (e)=>{
|
|
|
140
140
|
};
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
exports.default =
|
|
143
|
+
exports.default = u;
|
|
144
144
|
exports.getTFunction = getTFunction;
|
|
@@ -104,7 +104,7 @@ let d = {
|
|
|
104
104
|
allImports: r
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
-
var
|
|
107
|
+
var u = createGenerator("js", (e)=>{
|
|
108
108
|
let { config: t, options: { translations: n, adapter: { modularize: r } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = y(a, t);
|
|
109
109
|
return r ? i.reduce((e, t)=>(e[t.name] = {
|
|
110
110
|
dir: o,
|
|
@@ -136,4 +136,4 @@ var c$1 = createGenerator("js", (e)=>{
|
|
|
136
136
|
};
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
export {
|
|
139
|
+
export { u as default, getTFunction };
|
|
@@ -37,7 +37,7 @@ const tPluralise = ()=>new functions.FunctionsCompiler({
|
|
|
37
37
|
body: 'values[count] || values[pluralRules.select(count)] || (count === 0 ? values.zero : values["other"])',
|
|
38
38
|
implicitReturn: !0
|
|
39
39
|
});
|
|
40
|
-
var
|
|
40
|
+
var T = createAdapter.createGenerator("js", (t)=>({
|
|
41
41
|
tPluralise: {
|
|
42
42
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
43
43
|
name: "tPluralise",
|
|
@@ -50,5 +50,5 @@ var I = createAdapter.createGenerator("js", (t)=>({
|
|
|
50
50
|
}
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
|
-
exports.default =
|
|
53
|
+
exports.default = T;
|
|
54
54
|
exports.tPluralise = tPluralise;
|
|
@@ -33,7 +33,7 @@ const tPluralise = ()=>new FunctionsCompiler({
|
|
|
33
33
|
body: 'values[count] || values[pluralRules.select(count)] || (count === 0 ? values.zero : values["other"])',
|
|
34
34
|
implicitReturn: !0
|
|
35
35
|
});
|
|
36
|
-
var
|
|
36
|
+
var T = createGenerator("js", (t)=>({
|
|
37
37
|
tPluralise: {
|
|
38
38
|
dir: createGenerator.dirs.internal,
|
|
39
39
|
name: "tPluralise",
|
|
@@ -46,4 +46,4 @@ var I = createGenerator("js", (t)=>({
|
|
|
46
46
|
}
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { T as default, tPluralise };
|
|
@@ -53,7 +53,7 @@ let l = {
|
|
|
53
53
|
}),
|
|
54
54
|
types: types.getImportTypes()
|
|
55
55
|
};
|
|
56
|
-
var
|
|
56
|
+
var I = createAdapter.createGenerator("js", (t)=>{
|
|
57
57
|
let { options: { routes: { tokens: { idDelimiter: e } } }, routes: { dynamicRoutes: a, staticRoutes: n } } = t;
|
|
58
58
|
return {
|
|
59
59
|
...function(t) {
|
|
@@ -222,5 +222,5 @@ export default toSpa;
|
|
|
222
222
|
};
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
exports.default =
|
|
225
|
+
exports.default = I;
|
|
226
226
|
exports.getToFunction = getToFunction;
|
|
@@ -49,7 +49,7 @@ let l = {
|
|
|
49
49
|
}),
|
|
50
50
|
types: getImportTypes()
|
|
51
51
|
};
|
|
52
|
-
var
|
|
52
|
+
var I = createGenerator("js", (t)=>{
|
|
53
53
|
let { options: { routes: { tokens: { idDelimiter: e } } }, routes: { dynamicRoutes: a, staticRoutes: n } } = t;
|
|
54
54
|
return {
|
|
55
55
|
...function(t) {
|
|
@@ -218,4 +218,4 @@ export default toSpa;
|
|
|
218
218
|
};
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
export {
|
|
221
|
+
export { I as default, getToFunction };
|
package/adapter-js/index.cjs.js
CHANGED
|
@@ -11,14 +11,13 @@ var formatUrl = require('./generators/formatUrl.cjs.js');
|
|
|
11
11
|
var getI18nDictionaries = require('./generators/getI18nDictionaries.cjs.js');
|
|
12
12
|
var getI18nMetadata = require('./generators/getI18nMetadata.cjs.js');
|
|
13
13
|
var getT = require('./generators/getT.cjs.js');
|
|
14
|
+
var interpolate = require('./generators/interpolate.cjs.js');
|
|
14
15
|
var isLocale = require('./generators/isLocale.cjs.js');
|
|
15
16
|
var loadTranslations = require('./generators/loadTranslations.cjs.js');
|
|
16
17
|
var pathnameToRouteId = require('./generators/pathnameToRouteId.cjs.js');
|
|
17
18
|
var routes = require('./generators/routes.cjs.js');
|
|
18
19
|
var setLocale = require('./generators/setLocale.cjs.js');
|
|
19
20
|
var t = require('./generators/t.cjs.js');
|
|
20
|
-
var tInterpolateParams = require('./generators/tInterpolateParams.cjs.js');
|
|
21
|
-
var tInterpolateParamsDeep = require('./generators/tInterpolateParamsDeep.cjs.js');
|
|
22
21
|
var tPluralise = require('./generators/tPluralise.cjs.js');
|
|
23
22
|
var to = require('./generators/to.cjs.js');
|
|
24
23
|
var types = require('./generators/types.cjs.js');
|
|
@@ -37,14 +36,13 @@ const adapterJs = createAdapter.createAdapter({
|
|
|
37
36
|
getI18nDictionaries,
|
|
38
37
|
getI18nMetadata,
|
|
39
38
|
getT,
|
|
39
|
+
interpolate.default,
|
|
40
40
|
isLocale,
|
|
41
41
|
loadTranslations,
|
|
42
42
|
pathnameToRouteId,
|
|
43
43
|
routes,
|
|
44
44
|
setLocale.default,
|
|
45
45
|
t.default,
|
|
46
|
-
tInterpolateParams.default,
|
|
47
|
-
tInterpolateParamsDeep.default,
|
|
48
46
|
tPluralise.default,
|
|
49
47
|
to.default,
|
|
50
48
|
types.default
|
package/adapter-js/index.d.ts
CHANGED
|
@@ -105,6 +105,22 @@ export declare const adapterJs: {
|
|
|
105
105
|
index: true;
|
|
106
106
|
content: () => string;
|
|
107
107
|
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
108
|
+
i18nInterpolateParams: boolean | ((file: {
|
|
109
|
+
dir: string;
|
|
110
|
+
name: string;
|
|
111
|
+
ext: "ts";
|
|
112
|
+
index: false;
|
|
113
|
+
disabled: true;
|
|
114
|
+
content: () => string;
|
|
115
|
+
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
116
|
+
i18nInterpolateParamsDeep: boolean | ((file: {
|
|
117
|
+
dir: string;
|
|
118
|
+
name: string;
|
|
119
|
+
ext: "ts";
|
|
120
|
+
index: false;
|
|
121
|
+
disabled: true;
|
|
122
|
+
content: () => string;
|
|
123
|
+
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
108
124
|
isLocale: boolean | ((file: {
|
|
109
125
|
name: string;
|
|
110
126
|
ext: "ts";
|
|
@@ -172,22 +188,6 @@ export declare const adapterJs: {
|
|
|
172
188
|
index: false;
|
|
173
189
|
content: () => string;
|
|
174
190
|
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
175
|
-
tInterpolateParams: boolean | ((file: {
|
|
176
|
-
dir: string;
|
|
177
|
-
name: string;
|
|
178
|
-
ext: "ts";
|
|
179
|
-
index: false;
|
|
180
|
-
disabled: true;
|
|
181
|
-
content: () => string;
|
|
182
|
-
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
183
|
-
tInterpolateParamsDeep: boolean | ((file: {
|
|
184
|
-
dir: string;
|
|
185
|
-
name: string;
|
|
186
|
-
ext: "ts";
|
|
187
|
-
index: false;
|
|
188
|
-
disabled: true;
|
|
189
|
-
content: () => string;
|
|
190
|
-
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
191
191
|
tPluralise: boolean | ((file: {
|
|
192
192
|
dir: string;
|
|
193
193
|
name: string;
|
package/adapter-js/index.esm.js
CHANGED
|
@@ -5,18 +5,17 @@ import e from './generators/dictionary.esm.js';
|
|
|
5
5
|
import a from './generators/formatTo.esm.js';
|
|
6
6
|
import m from './generators/formatUrl.esm.js';
|
|
7
7
|
import s from './generators/getI18nDictionaries.esm.js';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import p from './generators/
|
|
11
|
-
import f from './generators/
|
|
12
|
-
import g from './generators/
|
|
13
|
-
import l from './generators/
|
|
14
|
-
import d from './generators/
|
|
15
|
-
import c from './generators/
|
|
16
|
-
import u from './generators/
|
|
17
|
-
import T from './generators/
|
|
18
|
-
import I from './generators/
|
|
19
|
-
import P from './generators/to.esm.js';
|
|
8
|
+
import i from './generators/getI18nMetadata.esm.js';
|
|
9
|
+
import n from './generators/getT.esm.js';
|
|
10
|
+
import p from './generators/interpolate.esm.js';
|
|
11
|
+
import f from './generators/isLocale.esm.js';
|
|
12
|
+
import g from './generators/loadTranslations.esm.js';
|
|
13
|
+
import l from './generators/pathnameToRouteId.esm.js';
|
|
14
|
+
import d from './generators/routes.esm.js';
|
|
15
|
+
import c from './generators/setLocale.esm.js';
|
|
16
|
+
import u from './generators/t.esm.js';
|
|
17
|
+
import T from './generators/tPluralise.esm.js';
|
|
18
|
+
import I from './generators/to.esm.js';
|
|
20
19
|
import x from './generators/types.esm.js';
|
|
21
20
|
|
|
22
21
|
const adapterJs = createAdapter({
|
|
@@ -31,8 +30,8 @@ const adapterJs = createAdapter({
|
|
|
31
30
|
a,
|
|
32
31
|
m,
|
|
33
32
|
s,
|
|
34
|
-
n,
|
|
35
33
|
i,
|
|
34
|
+
n,
|
|
36
35
|
p,
|
|
37
36
|
f,
|
|
38
37
|
g,
|
|
@@ -42,7 +41,6 @@ const adapterJs = createAdapter({
|
|
|
42
41
|
u,
|
|
43
42
|
T,
|
|
44
43
|
I,
|
|
45
|
-
P,
|
|
46
44
|
x
|
|
47
45
|
],
|
|
48
46
|
getTransformers: ()=>({})
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var formatTo = require('../../adapter-js/generators/formatTo.cjs.js');
|
|
4
|
+
var interpolate = require('../../adapter-js/generators/interpolate.cjs.js');
|
|
4
5
|
var t = require('../../adapter-js/generators/t.cjs.js');
|
|
5
|
-
var tInterpolateParams = require('../../adapter-js/generators/tInterpolateParams.cjs.js');
|
|
6
|
-
var tInterpolateParamsDeep = require('../../adapter-js/generators/tInterpolateParamsDeep.cjs.js');
|
|
7
6
|
var tPluralise = require('../../adapter-js/generators/tPluralise.cjs.js');
|
|
8
7
|
var to = require('../../adapter-js/generators/to.cjs.js');
|
|
9
8
|
var types = require('../../adapter-js/generators/types.cjs.js');
|
|
@@ -15,10 +14,10 @@ function m(e) {
|
|
|
15
14
|
return e.replace(/\s+/g, " ");
|
|
16
15
|
}
|
|
17
16
|
var d = createAdapter.createGenerator("next", (u)=>{
|
|
18
|
-
let { config: d, options:
|
|
17
|
+
let { config: d, options: $ } = u, { debug: f } = d, { cwd: b, output: j } = $.write || {
|
|
19
18
|
cwd: "",
|
|
20
19
|
output: ""
|
|
21
|
-
}, { modularize: g } =
|
|
20
|
+
}, { modularize: g } = $.adapter, k = index.resolveGlobalizeOption($.adapter.globalize), x = k.functions.routes ? u.routes.byId : {}, y = k.functions.translations ? u.translations : {};
|
|
22
21
|
return {
|
|
23
22
|
webpackDefineGranularTypes: {
|
|
24
23
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
@@ -31,12 +30,12 @@ var d = createAdapter.createGenerator("next", (u)=>{
|
|
|
31
30
|
export {};
|
|
32
31
|
|
|
33
32
|
declare global {
|
|
34
|
-
${Object.keys(
|
|
35
|
-
let { fnName: n, params: a, pathnames: o } =
|
|
33
|
+
${Object.keys(x).map((t)=>{
|
|
34
|
+
let { fnName: n, params: a, pathnames: o } = x[t], r = `var ${k.prefixSafe}${n}: (`;
|
|
36
35
|
return a ? r += `params: ${helpers.compileDataParamsToType(a)}, ` : r += "", r += `locale?: ${e}) => ${JSON.stringify(o[d.defaultLocale])}`;
|
|
37
36
|
}).join(";\n ")};
|
|
38
|
-
${Object.keys(
|
|
39
|
-
let { fnName: n, params: a, values: o } =
|
|
37
|
+
${Object.keys(y).map((t)=>{
|
|
38
|
+
let { fnName: n, params: a, values: o } = y[t], r = `var ${k.prefixSafe}${n}: (`;
|
|
40
39
|
return a ? r += `params: ${helpers.compileDataParamsToType(a)}, ` : r += "", r += `locale?: ${e}) => ${JSON.stringify(o[d.defaultLocale])}`;
|
|
41
40
|
}).join(";\n ")};
|
|
42
41
|
}
|
|
@@ -55,8 +54,8 @@ const { DefinePlugin } = require("webpack");
|
|
|
55
54
|
const base = join("${b}", "${j}");
|
|
56
55
|
|
|
57
56
|
module.exports = {
|
|
58
|
-
${Object.keys(
|
|
59
|
-
let n =
|
|
57
|
+
${Object.keys(x).map((t)=>{
|
|
58
|
+
let n = x[t], { fnName: a } = n, { args: o, body: i } = to.getToFunction(n, d), { dir: l } = $.routes.functions;
|
|
60
59
|
return `${k.prefixSafe}${a}: DefinePlugin.runtimeValue(() => ` + m([
|
|
61
60
|
"`(function(" + o.map((e)=>e.name).join(", ") + ") {",
|
|
62
61
|
formatTo.formatTo(d).$outInline(),
|
|
@@ -67,18 +66,18 @@ module.exports = {
|
|
|
67
66
|
`{ fileDependencies: [join(base, ${g ? `"${l}", "${a}.ts"` : `"${l}.ts"`})] }`
|
|
68
67
|
].join(" "));
|
|
69
68
|
}).join("),\n ")}),
|
|
70
|
-
${Object.keys(
|
|
71
|
-
let r =
|
|
69
|
+
${Object.keys(y).map((e)=>{
|
|
70
|
+
let r = y[e], { fnName: i, params: l, typeValue: s, plural: c } = r, { args: p, body: u } = t.getTFunction(r, d), { dir: f } = $.translations.functions;
|
|
72
71
|
return `${k.prefixSafe}${i}: DefinePlugin.runtimeValue(() => ` + m([
|
|
73
72
|
"`(function(" + p.map((e)=>e.name).join(", ") + ") {",
|
|
74
|
-
l ?
|
|
75
|
-
l ? "Primitive" === s ? "" :
|
|
73
|
+
l ? interpolate.i18nInterpolateParamsCompiler($.translations.tokens.dynamicDelimiters).$outInline() : "",
|
|
74
|
+
l ? "Primitive" === s ? "" : interpolate.i18nInterpolateParamsDeepCompiler().$outInline() : "",
|
|
76
75
|
c ? tPluralise.tPluralise().$outInline() : "",
|
|
77
76
|
u({
|
|
78
77
|
format: "cjs"
|
|
79
78
|
}),
|
|
80
79
|
"})`,",
|
|
81
|
-
`{ fileDependencies: [join(base, ${g ? `"${
|
|
80
|
+
`{ fileDependencies: [join(base, ${g ? `"${f}", "${i}.ts"` : `"${f}.ts"`})] }`
|
|
82
81
|
].join(" "));
|
|
83
82
|
}).join(`),\n `)}),
|
|
84
83
|
};
|
|
@@ -116,7 +115,7 @@ declare global {
|
|
|
116
115
|
/**
|
|
117
116
|
* Global t function (allows to select any of the all available translations)
|
|
118
117
|
*
|
|
119
|
-
* @param path e.g. \`"myNamespace${
|
|
118
|
+
* @param path e.g. \`"myNamespace${$.translations.tokens.namespaceDelimiter}myPath.nestedKey"\`
|
|
120
119
|
*/
|
|
121
120
|
type GlobalT = <
|
|
122
121
|
TTrace extends import("../types").I18n.TranslationsTrace,
|
|
@@ -152,11 +151,11 @@ const { DefinePlugin } = require("webpack");
|
|
|
152
151
|
module.exports = {
|
|
153
152
|
${k.prefix}: DefinePlugin.runtimeValue(
|
|
154
153
|
(_ctx) => {
|
|
155
|
-
${"internal" ===
|
|
154
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define:ctx.module", _ctx.module);' : ""};
|
|
156
155
|
return {
|
|
157
156
|
to: \`(function(routeId, params) {
|
|
158
157
|
const locale = global.${helpers.GLOBAL_I18N_IDENTIFIER};
|
|
159
|
-
${"internal" ===
|
|
158
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define-compact:to", { locale });' : ""}
|
|
160
159
|
|
|
161
160
|
const defaultLocale = "${d.defaultLocale}";
|
|
162
161
|
|
|
@@ -167,8 +166,8 @@ module.exports = {
|
|
|
167
166
|
})}
|
|
168
167
|
|
|
169
168
|
const lookup = {
|
|
170
|
-
${Object.keys(
|
|
171
|
-
let { args: t, body: n } = to.getToFunction(
|
|
169
|
+
${Object.keys(x).map((e)=>{
|
|
170
|
+
let { args: t, body: n } = to.getToFunction(x[e], d);
|
|
172
171
|
return `"${e}": (${t.map((e)=>e.name).join(", ")}) => { ${n({
|
|
173
172
|
format: "cjs"
|
|
174
173
|
})} }`;
|
|
@@ -182,16 +181,16 @@ module.exports = {
|
|
|
182
181
|
})\`,
|
|
183
182
|
t: \`(function(trace, params) {
|
|
184
183
|
const locale = global.${helpers.GLOBAL_I18N_IDENTIFIER};
|
|
185
|
-
${"internal" ===
|
|
184
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define-compact:t", { locale });' : ""}
|
|
186
185
|
|
|
187
186
|
${tPluralise.tPluralise().$outInline()}
|
|
188
|
-
${
|
|
189
|
-
${
|
|
187
|
+
${interpolate.i18nInterpolateParamsCompiler($.translations.tokens.dynamicDelimiters).$outInline()}
|
|
188
|
+
${interpolate.i18nInterpolateParamsDeepCompiler().$outInline()}
|
|
190
189
|
|
|
191
190
|
const lookup = {
|
|
192
|
-
${Object.keys(
|
|
193
|
-
let
|
|
194
|
-
return `"${
|
|
191
|
+
${Object.keys(y).map((e)=>{
|
|
192
|
+
let t$1 = y[e], { trace: n } = t$1, { args: o, body: r } = t.getTFunction(t$1, d);
|
|
193
|
+
return `"${n}": (${o.map((e)=>e.name).join(", ")}) => { ${r({
|
|
195
194
|
format: "cjs"
|
|
196
195
|
})} }`;
|
|
197
196
|
}).join(",\n ")}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { formatTo } from '../../adapter-js/generators/formatTo.esm.js';
|
|
2
|
+
import { i18nInterpolateParamsCompiler, i18nInterpolateParamsDeepCompiler } from '../../adapter-js/generators/interpolate.esm.js';
|
|
2
3
|
import { getTFunction } from '../../adapter-js/generators/t.esm.js';
|
|
3
|
-
import { tInterpolateParams } from '../../adapter-js/generators/tInterpolateParams.esm.js';
|
|
4
|
-
import { tInterpolateParamsDeep } from '../../adapter-js/generators/tInterpolateParamsDeep.esm.js';
|
|
5
4
|
import { tPluralise } from '../../adapter-js/generators/tPluralise.esm.js';
|
|
6
5
|
import { getToFunction } from '../../adapter-js/generators/to.esm.js';
|
|
7
6
|
import { getTypeLocale } from '../../adapter-js/generators/types.esm.js';
|
|
@@ -13,10 +12,10 @@ function m(e) {
|
|
|
13
12
|
return e.replace(/\s+/g, " ");
|
|
14
13
|
}
|
|
15
14
|
var d = createGenerator("next", (u)=>{
|
|
16
|
-
let { config: d, options:
|
|
15
|
+
let { config: d, options: $ } = u, { debug: f } = d, { cwd: b, output: j } = $.write || {
|
|
17
16
|
cwd: "",
|
|
18
17
|
output: ""
|
|
19
|
-
}, { modularize: g } =
|
|
18
|
+
}, { modularize: g } = $.adapter, k = resolveGlobalizeOption($.adapter.globalize), x = k.functions.routes ? u.routes.byId : {}, y = k.functions.translations ? u.translations : {};
|
|
20
19
|
return {
|
|
21
20
|
webpackDefineGranularTypes: {
|
|
22
21
|
dir: createGenerator.dirs.internal,
|
|
@@ -29,12 +28,12 @@ var d = createGenerator("next", (u)=>{
|
|
|
29
28
|
export {};
|
|
30
29
|
|
|
31
30
|
declare global {
|
|
32
|
-
${Object.keys(
|
|
33
|
-
let { fnName: n, params: a, pathnames: o } =
|
|
31
|
+
${Object.keys(x).map((t)=>{
|
|
32
|
+
let { fnName: n, params: a, pathnames: o } = x[t], r = `var ${k.prefixSafe}${n}: (`;
|
|
34
33
|
return a ? r += `params: ${compileDataParamsToType(a)}, ` : r += "", r += `locale?: ${e}) => ${JSON.stringify(o[d.defaultLocale])}`;
|
|
35
34
|
}).join(";\n ")};
|
|
36
|
-
${Object.keys(
|
|
37
|
-
let { fnName: n, params: a, values: o } =
|
|
35
|
+
${Object.keys(y).map((t)=>{
|
|
36
|
+
let { fnName: n, params: a, values: o } = y[t], r = `var ${k.prefixSafe}${n}: (`;
|
|
38
37
|
return a ? r += `params: ${compileDataParamsToType(a)}, ` : r += "", r += `locale?: ${e}) => ${JSON.stringify(o[d.defaultLocale])}`;
|
|
39
38
|
}).join(";\n ")};
|
|
40
39
|
}
|
|
@@ -53,8 +52,8 @@ const { DefinePlugin } = require("webpack");
|
|
|
53
52
|
const base = join("${b}", "${j}");
|
|
54
53
|
|
|
55
54
|
module.exports = {
|
|
56
|
-
${Object.keys(
|
|
57
|
-
let n =
|
|
55
|
+
${Object.keys(x).map((t)=>{
|
|
56
|
+
let n = x[t], { fnName: a } = n, { args: o, body: i } = getToFunction(n, d), { dir: l } = $.routes.functions;
|
|
58
57
|
return `${k.prefixSafe}${a}: DefinePlugin.runtimeValue(() => ` + m([
|
|
59
58
|
"`(function(" + o.map((e)=>e.name).join(", ") + ") {",
|
|
60
59
|
formatTo(d).$outInline(),
|
|
@@ -65,18 +64,18 @@ module.exports = {
|
|
|
65
64
|
`{ fileDependencies: [join(base, ${g ? `"${l}", "${a}.ts"` : `"${l}.ts"`})] }`
|
|
66
65
|
].join(" "));
|
|
67
66
|
}).join("),\n ")}),
|
|
68
|
-
${Object.keys(
|
|
69
|
-
let r =
|
|
67
|
+
${Object.keys(y).map((e)=>{
|
|
68
|
+
let r = y[e], { fnName: i, params: l, typeValue: s, plural: c } = r, { args: p, body: u } = getTFunction(r, d), { dir: f } = $.translations.functions;
|
|
70
69
|
return `${k.prefixSafe}${i}: DefinePlugin.runtimeValue(() => ` + m([
|
|
71
70
|
"`(function(" + p.map((e)=>e.name).join(", ") + ") {",
|
|
72
|
-
l ?
|
|
73
|
-
l ? "Primitive" === s ? "" :
|
|
71
|
+
l ? i18nInterpolateParamsCompiler($.translations.tokens.dynamicDelimiters).$outInline() : "",
|
|
72
|
+
l ? "Primitive" === s ? "" : i18nInterpolateParamsDeepCompiler().$outInline() : "",
|
|
74
73
|
c ? tPluralise().$outInline() : "",
|
|
75
74
|
u({
|
|
76
75
|
format: "cjs"
|
|
77
76
|
}),
|
|
78
77
|
"})`,",
|
|
79
|
-
`{ fileDependencies: [join(base, ${g ? `"${
|
|
78
|
+
`{ fileDependencies: [join(base, ${g ? `"${f}", "${i}.ts"` : `"${f}.ts"`})] }`
|
|
80
79
|
].join(" "));
|
|
81
80
|
}).join(`),\n `)}),
|
|
82
81
|
};
|
|
@@ -114,7 +113,7 @@ declare global {
|
|
|
114
113
|
/**
|
|
115
114
|
* Global t function (allows to select any of the all available translations)
|
|
116
115
|
*
|
|
117
|
-
* @param path e.g. \`"myNamespace${
|
|
116
|
+
* @param path e.g. \`"myNamespace${$.translations.tokens.namespaceDelimiter}myPath.nestedKey"\`
|
|
118
117
|
*/
|
|
119
118
|
type GlobalT = <
|
|
120
119
|
TTrace extends import("../types").I18n.TranslationsTrace,
|
|
@@ -150,11 +149,11 @@ const { DefinePlugin } = require("webpack");
|
|
|
150
149
|
module.exports = {
|
|
151
150
|
${k.prefix}: DefinePlugin.runtimeValue(
|
|
152
151
|
(_ctx) => {
|
|
153
|
-
${"internal" ===
|
|
152
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define:ctx.module", _ctx.module);' : ""};
|
|
154
153
|
return {
|
|
155
154
|
to: \`(function(routeId, params) {
|
|
156
155
|
const locale = global.${GLOBAL_I18N_IDENTIFIER};
|
|
157
|
-
${"internal" ===
|
|
156
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define-compact:to", { locale });' : ""}
|
|
158
157
|
|
|
159
158
|
const defaultLocale = "${d.defaultLocale}";
|
|
160
159
|
|
|
@@ -165,8 +164,8 @@ module.exports = {
|
|
|
165
164
|
})}
|
|
166
165
|
|
|
167
166
|
const lookup = {
|
|
168
|
-
${Object.keys(
|
|
169
|
-
let { args: t, body: n } = getToFunction(
|
|
167
|
+
${Object.keys(x).map((e)=>{
|
|
168
|
+
let { args: t, body: n } = getToFunction(x[e], d);
|
|
170
169
|
return `"${e}": (${t.map((e)=>e.name).join(", ")}) => { ${n({
|
|
171
170
|
format: "cjs"
|
|
172
171
|
})} }`;
|
|
@@ -180,16 +179,16 @@ module.exports = {
|
|
|
180
179
|
})\`,
|
|
181
180
|
t: \`(function(trace, params) {
|
|
182
181
|
const locale = global.${GLOBAL_I18N_IDENTIFIER};
|
|
183
|
-
${"internal" ===
|
|
182
|
+
${"internal" === f ? 'console.log("[@koine/i18n]:webpack-define-compact:t", { locale });' : ""}
|
|
184
183
|
|
|
185
184
|
${tPluralise().$outInline()}
|
|
186
|
-
${
|
|
187
|
-
${
|
|
185
|
+
${i18nInterpolateParamsCompiler($.translations.tokens.dynamicDelimiters).$outInline()}
|
|
186
|
+
${i18nInterpolateParamsDeepCompiler().$outInline()}
|
|
188
187
|
|
|
189
188
|
const lookup = {
|
|
190
|
-
${Object.keys(
|
|
191
|
-
let
|
|
192
|
-
return `"${
|
|
189
|
+
${Object.keys(y).map((e)=>{
|
|
190
|
+
let t = y[e], { trace: n } = t, { args: o, body: r } = getTFunction(t, d);
|
|
191
|
+
return `"${n}": (${o.map((e)=>e.name).join(", ")}) => { ${r({
|
|
193
192
|
format: "cjs"
|
|
194
193
|
})} }`;
|
|
195
194
|
}).join(",\n ")}
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"node": "^14.18.0 || >=16.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@koine/node": "2.0.0-beta.
|
|
9
|
-
"@koine/utils": "2.0.0-beta.
|
|
8
|
+
"@koine/node": "2.0.0-beta.179",
|
|
9
|
+
"@koine/utils": "2.0.0-beta.179",
|
|
10
10
|
"comment-json": "^4.2.4",
|
|
11
11
|
"consola": "^3.2.3",
|
|
12
12
|
"glob": "^11.0.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"module": "./index.esm.js",
|
|
111
111
|
"main": "./index.cjs.js",
|
|
112
112
|
"types": "./index.esm.d.ts",
|
|
113
|
-
"version": "2.0.0-beta.
|
|
113
|
+
"version": "2.0.0-beta.179"
|
|
114
114
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
|
-
var functions = require('../../compiler/functions.cjs.js');
|
|
7
|
-
var helpers = require('../../compiler/helpers.cjs.js');
|
|
8
|
-
|
|
9
|
-
const tInterpolateParams = ({ start: e, end: r })=>new functions.FunctionsCompiler({
|
|
10
|
-
imports: [],
|
|
11
|
-
comment: {
|
|
12
|
-
internal: !0
|
|
13
|
-
},
|
|
14
|
-
name: "tInterpolateParams",
|
|
15
|
-
generics: [
|
|
16
|
-
{
|
|
17
|
-
name: "T",
|
|
18
|
-
type: "string | number | boolean"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
args: [
|
|
22
|
-
{
|
|
23
|
-
name: "value",
|
|
24
|
-
type: "T",
|
|
25
|
-
optional: !1
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "params",
|
|
29
|
-
type: "object",
|
|
30
|
-
optional: !0
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
returns: {
|
|
34
|
-
name: "T"
|
|
35
|
-
},
|
|
36
|
-
body: ({ format: t })=>`params ? value.replace(
|
|
37
|
-
/${helpers.escapeEachChar(e)}(.*?)${helpers.escapeEachChar(r)}/g,
|
|
38
|
-
(_, key) =>
|
|
39
|
-
(params[key.trim()${"ts" === t ? " as keyof typeof params" : ""}] || "{{" + key + "}}") + "",
|
|
40
|
-
) : value`,
|
|
41
|
-
implicitReturn: !0
|
|
42
|
-
});
|
|
43
|
-
var u = createAdapter.createGenerator("js", (t)=>{
|
|
44
|
-
let { options: a } = t, { dynamicDelimiters: r } = a.translations.tokens;
|
|
45
|
-
return {
|
|
46
|
-
tInterpolateParams: {
|
|
47
|
-
dir: createAdapter.createGenerator.dirs.internal,
|
|
48
|
-
name: "tInterpolateParams",
|
|
49
|
-
ext: "ts",
|
|
50
|
-
index: !1,
|
|
51
|
-
disabled: !0,
|
|
52
|
-
content: ()=>tInterpolateParams(r).$out("ts", {
|
|
53
|
-
imports: !1,
|
|
54
|
-
exports: "named"
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
exports.default = u;
|
|
61
|
-
exports.tInterpolateParams = tInterpolateParams;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
|
-
import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
3
|
-
import { escapeEachChar } from '../../compiler/helpers.esm.js';
|
|
4
|
-
|
|
5
|
-
const tInterpolateParams = ({ start: e, end: r })=>new FunctionsCompiler({
|
|
6
|
-
imports: [],
|
|
7
|
-
comment: {
|
|
8
|
-
internal: !0
|
|
9
|
-
},
|
|
10
|
-
name: "tInterpolateParams",
|
|
11
|
-
generics: [
|
|
12
|
-
{
|
|
13
|
-
name: "T",
|
|
14
|
-
type: "string | number | boolean"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
args: [
|
|
18
|
-
{
|
|
19
|
-
name: "value",
|
|
20
|
-
type: "T",
|
|
21
|
-
optional: !1
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: "params",
|
|
25
|
-
type: "object",
|
|
26
|
-
optional: !0
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
returns: {
|
|
30
|
-
name: "T"
|
|
31
|
-
},
|
|
32
|
-
body: ({ format: t })=>`params ? value.replace(
|
|
33
|
-
/${escapeEachChar(e)}(.*?)${escapeEachChar(r)}/g,
|
|
34
|
-
(_, key) =>
|
|
35
|
-
(params[key.trim()${"ts" === t ? " as keyof typeof params" : ""}] || "{{" + key + "}}") + "",
|
|
36
|
-
) : value`,
|
|
37
|
-
implicitReturn: !0
|
|
38
|
-
});
|
|
39
|
-
var u = createGenerator("js", (t)=>{
|
|
40
|
-
let { options: a } = t, { dynamicDelimiters: r } = a.translations.tokens;
|
|
41
|
-
return {
|
|
42
|
-
tInterpolateParams: {
|
|
43
|
-
dir: createGenerator.dirs.internal,
|
|
44
|
-
name: "tInterpolateParams",
|
|
45
|
-
ext: "ts",
|
|
46
|
-
index: !1,
|
|
47
|
-
disabled: !0,
|
|
48
|
-
content: ()=>tInterpolateParams(r).$out("ts", {
|
|
49
|
-
imports: !1,
|
|
50
|
-
exports: "named"
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export { u as default, tInterpolateParams };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
|
-
var functions = require('../../compiler/functions.cjs.js');
|
|
7
|
-
var imports = require('../../compiler/imports.cjs.js');
|
|
8
|
-
|
|
9
|
-
const tInterpolateParamsDeep = ()=>new functions.FunctionsCompiler({
|
|
10
|
-
imports: [
|
|
11
|
-
new imports.ImportsCompiler({
|
|
12
|
-
path: "tInterpolateParams",
|
|
13
|
-
named: [
|
|
14
|
-
{
|
|
15
|
-
name: "tInterpolateParams"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
})
|
|
19
|
-
],
|
|
20
|
-
comment: {
|
|
21
|
-
internal: !0
|
|
22
|
-
},
|
|
23
|
-
name: "tInterpolateParamsDeep",
|
|
24
|
-
generics: [
|
|
25
|
-
{
|
|
26
|
-
name: "T",
|
|
27
|
-
type: "string | object | unknown[]"
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
args: [
|
|
31
|
-
{
|
|
32
|
-
name: "value",
|
|
33
|
-
type: "T",
|
|
34
|
-
optional: !1
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "params",
|
|
38
|
-
type: "object",
|
|
39
|
-
optional: !0
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
returns: {
|
|
43
|
-
name: "T"
|
|
44
|
-
},
|
|
45
|
-
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = tInterpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = tInterpolateParamsDeep(value[key], params); } } else { value = tInterpolateParams(value, params); } return value;'
|
|
46
|
-
});
|
|
47
|
-
var T = createAdapter.createGenerator("js", (a)=>({
|
|
48
|
-
tInterpolateParamsDeep: {
|
|
49
|
-
dir: createAdapter.createGenerator.dirs.internal,
|
|
50
|
-
name: "tInterpolateParamsDeep",
|
|
51
|
-
ext: "ts",
|
|
52
|
-
index: !1,
|
|
53
|
-
disabled: !0,
|
|
54
|
-
content: ()=>tInterpolateParamsDeep().$out("ts", {
|
|
55
|
-
imports: {},
|
|
56
|
-
exports: "named",
|
|
57
|
-
style: "function"
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
exports.default = T;
|
|
63
|
-
exports.tInterpolateParamsDeep = tInterpolateParamsDeep;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { FunctionsCompiler } from "../../compiler/functions";
|
|
2
|
-
export declare const tInterpolateParamsDeep: () => FunctionsCompiler;
|
|
3
|
-
declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"js">) => {
|
|
4
|
-
tInterpolateParamsDeep: {
|
|
5
|
-
dir: string;
|
|
6
|
-
name: string;
|
|
7
|
-
ext: "ts";
|
|
8
|
-
index: false;
|
|
9
|
-
disabled: true;
|
|
10
|
-
content: () => string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
|
-
import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
3
|
-
import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
4
|
-
|
|
5
|
-
const tInterpolateParamsDeep = ()=>new FunctionsCompiler({
|
|
6
|
-
imports: [
|
|
7
|
-
new ImportsCompiler({
|
|
8
|
-
path: "tInterpolateParams",
|
|
9
|
-
named: [
|
|
10
|
-
{
|
|
11
|
-
name: "tInterpolateParams"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
})
|
|
15
|
-
],
|
|
16
|
-
comment: {
|
|
17
|
-
internal: !0
|
|
18
|
-
},
|
|
19
|
-
name: "tInterpolateParamsDeep",
|
|
20
|
-
generics: [
|
|
21
|
-
{
|
|
22
|
-
name: "T",
|
|
23
|
-
type: "string | object | unknown[]"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
args: [
|
|
27
|
-
{
|
|
28
|
-
name: "value",
|
|
29
|
-
type: "T",
|
|
30
|
-
optional: !1
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "params",
|
|
34
|
-
type: "object",
|
|
35
|
-
optional: !0
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
returns: {
|
|
39
|
-
name: "T"
|
|
40
|
-
},
|
|
41
|
-
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = tInterpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = tInterpolateParamsDeep(value[key], params); } } else { value = tInterpolateParams(value, params); } return value;'
|
|
42
|
-
});
|
|
43
|
-
var T = createGenerator("js", (a)=>({
|
|
44
|
-
tInterpolateParamsDeep: {
|
|
45
|
-
dir: createGenerator.dirs.internal,
|
|
46
|
-
name: "tInterpolateParamsDeep",
|
|
47
|
-
ext: "ts",
|
|
48
|
-
index: !1,
|
|
49
|
-
disabled: !0,
|
|
50
|
-
content: ()=>tInterpolateParamsDeep().$out("ts", {
|
|
51
|
-
imports: {},
|
|
52
|
-
exports: "named",
|
|
53
|
-
style: "function"
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
export { T as default, tInterpolateParamsDeep };
|