@koine/i18n 2.0.0-beta.197 → 2.0.0-beta.199
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/createT.cjs.js +2 -2
- package/adapter-js/generators/createT.esm.js +2 -2
- package/adapter-js/generators/dictionary.cjs.js +2 -2
- package/adapter-js/generators/dictionary.esm.js +2 -2
- package/adapter-js/generators/getLocale.cjs.js +28 -0
- package/adapter-js/generators/getLocale.d.ts +9 -0
- package/adapter-js/generators/getLocale.esm.js +26 -0
- 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 +2 -2
- package/adapter-js/generators/interpolate.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/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/generators/types.cjs.js +41 -40
- package/adapter-js/generators/types.esm.js +41 -40
- package/adapter-js/index.cjs.js +2 -0
- package/adapter-js/index.d.ts +6 -0
- package/adapter-js/index.esm.js +15 -13
- package/adapter-next/generators/router-app/i18nServer.cjs.js +2 -0
- package/adapter-next/generators/router-app/i18nServer.esm.js +2 -0
- package/adapter-next/plugin/rewrites.cjs.js +29 -30
- package/adapter-next/plugin/rewrites.d.ts +7 -0
- package/adapter-next/plugin/rewrites.esm.js +29 -31
- package/adapter-next/plugin/utils.cjs.js +16 -14
- package/adapter-next/plugin/utils.d.ts +8 -1
- package/adapter-next/plugin/utils.esm.js +16 -14
- package/adapter-next/plugin/with-async.d.ts +2 -1
- package/adapter-next/plugin/with-sync.d.ts +2 -1
- package/compiler/code/data-routes.cjs.js +42 -41
- package/compiler/code/data-routes.esm.js +42 -41
- package/compiler/code/data-translations.cjs.js +19 -18
- package/compiler/code/data-translations.esm.js +19 -18
- package/compiler/code/write.cjs.js +6 -5
- package/compiler/code/write.esm.js +6 -5
- package/i18nFormatRoutePathname.cjs.js +4 -3
- package/i18nFormatRoutePathname.esm.js +4 -3
- package/i18nInterpolateRouteParams.cjs.js +7 -6
- package/i18nInterpolateRouteParams.esm.js +7 -6
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var e = createAdapter.createGenerator("js", (e)=>{
|
|
6
6
|
let { config: { single: t }, options: { translations: { fallbackDefaultStrategy: a, tokens: { keyDelimiter: n, namespaceDelimiter: l } } } } = e;
|
|
7
7
|
return {
|
|
8
8
|
createT: {
|
|
@@ -114,4 +114,4 @@ export default createT;
|
|
|
114
114
|
};
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
module.exports =
|
|
117
|
+
module.exports = e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var e = createGenerator("js", (e)=>{
|
|
4
4
|
let { config: { single: t }, options: { translations: { fallbackDefaultStrategy: a, tokens: { keyDelimiter: n, namespaceDelimiter: l } } } } = e;
|
|
5
5
|
return {
|
|
6
6
|
createT: {
|
|
@@ -112,4 +112,4 @@ export default createT;
|
|
|
112
112
|
};
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
export {
|
|
115
|
+
export { e as default };
|
|
@@ -5,7 +5,7 @@ var dataTranslations = require('../../compiler/code/data-translations.cjs.js');
|
|
|
5
5
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
6
|
var helpers = require('../../compiler/helpers.cjs.js');
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var t = createAdapter.createGenerator("js", (o)=>{
|
|
9
9
|
let { input: n, options: { translations: a } } = o, { dir: m, prefix: p } = a.dictionaries, { translationFiles: s = [] } = n, c = s.reduce((e, t)=>{
|
|
10
10
|
let { locale: o, path: i } = t, n = dataTranslations.translationPathToNamespace(i);
|
|
11
11
|
return e[n] = e[n] || {}, e[n][o] = i, e;
|
|
@@ -31,4 +31,4 @@ export default ${a};
|
|
|
31
31
|
}, {});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
module.exports =
|
|
34
|
+
module.exports = t;
|
|
@@ -3,7 +3,7 @@ import { translationPathToNamespace, normaliseTranslationTraceIdentifier } from
|
|
|
3
3
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
4
4
|
import { getTranslationsDir } from '../../compiler/helpers.esm.js';
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var t = createGenerator("js", (o)=>{
|
|
7
7
|
let { input: n, options: { translations: a } } = o, { dir: m, prefix: p } = a.dictionaries, { translationFiles: s = [] } = n, c = s.reduce((e, t)=>{
|
|
8
8
|
let { locale: o, path: i } = t, n = translationPathToNamespace(i);
|
|
9
9
|
return e[n] = e[n] || {}, e[n][o] = i, e;
|
|
@@ -29,4 +29,4 @@ export default ${a};
|
|
|
29
29
|
}, {});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export {
|
|
32
|
+
export { t as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
|
+
var helpers = require('../../compiler/helpers.cjs.js');
|
|
5
|
+
|
|
6
|
+
var n = createAdapter.createGenerator("js", (e)=>{
|
|
7
|
+
let { config: t } = e;
|
|
8
|
+
return {
|
|
9
|
+
getLocaleInBrowser: {
|
|
10
|
+
name: "getLocaleInBrowser",
|
|
11
|
+
ext: "ts",
|
|
12
|
+
index: true,
|
|
13
|
+
content: ()=>`
|
|
14
|
+
import { defaultLocale } from "./defaultLocale";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get current locale in browser context
|
|
18
|
+
*/
|
|
19
|
+
export const getLocaleInBrowser = () =>
|
|
20
|
+
typeof window !== "undefined" ? window.${helpers.GLOBAL_I18N_IDENTIFIER} : "${t.defaultLocale}";
|
|
21
|
+
|
|
22
|
+
export default getLocaleInBrowser;
|
|
23
|
+
`
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
module.exports = n;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
|
+
import { GLOBAL_I18N_IDENTIFIER } from '../../compiler/helpers.esm.js';
|
|
3
|
+
|
|
4
|
+
var n = createGenerator("js", (e)=>{
|
|
5
|
+
let { config: t } = e;
|
|
6
|
+
return {
|
|
7
|
+
getLocaleInBrowser: {
|
|
8
|
+
name: "getLocaleInBrowser",
|
|
9
|
+
ext: "ts",
|
|
10
|
+
index: true,
|
|
11
|
+
content: ()=>`
|
|
12
|
+
import { defaultLocale } from "./defaultLocale";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get current locale in browser context
|
|
16
|
+
*/
|
|
17
|
+
export const getLocaleInBrowser = () =>
|
|
18
|
+
typeof window !== "undefined" ? window.${GLOBAL_I18N_IDENTIFIER} : "${t.defaultLocale}";
|
|
19
|
+
|
|
20
|
+
export default getLocaleInBrowser;
|
|
21
|
+
`
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { n as default };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var p = 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 = p;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var p = 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 { p as default };
|
|
@@ -79,7 +79,7 @@ const i18nInterpolateParamsDeepCompiler = ()=>new functions.FunctionsCompiler({
|
|
|
79
79
|
},
|
|
80
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
81
|
});
|
|
82
|
-
var
|
|
82
|
+
var g = createAdapter.createGenerator("js", (a)=>{
|
|
83
83
|
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
84
84
|
return {
|
|
85
85
|
i18nInterpolateParams: {
|
|
@@ -108,6 +108,6 @@ var p = createAdapter.createGenerator("js", (a)=>{
|
|
|
108
108
|
};
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
exports.default =
|
|
111
|
+
exports.default = g;
|
|
112
112
|
exports.i18nInterpolateParamsCompiler = i18nInterpolateParamsCompiler;
|
|
113
113
|
exports.i18nInterpolateParamsDeepCompiler = i18nInterpolateParamsDeepCompiler;
|
|
@@ -75,7 +75,7 @@ const i18nInterpolateParamsDeepCompiler = ()=>new FunctionsCompiler({
|
|
|
75
75
|
},
|
|
76
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
77
|
});
|
|
78
|
-
var
|
|
78
|
+
var g = createGenerator("js", (a)=>{
|
|
79
79
|
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
80
80
|
return {
|
|
81
81
|
i18nInterpolateParams: {
|
|
@@ -104,4 +104,4 @@ var p = createGenerator("js", (a)=>{
|
|
|
104
104
|
};
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
export {
|
|
107
|
+
export { g as default, i18nInterpolateParamsCompiler, i18nInterpolateParamsDeepCompiler };
|
|
@@ -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 l = 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 = l;
|
|
@@ -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 l = 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 { l 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 c = 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 = c;
|
|
@@ -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 c = 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 { c as default };
|
|
@@ -29,7 +29,7 @@ const setGlobalLocale = (e)=>new functions.FunctionsCompiler({
|
|
|
29
29
|
body: `globalThis.${helpers.GLOBAL_I18N_IDENTIFIER} = value`,
|
|
30
30
|
implicitReturn: true
|
|
31
31
|
});
|
|
32
|
-
var
|
|
32
|
+
var u = 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 = u;
|
|
59
59
|
exports.setGlobalLocale = setGlobalLocale;
|
|
@@ -25,7 +25,7 @@ const setGlobalLocale = (e)=>new FunctionsCompiler({
|
|
|
25
25
|
body: `globalThis.${GLOBAL_I18N_IDENTIFIER} = value`,
|
|
26
26
|
implicitReturn: true
|
|
27
27
|
});
|
|
28
|
-
var
|
|
28
|
+
var u = 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 { u as default, setGlobalLocale };
|
|
@@ -85,7 +85,7 @@ let d = {
|
|
|
85
85
|
]
|
|
86
86
|
})
|
|
87
87
|
};
|
|
88
|
-
var
|
|
88
|
+
var T = createAdapter.createGenerator("js", (e)=>{
|
|
89
89
|
let { config: t, options: { translations: n, adapter: { options: { modularize: r } } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = ((e, t)=>{
|
|
90
90
|
let n = [], r = new Set();
|
|
91
91
|
for(let a in r.add(d.types), e){
|
|
@@ -143,5 +143,5 @@ var u = createAdapter.createGenerator("js", (e)=>{
|
|
|
143
143
|
};
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
exports.default =
|
|
146
|
+
exports.default = T;
|
|
147
147
|
exports.getTFunction = getTFunction;
|
|
@@ -81,7 +81,7 @@ let d = {
|
|
|
81
81
|
]
|
|
82
82
|
})
|
|
83
83
|
};
|
|
84
|
-
var
|
|
84
|
+
var T = createGenerator("js", (e)=>{
|
|
85
85
|
let { config: t, options: { translations: n, adapter: { options: { modularize: r } } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = ((e, t)=>{
|
|
86
86
|
let n = [], r = new Set();
|
|
87
87
|
for(let a in r.add(d.types), e){
|
|
@@ -139,4 +139,4 @@ var u = createGenerator("js", (e)=>{
|
|
|
139
139
|
};
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
export {
|
|
142
|
+
export { T 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: true
|
|
39
39
|
});
|
|
40
|
-
var
|
|
40
|
+
var I = createAdapter.createGenerator("js", (t)=>({
|
|
41
41
|
tPluralise: {
|
|
42
42
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
43
43
|
name: "tPluralise",
|
|
@@ -50,5 +50,5 @@ var T = createAdapter.createGenerator("js", (t)=>({
|
|
|
50
50
|
}
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
|
-
exports.default =
|
|
53
|
+
exports.default = I;
|
|
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: true
|
|
35
35
|
});
|
|
36
|
-
var
|
|
36
|
+
var I = createGenerator("js", (t)=>({
|
|
37
37
|
tPluralise: {
|
|
38
38
|
dir: createGenerator.dirs.internal,
|
|
39
39
|
name: "tPluralise",
|
|
@@ -46,4 +46,4 @@ var T = createGenerator("js", (t)=>({
|
|
|
46
46
|
}
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
|
-
export {
|
|
49
|
+
export { I as default, tPluralise };
|
|
@@ -53,7 +53,7 @@ let l = {
|
|
|
53
53
|
}),
|
|
54
54
|
types: types.getImportTypes()
|
|
55
55
|
};
|
|
56
|
-
var
|
|
56
|
+
var L = 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) {
|
|
@@ -225,5 +225,5 @@ export default toSpa;
|
|
|
225
225
|
};
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
-
exports.default =
|
|
228
|
+
exports.default = L;
|
|
229
229
|
exports.getToFunction = getToFunction;
|
|
@@ -49,7 +49,7 @@ let l = {
|
|
|
49
49
|
}),
|
|
50
50
|
types: getImportTypes()
|
|
51
51
|
};
|
|
52
|
-
var
|
|
52
|
+
var L = createGenerator("js", (t)=>{
|
|
53
53
|
let { options: { routes: { tokens: { idDelimiter: e } } }, routes: { dynamicRoutes: a, staticRoutes: n } } = t;
|
|
54
54
|
return {
|
|
55
55
|
...function(t) {
|
|
@@ -221,4 +221,4 @@ export default toSpa;
|
|
|
221
221
|
};
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
export {
|
|
224
|
+
export { L as default, getToFunction };
|
|
@@ -9,15 +9,16 @@ var imports = require('../../compiler/imports.cjs.js');
|
|
|
9
9
|
var pluralisation = require('../../compiler/pluralisation.cjs.js');
|
|
10
10
|
|
|
11
11
|
function getTypeLocale(e) {
|
|
12
|
-
return
|
|
12
|
+
return m(e.locales);
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
let T = /;\[\];/g, y = /;+/g;
|
|
15
|
+
function m(e, t = true) {
|
|
15
16
|
return (t ? e.sort() : e).filter(utils.isString).map((e)=>`"${e}"`).join(" | ");
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
18
|
+
function u(e, t) {
|
|
19
|
+
return m(Object.keys(e.byId).filter((a)=>t(a, e.byId[a]))) || "never";
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function h(e) {
|
|
21
22
|
return `{
|
|
22
23
|
${e.join("\n ")}
|
|
23
24
|
}`;
|
|
@@ -32,13 +33,13 @@ const getImportTypes = ()=>new imports.ImportsCompiler({
|
|
|
32
33
|
]
|
|
33
34
|
});
|
|
34
35
|
var x = createAdapter.createGenerator("js", (i)=>{
|
|
35
|
-
let { options: { routes: { tokens: { idDelimiter:
|
|
36
|
-
let { config: i, routes:
|
|
36
|
+
let { options: { routes: { tokens: { idDelimiter: m } }, translations: { tokens: { keyDelimiter: f, namespaceDelimiter: I } } } } = i, R = function(s) {
|
|
37
|
+
let { config: i, routes: m, options: f } = s;
|
|
37
38
|
return {
|
|
38
39
|
Locale: getTypeLocale(i),
|
|
39
|
-
RouteIdStatic:
|
|
40
|
-
RouteIdDynamic:
|
|
41
|
-
RouteSpa:
|
|
40
|
+
RouteIdStatic: u(m, (e, { params: t })=>!t),
|
|
41
|
+
RouteIdDynamic: u(m, (e, { params: t })=>!!t),
|
|
42
|
+
RouteSpa: h(function(e, t, a) {
|
|
42
43
|
let n = Object.keys(t.byId).reduce((e, a)=>{
|
|
43
44
|
if (t.byId[a].inWildcard) for(let n = 0; n < t.wildcardIds.length; n++){
|
|
44
45
|
let s = t.wildcardIds[n];
|
|
@@ -55,28 +56,28 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
55
56
|
s.push(`"${o}": { ${l.join(" ")} }`);
|
|
56
57
|
}
|
|
57
58
|
return s;
|
|
58
|
-
}(i,
|
|
59
|
-
RoutePathnames:
|
|
59
|
+
}(i, m, f)),
|
|
60
|
+
RoutePathnames: h(function(e, t) {
|
|
60
61
|
let a = [];
|
|
61
62
|
for(let n in t.byId){
|
|
62
63
|
let s = t.byId[n];
|
|
63
64
|
a.push(`"${s.id}": "${s.pathnames[e.defaultLocale]}";`);
|
|
64
65
|
}
|
|
65
66
|
return a;
|
|
66
|
-
}(i,
|
|
67
|
-
RouteParams:
|
|
67
|
+
}(i, m)),
|
|
68
|
+
RouteParams: h(function(e) {
|
|
68
69
|
let t = [];
|
|
69
70
|
for(let a in e.byId){
|
|
70
71
|
let { params: n } = e.byId[a];
|
|
71
72
|
n && t.push(`"${a}": ${helpers.compileDataParamsToType(n)};`);
|
|
72
73
|
}
|
|
73
74
|
return t;
|
|
74
|
-
}(
|
|
75
|
-
TranslationsDictionary:
|
|
76
|
-
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths:
|
|
77
|
-
for(let s = 0; s <
|
|
78
|
-
let { path: o, data: r } =
|
|
79
|
-
|
|
75
|
+
}(m)),
|
|
76
|
+
TranslationsDictionary: h(function(s) {
|
|
77
|
+
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths: m } } } = s, u = helpers.filterInputTranslationFiles(i, m, (e)=>e.locale === o), h = [];
|
|
78
|
+
for(let s = 0; s < u.length; s++){
|
|
79
|
+
let { path: o, data: r } = u[s], i = o.replace(".json", "");
|
|
80
|
+
h.push(`"${i}": ${function s(o) {
|
|
80
81
|
let r = "", i = "";
|
|
81
82
|
if (utils.isBoolean(o) ? i = "boolean" : utils.isString(o) && (i = "string"), i) r += i + ";";
|
|
82
83
|
else if (o) {
|
|
@@ -93,10 +94,10 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
93
94
|
r += "};";
|
|
94
95
|
}
|
|
95
96
|
} else r += "";
|
|
96
|
-
return (r = r.replace(
|
|
97
|
+
return (r = r.replace(T, "[];")).replace(y, ";");
|
|
97
98
|
}(r)}`);
|
|
98
99
|
}
|
|
99
|
-
return
|
|
100
|
+
return h.sort();
|
|
100
101
|
}(s))
|
|
101
102
|
};
|
|
102
103
|
}(i);
|
|
@@ -148,7 +149,7 @@ export namespace I18n {
|
|
|
148
149
|
/**
|
|
149
150
|
* Any of the available locale code
|
|
150
151
|
*/
|
|
151
|
-
export type Locale = ${
|
|
152
|
+
export type Locale = ${R.Locale};
|
|
152
153
|
|
|
153
154
|
/**
|
|
154
155
|
* Utility to map values by all available locales
|
|
@@ -179,32 +180,32 @@ export namespace I18n {
|
|
|
179
180
|
/**
|
|
180
181
|
* The static routes available ids
|
|
181
182
|
*/
|
|
182
|
-
export type RouteIdStatic = ${
|
|
183
|
+
export type RouteIdStatic = ${R.RouteIdStatic};
|
|
183
184
|
|
|
184
185
|
/**
|
|
185
186
|
* The dynamic routes available ids
|
|
186
187
|
*/
|
|
187
|
-
export type RouteIdDynamic = ${
|
|
188
|
+
export type RouteIdDynamic = ${R.RouteIdDynamic};
|
|
188
189
|
|
|
189
190
|
/**
|
|
190
191
|
* Route dynamic params dictionary for each dynamic route id
|
|
191
192
|
*/
|
|
192
|
-
export type RouteParams = ${
|
|
193
|
+
export type RouteParams = ${R.RouteParams};
|
|
193
194
|
|
|
194
195
|
/**
|
|
195
196
|
* Map every route id to its actual pathname value for the default locale
|
|
196
197
|
*/
|
|
197
|
-
export type RoutePathnames = ${
|
|
198
|
+
export type RoutePathnames = ${R.RoutePathnames};
|
|
198
199
|
|
|
199
200
|
/**
|
|
200
201
|
* Map every SPA path divided by their roots to their actual pathname value for the default locale
|
|
201
202
|
*/
|
|
202
|
-
export type RouteSpa = ${
|
|
203
|
+
export type RouteSpa = ${R.RouteSpa};
|
|
203
204
|
|
|
204
205
|
/**
|
|
205
206
|
* Utility to join two route ids
|
|
206
207
|
*/
|
|
207
|
-
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${
|
|
208
|
+
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${m}\${Tail}\` extends RouteId ? \`\${Root}${m}\${Tail}\` : never;
|
|
208
209
|
|
|
209
210
|
/**
|
|
210
211
|
* Extract all children routes that starts with the given string
|
|
@@ -221,7 +222,7 @@ export namespace I18n {
|
|
|
221
222
|
* The types extracted from the translations JSON files, this is a little
|
|
222
223
|
* more sophisticated than the type result of \`typeof "./en/messages.json"\`
|
|
223
224
|
*/
|
|
224
|
-
export type TranslationsDictionary = ${
|
|
225
|
+
export type TranslationsDictionary = ${R.TranslationsDictionary};
|
|
225
226
|
|
|
226
227
|
/**
|
|
227
228
|
* Any of the available translations dictionary namespaces
|
|
@@ -243,13 +244,13 @@ export namespace I18n {
|
|
|
243
244
|
*
|
|
244
245
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
245
246
|
* - \`namespace\` only a namespace
|
|
246
|
-
* - \`namespace${
|
|
247
|
-
* - \`namespace${
|
|
247
|
+
* - \`namespace${I}myKey\` sub dictionaries within a namespace
|
|
248
|
+
* - \`namespace${I}myKey.nested\` whatever nested level of nesting
|
|
248
249
|
*/
|
|
249
250
|
export type TranslationsChildrenOf<T extends TranslationAtGeneric> =
|
|
250
251
|
T extends TranslationsNamespace
|
|
251
252
|
? TranslationsPaths<TranslationsDictionary[T]>
|
|
252
|
-
: T extends \`\${infer Namespace}${
|
|
253
|
+
: T extends \`\${infer Namespace}${I}\${infer Path}\`
|
|
253
254
|
? Namespace extends TranslationsNamespace
|
|
254
255
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path> extends object
|
|
255
256
|
? TranslationsPaths<I18nUtils.Get<TranslationsDictionary[Namespace], Path>>
|
|
@@ -259,12 +260,12 @@ export namespace I18n {
|
|
|
259
260
|
|
|
260
261
|
/**
|
|
261
262
|
* All translations ancestor partial _paths_ of the given one, e.g. if \`T\` would be
|
|
262
|
-
* \`"area${
|
|
263
|
-
* \`"area${
|
|
263
|
+
* \`"area${f}main${f}[id]${f}edit"\` the generated type would be the union
|
|
264
|
+
* \`"area${f}main${f}[id]" | "area${f}main" | "area"\`.
|
|
264
265
|
*/
|
|
265
266
|
export type TranslationsAncestorsOf<
|
|
266
267
|
T extends string,
|
|
267
|
-
TSeparator extends string = "${
|
|
268
|
+
TSeparator extends string = "${f}",
|
|
268
269
|
> = I18nUtils.BuildRecursiveJoin<Split<T, TSeparator>, TSeparator>;
|
|
269
270
|
|
|
270
271
|
/**
|
|
@@ -272,13 +273,13 @@ export namespace I18n {
|
|
|
272
273
|
*
|
|
273
274
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
274
275
|
* - \`namespace\` only a namespace
|
|
275
|
-
* - \`namespace${
|
|
276
|
-
* - \`namespace${
|
|
276
|
+
* - \`namespace${I}myKey\` sub dictionaries within a namespace
|
|
277
|
+
* - \`namespace${I}myKey${f}nested\` whatever nested level of nesting
|
|
277
278
|
*/
|
|
278
279
|
export type TranslationAt<T extends TranslationAtGeneric> =
|
|
279
280
|
T extends TranslationsNamespace
|
|
280
281
|
? TranslationsDictionary[T]
|
|
281
|
-
: T extends \`\${infer Namespace}${
|
|
282
|
+
: T extends \`\${infer Namespace}${I}\${infer Path}\`
|
|
282
283
|
? Namespace extends TranslationsNamespace
|
|
283
284
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path>
|
|
284
285
|
: never
|
|
@@ -297,7 +298,7 @@ export namespace I18n {
|
|
|
297
298
|
*
|
|
298
299
|
* \`T\` can be any of all possible paths:
|
|
299
300
|
* - \`myKey\` sub dictionaries within a namespace
|
|
300
|
-
* - \`myKey${
|
|
301
|
+
* - \`myKey${f}nested\` whatever nested level of nesting within a namespace
|
|
301
302
|
*/
|
|
302
303
|
export type TranslationAtNamespace<
|
|
303
304
|
TNamespace extends TranslationsNamespace,
|