@koine/i18n 2.0.0-beta.205 → 2.0.0-beta.207
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 +3 -2
- package/adapter-js/generators/createT.esm.js +3 -2
- package/adapter-js/generators/dictionary.cjs.js +10 -10
- package/adapter-js/generators/dictionary.esm.js +10 -10
- package/adapter-js/generators/getI18nDictionaries.cjs.js +1 -1
- package/adapter-js/generators/getI18nDictionaries.esm.js +1 -1
- package/adapter-js/generators/getLocale.cjs.js +21 -7
- package/adapter-js/generators/getLocale.d.ts +6 -0
- package/adapter-js/generators/getLocale.esm.js +21 -7
- 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 +17 -19
- package/adapter-js/generators/interpolate.d.ts +4 -6
- package/adapter-js/generators/interpolate.esm.js +15 -17
- package/adapter-js/generators/loadTranslations.cjs.js +2 -2
- package/adapter-js/generators/loadTranslations.esm.js +2 -2
- package/adapter-js/generators/{getI18nMetadata.cjs.js → metadata.cjs.js} +28 -5
- package/adapter-js/generators/metadata.d.ts +17 -0
- package/adapter-js/generators/{getI18nMetadata.esm.js → metadata.esm.js} +28 -5
- package/adapter-js/generators/{tPluralise.cjs.js → pluralise.cjs.js} +33 -11
- package/adapter-js/generators/{tPluralise.d.ts → pluralise.d.ts} +2 -2
- package/adapter-js/generators/{tPluralise.esm.js → pluralise.esm.js} +32 -10
- package/adapter-js/generators/routes.cjs.js +2 -2
- package/adapter-js/generators/routes.esm.js +2 -2
- package/adapter-js/generators/rtlLocales.cjs.js +48 -0
- package/adapter-js/generators/{getI18nMetadata.d.ts → rtlLocales.d.ts} +3 -3
- package/adapter-js/generators/rtlLocales.esm.js +46 -0
- package/adapter-js/generators/setLocale.cjs.js +29 -35
- package/adapter-js/generators/setLocale.d.ts +2 -5
- package/adapter-js/generators/setLocale.esm.js +29 -32
- package/adapter-js/generators/t.cjs.js +55 -53
- package/adapter-js/generators/t.esm.js +55 -53
- package/adapter-js/generators/to.cjs.js +3 -3
- package/adapter-js/generators/to.esm.js +3 -3
- package/adapter-js/generators/types-utils.cjs.js +325 -0
- package/adapter-js/generators/types-utils.d.ts +16 -0
- package/adapter-js/generators/types-utils.esm.js +323 -0
- package/adapter-js/generators/types.cjs.js +43 -35
- package/adapter-js/generators/types.esm.js +43 -35
- package/adapter-js/index.cjs.js +10 -6
- package/adapter-js/index.d.ts +41 -22
- package/adapter-js/index.esm.js +18 -14
- package/adapter-next/generators/router-app/I18nLayout.cjs.js +29 -23
- package/adapter-next/generators/router-app/I18nLayout.esm.js +29 -23
- package/adapter-next/generators/router-app/I18nLayoutRoot.cjs.js +2 -2
- package/adapter-next/generators/router-app/I18nLayoutRoot.esm.js +2 -2
- package/adapter-next/generators/router-app/I18nPage.cjs.js +2 -3
- package/adapter-next/generators/router-app/I18nPage.esm.js +2 -3
- package/adapter-next/generators/router-app/i18nServer.cjs.js +23 -20
- package/adapter-next/generators/router-app/i18nServer.esm.js +23 -20
- package/adapter-next/generators/router-pages/I18nApp.cjs.js +3 -2
- package/adapter-next/generators/router-pages/I18nApp.esm.js +3 -2
- package/adapter-next/generators/router-pages/I18nDocument.cjs.js +2 -2
- package/adapter-next/generators/router-pages/I18nDocument.esm.js +2 -2
- package/adapter-next/generators/router-pages/I18nHead.cjs.js +2 -2
- package/adapter-next/generators/router-pages/I18nHead.esm.js +2 -2
- package/adapter-next/generators/router-pages/i18nGet.cjs.js +2 -2
- package/adapter-next/generators/router-pages/i18nGet.esm.js +2 -2
- package/adapter-next/generators/webpack-define.cjs.js +7 -7
- package/adapter-next/generators/webpack-define.esm.js +8 -8
- package/adapter-next/index.cjs.js +4 -1
- package/adapter-next/index.d.ts +13 -2
- package/adapter-next/index.esm.js +4 -1
- package/adapter-react/generators/I18nEffects.cjs.js +1 -2
- package/adapter-react/generators/I18nEffects.esm.js +1 -2
- package/adapter-react/generators/I18nHeadTags.cjs.js +3 -2
- package/adapter-react/generators/I18nHeadTags.esm.js +3 -2
- package/adapter-react/generators/I18nMetadata.cjs.js +6 -5
- package/adapter-react/generators/I18nMetadata.esm.js +6 -5
- package/adapter-react/generators/I18nTranslate.cjs.js +4 -4
- package/adapter-react/generators/I18nTranslate.esm.js +4 -4
- package/adapter-react/generators/Trans.cjs.js +1 -1
- package/adapter-react/generators/Trans.esm.js +1 -1
- package/adapter-react/generators/getT.cjs.js +2 -3
- package/adapter-react/generators/getT.esm.js +2 -3
- package/adapter-react/generators/getTo.cjs.js +5 -5
- package/adapter-react/generators/getTo.esm.js +5 -5
- package/adapter-react/generators/locale.cjs.js +12 -12
- package/adapter-react/generators/locale.d.ts +2 -2
- package/adapter-react/generators/locale.esm.js +12 -12
- package/adapter-react/index.d.ts +2 -2
- package/compiler/code/data-translations.cjs.js +22 -23
- package/compiler/code/data-translations.esm.js +22 -23
- package/compiler/code/write.cjs.js +9 -9
- package/compiler/code/write.esm.js +9 -9
- package/compiler/createAdapter.cjs.js +1 -1
- package/compiler/createAdapter.esm.js +1 -1
- package/compiler/functions.cjs.js +8 -7
- package/compiler/functions.d.ts +6 -2
- package/compiler/functions.esm.js +8 -7
- package/compiler/input/data-direct.cjs.js +6 -6
- package/compiler/input/data-direct.esm.js +6 -6
- package/compiler/pluralisation.cjs.js +10 -13
- package/compiler/pluralisation.esm.js +10 -13
- package/i18nGetLocaleInBrowser.cjs.js +1 -1
- package/i18nGetLocaleInBrowser.esm.js +1 -1
- package/package.json +4 -4
- package/scripts/index.d.ts +9 -0
|
@@ -11,7 +11,8 @@ var e = createAdapter.createGenerator("js", (e)=>{
|
|
|
11
11
|
ext: "ts",
|
|
12
12
|
index: true,
|
|
13
13
|
content: ()=>`
|
|
14
|
-
import {
|
|
14
|
+
import type { I18nUtils } from "./internal/types";
|
|
15
|
+
import { interpolateParamsDeep } from "./internal/interpolateParamsDeep";
|
|
15
16
|
import type { I18n } from "./types";${t ? "" : `
|
|
16
17
|
import { defaultLocale } from "./defaultLocale";`}
|
|
17
18
|
|
|
@@ -46,7 +47,7 @@ export function createT<TDictionary extends I18nUtils.TranslationsDictionaryLoos
|
|
|
46
47
|
return (typeof fallback !== "undefined" ? fallback : ${"key" === a ? "trace" : 'value || ""'}) as TReturn;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
return (query ?
|
|
50
|
+
return (query ? interpolateParamsDeep(value, query) : value) as TReturn;
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -9,7 +9,8 @@ var e = createGenerator("js", (e)=>{
|
|
|
9
9
|
ext: "ts",
|
|
10
10
|
index: true,
|
|
11
11
|
content: ()=>`
|
|
12
|
-
import {
|
|
12
|
+
import type { I18nUtils } from "./internal/types";
|
|
13
|
+
import { interpolateParamsDeep } from "./internal/interpolateParamsDeep";
|
|
13
14
|
import type { I18n } from "./types";${t ? "" : `
|
|
14
15
|
import { defaultLocale } from "./defaultLocale";`}
|
|
15
16
|
|
|
@@ -44,7 +45,7 @@ export function createT<TDictionary extends I18nUtils.TranslationsDictionaryLoos
|
|
|
44
45
|
return (typeof fallback !== "undefined" ? fallback : ${"key" === a ? "trace" : 'value || ""'}) as TReturn;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
return (query ?
|
|
48
|
+
return (query ? interpolateParamsDeep(value, query) : value) as TReturn;
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -9,25 +9,25 @@ 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;
|
|
12
|
-
}, {})
|
|
13
|
-
return Object.keys(c).reduce((
|
|
14
|
-
let
|
|
15
|
-
return
|
|
12
|
+
}, {});
|
|
13
|
+
return Object.keys(c).reduce((r, o)=>{
|
|
14
|
+
let n = c[o], a = `$dictionary_${o}`, s = dataTranslations.normaliseTranslationTraceIdentifier(o, p);
|
|
15
|
+
return r[a] = {
|
|
16
16
|
dir: m,
|
|
17
|
-
name:
|
|
17
|
+
name: s,
|
|
18
18
|
ext: "ts",
|
|
19
19
|
index: true,
|
|
20
20
|
content: ()=>`
|
|
21
|
-
${Object.keys(
|
|
21
|
+
${Object.keys(n).map((t)=>`import ${utils.changeCaseSnake(t)} from "${helpers.getTranslationsDir(1)}/${t}/${n[t]}";`).join("\n")}
|
|
22
22
|
|
|
23
23
|
/* @__NO_SIDE_EFFECTS__ */
|
|
24
|
-
export const ${
|
|
25
|
-
${Object.keys(
|
|
24
|
+
export const ${s} = {
|
|
25
|
+
${Object.keys(n).map((t)=>`"${t}": ${utils.changeCaseSnake(t)}`).join(",\n ")}
|
|
26
26
|
} as const;
|
|
27
27
|
|
|
28
|
-
export default ${
|
|
28
|
+
export default ${s};
|
|
29
29
|
`
|
|
30
|
-
},
|
|
30
|
+
}, r;
|
|
31
31
|
}, {});
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -7,25 +7,25 @@ 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;
|
|
10
|
-
}, {})
|
|
11
|
-
return Object.keys(c).reduce((
|
|
12
|
-
let
|
|
13
|
-
return
|
|
10
|
+
}, {});
|
|
11
|
+
return Object.keys(c).reduce((r, o)=>{
|
|
12
|
+
let n = c[o], a = `$dictionary_${o}`, s = normaliseTranslationTraceIdentifier(o, p);
|
|
13
|
+
return r[a] = {
|
|
14
14
|
dir: m,
|
|
15
|
-
name:
|
|
15
|
+
name: s,
|
|
16
16
|
ext: "ts",
|
|
17
17
|
index: true,
|
|
18
18
|
content: ()=>`
|
|
19
|
-
${Object.keys(
|
|
19
|
+
${Object.keys(n).map((t)=>`import ${changeCaseSnake(t)} from "${getTranslationsDir(1)}/${t}/${n[t]}";`).join("\n")}
|
|
20
20
|
|
|
21
21
|
/* @__NO_SIDE_EFFECTS__ */
|
|
22
|
-
export const ${
|
|
23
|
-
${Object.keys(
|
|
22
|
+
export const ${s} = {
|
|
23
|
+
${Object.keys(n).map((t)=>`"${t}": ${changeCaseSnake(t)}`).join(",\n ")}
|
|
24
24
|
} as const;
|
|
25
25
|
|
|
26
|
-
export default ${
|
|
26
|
+
export default ${s};
|
|
27
27
|
`
|
|
28
|
-
},
|
|
28
|
+
}, r;
|
|
29
29
|
}, {});
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -9,7 +9,7 @@ var s = createAdapter.createGenerator("js", (n)=>({
|
|
|
9
9
|
ext: "ts",
|
|
10
10
|
index: false,
|
|
11
11
|
content: ()=>`
|
|
12
|
-
import type { I18nUtils } from "
|
|
12
|
+
import type { I18nUtils } from "./types";
|
|
13
13
|
import { defaultLocale } from "../defaultLocale";
|
|
14
14
|
import type { I18n } from "../types";
|
|
15
15
|
import { loadTranslations } from "./loadTranslations";
|
|
@@ -7,7 +7,7 @@ var s = createGenerator("js", (n)=>({
|
|
|
7
7
|
ext: "ts",
|
|
8
8
|
index: false,
|
|
9
9
|
content: ()=>`
|
|
10
|
-
import type { I18nUtils } from "
|
|
10
|
+
import type { I18nUtils } from "./types";
|
|
11
11
|
import { defaultLocale } from "../defaultLocale";
|
|
12
12
|
import type { I18n } from "../types";
|
|
13
13
|
import { loadTranslations } from "./loadTranslations";
|
|
@@ -3,21 +3,35 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var constants = require('../../compiler/constants.cjs.js');
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
let { config:
|
|
6
|
+
var i = createAdapter.createGenerator("js", (e)=>{
|
|
7
|
+
let { config: o } = e;
|
|
8
8
|
return {
|
|
9
|
+
getLocale: {
|
|
10
|
+
name: "getLocale",
|
|
11
|
+
ext: "ts",
|
|
12
|
+
index: true,
|
|
13
|
+
content: ()=>`
|
|
14
|
+
/**
|
|
15
|
+
* ## Get current locale
|
|
16
|
+
*
|
|
17
|
+
* This function is used to get the current locale in the global scope (\`globalThis\`)
|
|
18
|
+
*/
|
|
19
|
+
export const getLocale = () =>
|
|
20
|
+
globalThis.${constants.GLOBAL_I18N_IDENTIFIER} || "${o.defaultLocale}";
|
|
21
|
+
|
|
22
|
+
export default getLocale;
|
|
23
|
+
`
|
|
24
|
+
},
|
|
9
25
|
getLocaleInBrowser: {
|
|
10
26
|
name: "getLocaleInBrowser",
|
|
11
27
|
ext: "ts",
|
|
12
28
|
index: true,
|
|
13
29
|
content: ()=>`
|
|
14
|
-
import { defaultLocale } from "./defaultLocale";
|
|
15
|
-
|
|
16
30
|
/**
|
|
17
|
-
* Get current locale
|
|
31
|
+
* Get current locale from \`window\` (browser context)
|
|
18
32
|
*/
|
|
19
33
|
export const getLocaleInBrowser = () =>
|
|
20
|
-
typeof window !== "undefined" ? window.${constants.GLOBAL_I18N_IDENTIFIER} : "${
|
|
34
|
+
typeof window !== "undefined" ? window.${constants.GLOBAL_I18N_IDENTIFIER} : "${o.defaultLocale}";
|
|
21
35
|
|
|
22
36
|
export default getLocaleInBrowser;
|
|
23
37
|
`
|
|
@@ -25,4 +39,4 @@ export default getLocaleInBrowser;
|
|
|
25
39
|
};
|
|
26
40
|
});
|
|
27
41
|
|
|
28
|
-
module.exports =
|
|
42
|
+
module.exports = i;
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { GLOBAL_I18N_IDENTIFIER } from '../../compiler/constants.esm.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
let { config:
|
|
4
|
+
var i = createGenerator("js", (e)=>{
|
|
5
|
+
let { config: o } = e;
|
|
6
6
|
return {
|
|
7
|
+
getLocale: {
|
|
8
|
+
name: "getLocale",
|
|
9
|
+
ext: "ts",
|
|
10
|
+
index: true,
|
|
11
|
+
content: ()=>`
|
|
12
|
+
/**
|
|
13
|
+
* ## Get current locale
|
|
14
|
+
*
|
|
15
|
+
* This function is used to get the current locale in the global scope (\`globalThis\`)
|
|
16
|
+
*/
|
|
17
|
+
export const getLocale = () =>
|
|
18
|
+
globalThis.${GLOBAL_I18N_IDENTIFIER} || "${o.defaultLocale}";
|
|
19
|
+
|
|
20
|
+
export default getLocale;
|
|
21
|
+
`
|
|
22
|
+
},
|
|
7
23
|
getLocaleInBrowser: {
|
|
8
24
|
name: "getLocaleInBrowser",
|
|
9
25
|
ext: "ts",
|
|
10
26
|
index: true,
|
|
11
27
|
content: ()=>`
|
|
12
|
-
import { defaultLocale } from "./defaultLocale";
|
|
13
|
-
|
|
14
28
|
/**
|
|
15
|
-
* Get current locale
|
|
29
|
+
* Get current locale from \`window\` (browser context)
|
|
16
30
|
*/
|
|
17
31
|
export const getLocaleInBrowser = () =>
|
|
18
|
-
typeof window !== "undefined" ? window.${GLOBAL_I18N_IDENTIFIER} : "${
|
|
32
|
+
typeof window !== "undefined" ? window.${GLOBAL_I18N_IDENTIFIER} : "${o.defaultLocale}";
|
|
19
33
|
|
|
20
34
|
export default getLocaleInBrowser;
|
|
21
35
|
`
|
|
@@ -23,4 +37,4 @@ export default getLocaleInBrowser;
|
|
|
23
37
|
};
|
|
24
38
|
});
|
|
25
39
|
|
|
26
|
-
export {
|
|
40
|
+
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 };
|
|
@@ -7,12 +7,12 @@ var functions = require('../../compiler/functions.cjs.js');
|
|
|
7
7
|
var helpers = require('../../compiler/helpers.cjs.js');
|
|
8
8
|
var imports = require('../../compiler/imports.cjs.js');
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const interpolateParamsCompiler = ({ start: e, end: r })=>new functions.FunctionsCompiler({
|
|
11
11
|
imports: [],
|
|
12
12
|
comment: {
|
|
13
13
|
internal: true
|
|
14
14
|
},
|
|
15
|
-
name: "
|
|
15
|
+
name: "interpolateParams",
|
|
16
16
|
generics: [
|
|
17
17
|
{
|
|
18
18
|
name: "T",
|
|
@@ -41,13 +41,13 @@ const i18nInterpolateParamsCompiler = ({ start: e, end: r })=>new functions.Func
|
|
|
41
41
|
) : value`,
|
|
42
42
|
implicitReturn: true
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const interpolateParamsDeepCompiler = ()=>new functions.FunctionsCompiler({
|
|
45
45
|
imports: [
|
|
46
46
|
new imports.ImportsCompiler({
|
|
47
|
-
path: "
|
|
47
|
+
path: "interpolateParams",
|
|
48
48
|
named: [
|
|
49
49
|
{
|
|
50
|
-
name: "
|
|
50
|
+
name: "interpolateParams"
|
|
51
51
|
}
|
|
52
52
|
]
|
|
53
53
|
})
|
|
@@ -55,7 +55,7 @@ const i18nInterpolateParamsDeepCompiler = ()=>new functions.FunctionsCompiler({
|
|
|
55
55
|
comment: {
|
|
56
56
|
internal: true
|
|
57
57
|
},
|
|
58
|
-
name: "
|
|
58
|
+
name: "interpolateParamsDeep",
|
|
59
59
|
generics: [
|
|
60
60
|
{
|
|
61
61
|
name: "T",
|
|
@@ -77,29 +77,27 @@ const i18nInterpolateParamsDeepCompiler = ()=>new functions.FunctionsCompiler({
|
|
|
77
77
|
returns: {
|
|
78
78
|
name: "T"
|
|
79
79
|
},
|
|
80
|
-
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] =
|
|
80
|
+
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = interpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = interpolateParamsDeep(value[key], params); } } else { value = interpolateParams(value, params); } return value;'
|
|
81
81
|
});
|
|
82
|
-
var
|
|
82
|
+
var p = createAdapter.createGenerator("js", (a)=>{
|
|
83
83
|
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
84
84
|
return {
|
|
85
|
-
|
|
85
|
+
interpolateParams: {
|
|
86
86
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
87
|
-
name: "
|
|
87
|
+
name: "interpolateParams",
|
|
88
88
|
ext: "ts",
|
|
89
89
|
index: false,
|
|
90
|
-
|
|
91
|
-
content: ()=>i18nInterpolateParamsCompiler(r).$out("ts", {
|
|
90
|
+
content: ()=>interpolateParamsCompiler(r).$out("ts", {
|
|
92
91
|
imports: false,
|
|
93
92
|
exports: "named"
|
|
94
93
|
})
|
|
95
94
|
},
|
|
96
|
-
|
|
95
|
+
interpolateParamsDeep: {
|
|
97
96
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
98
|
-
name: "
|
|
97
|
+
name: "interpolateParamsDeep",
|
|
99
98
|
ext: "ts",
|
|
100
99
|
index: false,
|
|
101
|
-
|
|
102
|
-
content: ()=>i18nInterpolateParamsDeepCompiler().$out("ts", {
|
|
100
|
+
content: ()=>interpolateParamsDeepCompiler().$out("ts", {
|
|
103
101
|
imports: {},
|
|
104
102
|
exports: "named",
|
|
105
103
|
style: "function"
|
|
@@ -108,6 +106,6 @@ var g = createAdapter.createGenerator("js", (a)=>{
|
|
|
108
106
|
};
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
exports.default =
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
109
|
+
exports.default = p;
|
|
110
|
+
exports.interpolateParamsCompiler = interpolateParamsCompiler;
|
|
111
|
+
exports.interpolateParamsDeepCompiler = interpolateParamsDeepCompiler;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { FunctionsCompiler } from "../../compiler/functions";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const interpolateParamsCompiler: ({ start, end, }: {
|
|
3
3
|
start: string;
|
|
4
4
|
end: string;
|
|
5
5
|
}) => FunctionsCompiler;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const interpolateParamsDeepCompiler: () => FunctionsCompiler;
|
|
7
7
|
declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"js">) => {
|
|
8
|
-
|
|
8
|
+
interpolateParams: {
|
|
9
9
|
dir: string;
|
|
10
10
|
name: string;
|
|
11
11
|
ext: "ts";
|
|
12
12
|
index: false;
|
|
13
|
-
disabled: true;
|
|
14
13
|
content: () => string;
|
|
15
14
|
};
|
|
16
|
-
|
|
15
|
+
interpolateParamsDeep: {
|
|
17
16
|
dir: string;
|
|
18
17
|
name: string;
|
|
19
18
|
ext: "ts";
|
|
20
19
|
index: false;
|
|
21
|
-
disabled: true;
|
|
22
20
|
content: () => string;
|
|
23
21
|
};
|
|
24
22
|
};
|
|
@@ -3,12 +3,12 @@ import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
|
3
3
|
import { escapeEachChar } from '../../compiler/helpers.esm.js';
|
|
4
4
|
import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const interpolateParamsCompiler = ({ start: e, end: r })=>new FunctionsCompiler({
|
|
7
7
|
imports: [],
|
|
8
8
|
comment: {
|
|
9
9
|
internal: true
|
|
10
10
|
},
|
|
11
|
-
name: "
|
|
11
|
+
name: "interpolateParams",
|
|
12
12
|
generics: [
|
|
13
13
|
{
|
|
14
14
|
name: "T",
|
|
@@ -37,13 +37,13 @@ const i18nInterpolateParamsCompiler = ({ start: e, end: r })=>new FunctionsCompi
|
|
|
37
37
|
) : value`,
|
|
38
38
|
implicitReturn: true
|
|
39
39
|
});
|
|
40
|
-
const
|
|
40
|
+
const interpolateParamsDeepCompiler = ()=>new FunctionsCompiler({
|
|
41
41
|
imports: [
|
|
42
42
|
new ImportsCompiler({
|
|
43
|
-
path: "
|
|
43
|
+
path: "interpolateParams",
|
|
44
44
|
named: [
|
|
45
45
|
{
|
|
46
|
-
name: "
|
|
46
|
+
name: "interpolateParams"
|
|
47
47
|
}
|
|
48
48
|
]
|
|
49
49
|
})
|
|
@@ -51,7 +51,7 @@ const i18nInterpolateParamsDeepCompiler = ()=>new FunctionsCompiler({
|
|
|
51
51
|
comment: {
|
|
52
52
|
internal: true
|
|
53
53
|
},
|
|
54
|
-
name: "
|
|
54
|
+
name: "interpolateParamsDeep",
|
|
55
55
|
generics: [
|
|
56
56
|
{
|
|
57
57
|
name: "T",
|
|
@@ -73,29 +73,27 @@ const i18nInterpolateParamsDeepCompiler = ()=>new FunctionsCompiler({
|
|
|
73
73
|
returns: {
|
|
74
74
|
name: "T"
|
|
75
75
|
},
|
|
76
|
-
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] =
|
|
76
|
+
body: ()=>'if (Array.isArray(value)) { for (let i = 0; i < value.length; i++) { value[i] = interpolateParamsDeep(value[i], params); } } else if (typeof value === "object") { for (const key in value) { value[key] = interpolateParamsDeep(value[key], params); } } else { value = interpolateParams(value, params); } return value;'
|
|
77
77
|
});
|
|
78
|
-
var
|
|
78
|
+
var p = createGenerator("js", (a)=>{
|
|
79
79
|
let { options: t } = a, { dynamicDelimiters: r } = t.translations.tokens;
|
|
80
80
|
return {
|
|
81
|
-
|
|
81
|
+
interpolateParams: {
|
|
82
82
|
dir: createGenerator.dirs.internal,
|
|
83
|
-
name: "
|
|
83
|
+
name: "interpolateParams",
|
|
84
84
|
ext: "ts",
|
|
85
85
|
index: false,
|
|
86
|
-
|
|
87
|
-
content: ()=>i18nInterpolateParamsCompiler(r).$out("ts", {
|
|
86
|
+
content: ()=>interpolateParamsCompiler(r).$out("ts", {
|
|
88
87
|
imports: false,
|
|
89
88
|
exports: "named"
|
|
90
89
|
})
|
|
91
90
|
},
|
|
92
|
-
|
|
91
|
+
interpolateParamsDeep: {
|
|
93
92
|
dir: createGenerator.dirs.internal,
|
|
94
|
-
name: "
|
|
93
|
+
name: "interpolateParamsDeep",
|
|
95
94
|
ext: "ts",
|
|
96
95
|
index: false,
|
|
97
|
-
|
|
98
|
-
content: ()=>i18nInterpolateParamsDeepCompiler().$out("ts", {
|
|
96
|
+
content: ()=>interpolateParamsDeepCompiler().$out("ts", {
|
|
99
97
|
imports: {},
|
|
100
98
|
exports: "named",
|
|
101
99
|
style: "function"
|
|
@@ -104,4 +102,4 @@ var g = createGenerator("js", (a)=>{
|
|
|
104
102
|
};
|
|
105
103
|
});
|
|
106
104
|
|
|
107
|
-
export {
|
|
105
|
+
export { p as default, interpolateParamsCompiler, interpolateParamsDeepCompiler };
|
|
@@ -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", ({ input: n })=>({
|
|
7
7
|
loadTranslations: {
|
|
8
8
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
9
9
|
name: "loadTranslations",
|
|
@@ -25,4 +25,4 @@ export const loadTranslations = (
|
|
|
25
25
|
}
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
|
-
module.exports =
|
|
28
|
+
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", ({ input: n })=>({
|
|
5
5
|
loadTranslations: {
|
|
6
6
|
dir: createGenerator.dirs.internal,
|
|
7
7
|
name: "loadTranslations",
|
|
@@ -23,4 +23,4 @@ export const loadTranslations = (
|
|
|
23
23
|
}
|
|
24
24
|
}));
|
|
25
25
|
|
|
26
|
-
export {
|
|
26
|
+
export { g as default };
|
|
@@ -2,16 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
let { routes: { dynamicRoutes: a, staticRoutes: o } } =
|
|
5
|
+
var l = createAdapter.createGenerator("js", (e)=>{
|
|
6
|
+
let { routes: { dynamicRoutes: a, staticRoutes: o } } = e;
|
|
7
7
|
return {
|
|
8
|
+
defaultMetadata: {
|
|
9
|
+
dir: createAdapter.createGenerator.dirs.internal,
|
|
10
|
+
name: "defaultMetadata",
|
|
11
|
+
ext: "ts",
|
|
12
|
+
index: false,
|
|
13
|
+
content: ()=>`
|
|
14
|
+
import type { I18nUtils } from "./types";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Default metadata shape for I18n SEO
|
|
18
|
+
*
|
|
19
|
+
* @internal Same as exported from lib \`i18nDefaultMetadata\`
|
|
20
|
+
*/
|
|
21
|
+
export const defaultMetadata: I18nUtils.Metadata = {
|
|
22
|
+
canonical: "",
|
|
23
|
+
alternates: {},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default defaultMetadata;
|
|
27
|
+
|
|
28
|
+
`
|
|
29
|
+
},
|
|
8
30
|
getI18nMetadata: {
|
|
9
31
|
dir: createAdapter.createGenerator.dirs.internal,
|
|
10
32
|
name: "getI18nMetadata",
|
|
11
33
|
ext: "ts",
|
|
12
34
|
index: false,
|
|
13
35
|
content: ()=>`
|
|
14
|
-
import {
|
|
36
|
+
import type { I18nUtils } from "./types";
|
|
37
|
+
import { defaultMetadata } from "./defaultMetadata";
|
|
15
38
|
import { defaultLocale } from "../defaultLocale";
|
|
16
39
|
import { formatUrl } from "../formatUrl";
|
|
17
40
|
import { locales } from "../locales";
|
|
@@ -36,7 +59,7 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
36
59
|
params,` : ""}${a.length ? `
|
|
37
60
|
paramsByLocale,` : ""}
|
|
38
61
|
}: GetI18nMetadataOptions<TRouteId>) {
|
|
39
|
-
if (isErrorRoute(id)) return
|
|
62
|
+
if (isErrorRoute(id)) return defaultMetadata;${a.length && !o.length ? `
|
|
40
63
|
params = params as NonNullable<typeof params>;` : ""}
|
|
41
64
|
const alternates: I18nUtils.Alternates = {
|
|
42
65
|
"x-default": formatUrl(${a.length && o.length ? `
|
|
@@ -64,4 +87,4 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
64
87
|
};
|
|
65
88
|
});
|
|
66
89
|
|
|
67
|
-
module.exports =
|
|
90
|
+
module.exports = l;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: (data: import("../../compiler").I18nCompiler.DataCode<"js">) => {
|
|
2
|
+
defaultMetadata: {
|
|
3
|
+
dir: string;
|
|
4
|
+
name: string;
|
|
5
|
+
ext: "ts";
|
|
6
|
+
index: false;
|
|
7
|
+
content: () => string;
|
|
8
|
+
};
|
|
9
|
+
getI18nMetadata: {
|
|
10
|
+
dir: string;
|
|
11
|
+
name: string;
|
|
12
|
+
ext: "ts";
|
|
13
|
+
index: false;
|
|
14
|
+
content: () => string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
let { routes: { dynamicRoutes: a, staticRoutes: o } } =
|
|
3
|
+
var l = createGenerator("js", (e)=>{
|
|
4
|
+
let { routes: { dynamicRoutes: a, staticRoutes: o } } = e;
|
|
5
5
|
return {
|
|
6
|
+
defaultMetadata: {
|
|
7
|
+
dir: createGenerator.dirs.internal,
|
|
8
|
+
name: "defaultMetadata",
|
|
9
|
+
ext: "ts",
|
|
10
|
+
index: false,
|
|
11
|
+
content: ()=>`
|
|
12
|
+
import type { I18nUtils } from "./types";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default metadata shape for I18n SEO
|
|
16
|
+
*
|
|
17
|
+
* @internal Same as exported from lib \`i18nDefaultMetadata\`
|
|
18
|
+
*/
|
|
19
|
+
export const defaultMetadata: I18nUtils.Metadata = {
|
|
20
|
+
canonical: "",
|
|
21
|
+
alternates: {},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default defaultMetadata;
|
|
25
|
+
|
|
26
|
+
`
|
|
27
|
+
},
|
|
6
28
|
getI18nMetadata: {
|
|
7
29
|
dir: createGenerator.dirs.internal,
|
|
8
30
|
name: "getI18nMetadata",
|
|
9
31
|
ext: "ts",
|
|
10
32
|
index: false,
|
|
11
33
|
content: ()=>`
|
|
12
|
-
import {
|
|
34
|
+
import type { I18nUtils } from "./types";
|
|
35
|
+
import { defaultMetadata } from "./defaultMetadata";
|
|
13
36
|
import { defaultLocale } from "../defaultLocale";
|
|
14
37
|
import { formatUrl } from "../formatUrl";
|
|
15
38
|
import { locales } from "../locales";
|
|
@@ -34,7 +57,7 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
34
57
|
params,` : ""}${a.length ? `
|
|
35
58
|
paramsByLocale,` : ""}
|
|
36
59
|
}: GetI18nMetadataOptions<TRouteId>) {
|
|
37
|
-
if (isErrorRoute(id)) return
|
|
60
|
+
if (isErrorRoute(id)) return defaultMetadata;${a.length && !o.length ? `
|
|
38
61
|
params = params as NonNullable<typeof params>;` : ""}
|
|
39
62
|
const alternates: I18nUtils.Alternates = {
|
|
40
63
|
"x-default": formatUrl(${a.length && o.length ? `
|
|
@@ -62,4 +85,4 @@ export function getI18nMetadata<TRouteId extends I18n.RouteId | RouteIdError>({
|
|
|
62
85
|
};
|
|
63
86
|
});
|
|
64
87
|
|
|
65
|
-
export {
|
|
88
|
+
export { l as default };
|