@koine/i18n 2.0.0-beta.198 → 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/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/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/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 };
|
package/adapter-js/index.cjs.js
CHANGED
|
@@ -10,6 +10,7 @@ var formatTo = require('./generators/formatTo.cjs.js');
|
|
|
10
10
|
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
|
+
var getLocale = require('./generators/getLocale.cjs.js');
|
|
13
14
|
var getT = require('./generators/getT.cjs.js');
|
|
14
15
|
var interpolate = require('./generators/interpolate.cjs.js');
|
|
15
16
|
var isLocale = require('./generators/isLocale.cjs.js');
|
|
@@ -36,6 +37,7 @@ const adapterJs = createAdapter.createAdapter({
|
|
|
36
37
|
formatUrl,
|
|
37
38
|
getI18nDictionaries,
|
|
38
39
|
getI18nMetadata,
|
|
40
|
+
getLocale,
|
|
39
41
|
getT,
|
|
40
42
|
interpolate.default,
|
|
41
43
|
isLocale,
|
package/adapter-js/index.d.ts
CHANGED
|
@@ -105,6 +105,12 @@ export declare const adapterJs: {
|
|
|
105
105
|
index: false;
|
|
106
106
|
content: () => string;
|
|
107
107
|
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
108
|
+
getLocaleInBrowser: boolean | ((file: {
|
|
109
|
+
name: string;
|
|
110
|
+
ext: "ts";
|
|
111
|
+
index: true;
|
|
112
|
+
content: () => string;
|
|
113
|
+
}) => import("../compiler").I18nCompiler.AdapterFile);
|
|
108
114
|
getT: boolean | ((file: {
|
|
109
115
|
name: string;
|
|
110
116
|
ext: "ts";
|
package/adapter-js/index.esm.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { createAdapter } from '../compiler/createAdapter.esm.js';
|
|
2
2
|
import o from './generators/config.esm.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import e from './generators/createT.esm.js';
|
|
4
|
+
import t 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
8
|
import i from './generators/getI18nMetadata.esm.js';
|
|
9
|
-
import n from './generators/
|
|
10
|
-
import p from './generators/
|
|
9
|
+
import n from './generators/getLocale.esm.js';
|
|
10
|
+
import p from './generators/getT.esm.js';
|
|
11
|
+
import g from './generators/interpolate.esm.js';
|
|
11
12
|
import f from './generators/isLocale.esm.js';
|
|
12
|
-
import
|
|
13
|
-
import
|
|
13
|
+
import l from './generators/loadTranslations.esm.js';
|
|
14
|
+
import c from './generators/pathnameToRouteId.esm.js';
|
|
14
15
|
import d from './generators/routes.esm.js';
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
16
|
+
import u from './generators/setLocale.esm.js';
|
|
17
|
+
import T from './generators/t.esm.js';
|
|
18
|
+
import I from './generators/tPluralise.esm.js';
|
|
19
|
+
import L from './generators/to.esm.js';
|
|
19
20
|
import x from './generators/types.esm.js';
|
|
20
21
|
|
|
21
22
|
const adapterJs = createAdapter({
|
|
@@ -26,22 +27,23 @@ const adapterJs = createAdapter({
|
|
|
26
27
|
getMeta: (r)=>({}),
|
|
27
28
|
getGenerators: (r)=>[
|
|
28
29
|
o,
|
|
29
|
-
t,
|
|
30
30
|
e,
|
|
31
|
+
t,
|
|
31
32
|
a,
|
|
32
33
|
m,
|
|
33
34
|
s,
|
|
34
35
|
i,
|
|
35
36
|
n,
|
|
36
37
|
p,
|
|
37
|
-
f,
|
|
38
38
|
g,
|
|
39
|
+
f,
|
|
39
40
|
l,
|
|
40
|
-
d,
|
|
41
41
|
c,
|
|
42
|
+
d,
|
|
42
43
|
u,
|
|
43
44
|
T,
|
|
44
45
|
I,
|
|
46
|
+
L,
|
|
45
47
|
x
|
|
46
48
|
],
|
|
47
49
|
getTransformers: ()=>({})
|
|
@@ -14,29 +14,31 @@ function transformPathname(e, t) {
|
|
|
14
14
|
return "/" + e.split("/").filter(Boolean).map((e)=>e.startsWith("[[...") ? `:${encodeURIComponent(e.slice(5, -2))}` : e.startsWith("[[") ? `:${encodeURIComponent(e.slice(2, -2))}` : e.startsWith("[") ? `:${encodeURIComponent(e.slice(1, -1))}` : `${encodeURIComponent(e)}`).join("/") + (t ? "/:wildcard*" : "");
|
|
15
15
|
}
|
|
16
16
|
let tweakNextConfig = (n, i, l)=>{
|
|
17
|
-
let { config: { defaultLocale: a, locales: p }, options: { routes: { localeParamName: c }, write: f } } = i, { webpack: u, i18n: m, modularizeImports: d = {}, ...w } = l,
|
|
17
|
+
let { config: { defaultLocale: a, locales: p }, options: { routes: { localeParamName: c }, write: f } } = i, { webpack: u, i18n: m, modularizeImports: d = {}, ...w } = l, g = {
|
|
18
18
|
...w,
|
|
19
19
|
modularizeImports: {
|
|
20
20
|
...createSwcTransforms.createSwcTransforms(i.options),
|
|
21
21
|
...d
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
...n.webpackPlugin && {
|
|
24
|
+
webpack: (r, i)=>{
|
|
25
|
+
let l = "function" == typeof u ? u(r, i) : r;
|
|
26
|
+
return {
|
|
27
|
+
...l,
|
|
28
|
+
plugins: [
|
|
29
|
+
...l.plugins || [],
|
|
30
|
+
new webpackPluginI18n.I18nWebpackPlugin(n),
|
|
31
|
+
new webpack.ContextReplacementPlugin(/^date-fns[/\\]locale$/, RegExp(`\\.[/\\\\](${p.join("|")})[/\\\\]index\\.js$`)),
|
|
32
|
+
f && new webpack.DefinePlugin(require(path.join(f.cwd, f.output, "internal/webpack-define-granular.cjs")))
|
|
33
|
+
].filter(Boolean)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
|
-
return c ? delete
|
|
38
|
+
return c ? delete g.i18n : (g.i18n = g.i18n || {
|
|
37
39
|
locales: p,
|
|
38
40
|
defaultLocale: a
|
|
39
|
-
},
|
|
41
|
+
}, g.i18n.locales = p, g.i18n.defaultLocale = a), g;
|
|
40
42
|
};
|
|
41
43
|
let getRedirects = async (e, t)=>{
|
|
42
44
|
let o = redirects.generateRedirects(t.config, t.options.routes, t.routes.byId);
|
|
@@ -17,7 +17,14 @@ export declare function shouldIgnoreNextJsConfigRun(): string | boolean | undefi
|
|
|
17
17
|
* @see https://nextjs.org/docs/messages/invalid-multi-match
|
|
18
18
|
*/
|
|
19
19
|
export declare function transformPathname(rawPathnameOrTemplate: string, wildcard?: boolean): string;
|
|
20
|
-
export
|
|
20
|
+
export type I18nCompilerOptionsNext = {
|
|
21
|
+
/**
|
|
22
|
+
* When `true` the i18n webpack plugin is added to the webpack configuration.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
webpackPlugin?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare let tweakNextConfig: (i18nCompilerOptions: I18nCompilerOptions & I18nCompilerOptionsNext, i18nCompilerReturn: I18nCompilerReturn, options: NextConfig) => NextConfig;
|
|
21
28
|
export declare let getRedirects: (prevRedirects: NextConfig["redirects"], i18nResult: I18nCompilerReturn) => Promise<import("next/dist/lib/load-custom-routes").Redirect[]>;
|
|
22
29
|
export declare let getRewrites: (prevRewrites: NextConfig["rewrites"], i18nResult: I18nCompilerReturn) => Promise<{
|
|
23
30
|
beforeFiles: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
@@ -12,29 +12,31 @@ function transformPathname(e, t) {
|
|
|
12
12
|
return "/" + e.split("/").filter(Boolean).map((e)=>e.startsWith("[[...") ? `:${encodeURIComponent(e.slice(5, -2))}` : e.startsWith("[[") ? `:${encodeURIComponent(e.slice(2, -2))}` : e.startsWith("[") ? `:${encodeURIComponent(e.slice(1, -1))}` : `${encodeURIComponent(e)}`).join("/") + (t ? "/:wildcard*" : "");
|
|
13
13
|
}
|
|
14
14
|
let tweakNextConfig = (n, i, l)=>{
|
|
15
|
-
let { config: { defaultLocale: a, locales: p }, options: { routes: { localeParamName: c }, write: f } } = i, { webpack: u, i18n: m, modularizeImports: d = {}, ...w } = l,
|
|
15
|
+
let { config: { defaultLocale: a, locales: p }, options: { routes: { localeParamName: c }, write: f } } = i, { webpack: u, i18n: m, modularizeImports: d = {}, ...w } = l, g = {
|
|
16
16
|
...w,
|
|
17
17
|
modularizeImports: {
|
|
18
18
|
...createSwcTransforms(i.options),
|
|
19
19
|
...d
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
...n.webpackPlugin && {
|
|
22
|
+
webpack: (r, i)=>{
|
|
23
|
+
let l = "function" == typeof u ? u(r, i) : r;
|
|
24
|
+
return {
|
|
25
|
+
...l,
|
|
26
|
+
plugins: [
|
|
27
|
+
...l.plugins || [],
|
|
28
|
+
new I18nWebpackPlugin(n),
|
|
29
|
+
new ContextReplacementPlugin(/^date-fns[/\\]locale$/, RegExp(`\\.[/\\\\](${p.join("|")})[/\\\\]index\\.js$`)),
|
|
30
|
+
f && new DefinePlugin(require(join(f.cwd, f.output, "internal/webpack-define-granular.cjs")))
|
|
31
|
+
].filter(Boolean)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
35
|
};
|
|
34
|
-
return c ? delete
|
|
36
|
+
return c ? delete g.i18n : (g.i18n = g.i18n || {
|
|
35
37
|
locales: p,
|
|
36
38
|
defaultLocale: a
|
|
37
|
-
},
|
|
39
|
+
}, g.i18n.locales = p, g.i18n.defaultLocale = a), g;
|
|
38
40
|
};
|
|
39
41
|
let getRedirects = async (e, t)=>{
|
|
40
42
|
let o = generateRedirects(t.config, t.options.routes, t.routes.byId);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { NextConfig } from "next";
|
|
2
2
|
import { type I18nCompilerOptions } from "../../compiler";
|
|
3
|
+
import { type I18nCompilerOptionsNext } from "./utils";
|
|
3
4
|
type NextConfigFn = (phase: string, context?: any) => Promise<NextConfig> | NextConfig;
|
|
4
5
|
export type WithI18nAsyncOptions = NextConfig & {
|
|
5
6
|
/**
|
|
6
7
|
* Configure the {@link I18nCompilerOptions I18nCompiler}
|
|
7
8
|
*/
|
|
8
|
-
i18nCompiler?: I18nCompilerOptions;
|
|
9
|
+
i18nCompiler?: I18nCompilerOptions & I18nCompilerOptionsNext;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* See [`withNx`](https://github.com/nrwl/nx/blob/master/packages/next/plugins/with-nx.ts#L216)
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { NextConfig } from "next";
|
|
13
13
|
import type { I18nCompilerOptions } from "../../compiler";
|
|
14
|
+
import { type I18nCompilerOptionsNext } from "./utils";
|
|
14
15
|
export type WithI18nOptions = NextConfig & {
|
|
15
16
|
/**
|
|
16
17
|
* Configure the {@link I18nCompilerOptions I18nCompiler}
|
|
17
18
|
*/
|
|
18
|
-
i18nCompiler?: I18nCompilerOptions;
|
|
19
|
+
i18nCompiler?: I18nCompilerOptions & I18nCompilerOptionsNext;
|
|
19
20
|
};
|
|
20
21
|
export declare let withI18n: (config?: WithI18nOptions) => NextConfig;
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"node": ">=18.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.199",
|
|
9
|
+
"@koine/utils": "2.0.0-beta.199",
|
|
10
10
|
"comment-json": "^4.2.4",
|
|
11
11
|
"consola": "^3.2.3",
|
|
12
12
|
"glob": "^11.0.0",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"module": "./index.esm.js",
|
|
124
124
|
"main": "./index.cjs.js",
|
|
125
125
|
"types": "./index.d.ts",
|
|
126
|
-
"version": "2.0.0-beta.
|
|
126
|
+
"version": "2.0.0-beta.199"
|
|
127
127
|
}
|