@koine/i18n 2.0.0-beta.138 → 2.0.0-beta.139
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/config.cjs.js +2 -0
- package/adapter-js/generators/config.d.ts +2 -0
- package/adapter-js/generators/config.esm.js +2 -0
- package/adapter-js/generators/formatTo.cjs.js +12 -27
- package/adapter-js/generators/formatTo.d.ts +1 -1
- package/adapter-js/generators/formatTo.esm.js +12 -27
- package/adapter-js/generators/getT.cjs.js +2 -2
- package/adapter-js/generators/getT.esm.js +2 -2
- package/adapter-js/generators/isLocale.cjs.js +2 -2
- package/adapter-js/generators/isLocale.esm.js +2 -2
- package/adapter-js/generators/setLocale.cjs.js +8 -7
- package/adapter-js/generators/setLocale.esm.js +8 -7
- package/adapter-js/generators/t.cjs.js +72 -49
- package/adapter-js/generators/t.d.ts +15 -9
- package/adapter-js/generators/t.esm.js +73 -48
- package/adapter-js/generators/tInterpolateParams.cjs.js +7 -8
- package/adapter-js/generators/tInterpolateParams.esm.js +7 -8
- package/adapter-js/generators/tInterpolateParamsDeep.cjs.js +54 -0
- package/adapter-js/generators/tInterpolateParamsDeep.d.ts +11 -0
- package/adapter-js/generators/tInterpolateParamsDeep.esm.js +49 -0
- package/adapter-js/generators/tPluralise.cjs.js +6 -8
- package/adapter-js/generators/tPluralise.esm.js +6 -8
- package/adapter-js/generators/to.cjs.js +93 -73
- package/adapter-js/generators/to.d.ts +16 -1
- package/adapter-js/generators/to.esm.js +91 -72
- package/adapter-js/generators/types.cjs.js +109 -65
- package/adapter-js/generators/types.d.ts +8 -0
- package/adapter-js/generators/types.esm.js +110 -66
- package/adapter-js/index.cjs.js +2 -0
- package/adapter-js/index.d.ts +34 -6
- package/adapter-js/index.esm.js +9 -7
- package/adapter-next/generators/router-app/I18nLayout.cjs.js +2 -2
- package/adapter-next/generators/router-app/I18nLayout.esm.js +2 -2
- 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 -2
- package/adapter-next/generators/router-app/I18nPage.esm.js +2 -2
- package/adapter-next/generators/router-app/i18nServer.cjs.js +2 -2
- package/adapter-next/generators/router-app/i18nServer.esm.js +2 -2
- package/adapter-next/generators/router-pages/I18nApp.cjs.js +2 -2
- package/adapter-next/generators/router-pages/I18nApp.esm.js +2 -2
- package/adapter-next/generators/webpack-define.cjs.js +144 -83
- package/adapter-next/generators/webpack-define.d.ts +19 -4
- package/adapter-next/generators/webpack-define.esm.js +148 -87
- package/adapter-next/index.cjs.js +4 -0
- package/adapter-next/index.d.ts +70 -10
- package/adapter-next/index.esm.js +11 -7
- package/adapter-next/plugin-shared.cjs.js +9 -9
- package/adapter-next/plugin-shared.esm.js +9 -9
- package/adapter-next-translate/index.d.ts +70 -10
- package/adapter-react/index.d.ts +34 -6
- package/compiler/api.d.ts +1 -6
- package/compiler/code/data-translations.cjs.js +119 -86
- package/compiler/code/data-translations.esm.js +121 -88
- package/compiler/code/generate.cjs.js +9 -7
- package/compiler/code/generate.esm.js +9 -7
- package/compiler/createAdapter.d.ts +1 -6
- package/compiler/functions.cjs.js +30 -13
- package/compiler/functions.d.ts +20 -3
- package/compiler/functions.esm.js +30 -13
- package/compiler/helpers.cjs.js +8 -8
- package/compiler/helpers.d.ts +1 -3
- package/compiler/helpers.esm.js +8 -8
- package/compiler/input/types.d.ts +7 -10
- package/compiler/pluralisation.esm.js +1 -1
- package/compiler/types.d.ts +5 -1
- package/package.json +4 -3
|
@@ -31,6 +31,7 @@ export default defaultLocale;
|
|
|
31
31
|
name: "config",
|
|
32
32
|
ext: "ts",
|
|
33
33
|
index: !0,
|
|
34
|
+
disabled: !0,
|
|
34
35
|
content: ()=>`
|
|
35
36
|
import { locales } from "./locales";
|
|
36
37
|
import { defaultLocale } from "./defaultLocale";
|
|
@@ -50,6 +51,7 @@ export default config;
|
|
|
50
51
|
name: "config.cjs",
|
|
51
52
|
ext: "js",
|
|
52
53
|
index: !1,
|
|
54
|
+
disabled: !0,
|
|
53
55
|
content: ()=>`
|
|
54
56
|
const { locales } = require("./locales");
|
|
55
57
|
const { defaultLocale } = require("./defaultLocale");
|
|
@@ -15,12 +15,14 @@ declare const _default: (data: import("../../compiler-sync").I18nCompiler.DataCo
|
|
|
15
15
|
name: string;
|
|
16
16
|
ext: "ts";
|
|
17
17
|
index: true;
|
|
18
|
+
disabled: true;
|
|
18
19
|
content: () => string;
|
|
19
20
|
};
|
|
20
21
|
configCjs: {
|
|
21
22
|
name: string;
|
|
22
23
|
ext: "js";
|
|
23
24
|
index: false;
|
|
25
|
+
disabled: true;
|
|
24
26
|
content: () => string;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
@@ -29,6 +29,7 @@ export default defaultLocale;
|
|
|
29
29
|
name: "config",
|
|
30
30
|
ext: "ts",
|
|
31
31
|
index: !0,
|
|
32
|
+
disabled: !0,
|
|
32
33
|
content: ()=>`
|
|
33
34
|
import { locales } from "./locales";
|
|
34
35
|
import { defaultLocale } from "./defaultLocale";
|
|
@@ -48,6 +49,7 @@ export default config;
|
|
|
48
49
|
name: "config.cjs",
|
|
49
50
|
ext: "js",
|
|
50
51
|
index: !1,
|
|
52
|
+
disabled: !0,
|
|
51
53
|
content: ()=>`
|
|
52
54
|
const { locales } = require("./locales");
|
|
53
55
|
const { defaultLocale } = require("./defaultLocale");
|
|
@@ -4,19 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
6
|
var functions = require('../../compiler/functions.cjs.js');
|
|
7
|
-
var imports = require('../../compiler/imports.cjs.js');
|
|
8
7
|
|
|
9
|
-
const formatTo = ({
|
|
10
|
-
imports: [
|
|
11
|
-
new imports.ImportsCompiler({
|
|
12
|
-
path: "defaultLocale",
|
|
13
|
-
named: [
|
|
14
|
-
{
|
|
15
|
-
name: "defaultLocale"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
})
|
|
19
|
-
],
|
|
8
|
+
const formatTo = ({ defaultLocale: e, hideDefaultLocaleInUrl: t }, o)=>new functions.FunctionsCompiler({
|
|
9
|
+
imports: [],
|
|
20
10
|
comment: {
|
|
21
11
|
internal: !0
|
|
22
12
|
},
|
|
@@ -38,8 +28,9 @@ const formatTo = ({ hideDefaultLocaleInUrl: e })=>new functions.FunctionsCompile
|
|
|
38
28
|
optional: !0
|
|
39
29
|
}
|
|
40
30
|
],
|
|
41
|
-
body: ({ format: a })=>`
|
|
42
|
-
locale = locale ||
|
|
31
|
+
body: ({ format: a })=>`
|
|
32
|
+
locale = locale || "${e}";
|
|
33
|
+
${o ? `
|
|
43
34
|
if (process.env["NODE_ENV"] === "development") {
|
|
44
35
|
if (params) {
|
|
45
36
|
pathname.replace(/\\[(.*?)\\]/g, (_, dynamicKey) => {
|
|
@@ -71,21 +62,17 @@ const formatTo = ({ hideDefaultLocaleInUrl: e })=>new functions.FunctionsCompile
|
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
64
|
}
|
|
74
|
-
|
|
65
|
+
` : ""}
|
|
75
66
|
if (params) {
|
|
76
|
-
pathname = pathname.replace(
|
|
77
|
-
/\\[(.*?)\\]/g,
|
|
78
|
-
(_, key) =>
|
|
79
|
-
params[key${"ts" === a ? " as keyof typeof params" : ""}] + "",
|
|
80
|
-
)
|
|
67
|
+
pathname = pathname.replace(/\\[(.*?)\\]/g, (_, key) => params[key${"ts" === a ? " as keyof typeof params" : ""}] + "")
|
|
81
68
|
}
|
|
82
|
-
${
|
|
83
|
-
if (locale !==
|
|
69
|
+
${t ? `
|
|
70
|
+
if (locale !== "${e}") {
|
|
84
71
|
return "/" + locale + (pathname === "/" ? "" : pathname);
|
|
85
72
|
}
|
|
86
73
|
` : ""}
|
|
87
74
|
return pathname;
|
|
88
|
-
|
|
75
|
+
`
|
|
89
76
|
});
|
|
90
77
|
var a = createAdapter.createGenerator("js", (e)=>{
|
|
91
78
|
let { config: a } = e;
|
|
@@ -94,14 +81,12 @@ var a = createAdapter.createGenerator("js", (e)=>{
|
|
|
94
81
|
name: "formatTo",
|
|
95
82
|
ext: "ts",
|
|
96
83
|
index: !1,
|
|
97
|
-
content: ()
|
|
98
|
-
${formatTo(a).$out("ts", {
|
|
84
|
+
content: ()=>formatTo(a, !0).$out("ts", {
|
|
99
85
|
imports: {
|
|
100
86
|
folderUp: 0
|
|
101
87
|
},
|
|
102
88
|
exports: "named"
|
|
103
|
-
})
|
|
104
|
-
`
|
|
89
|
+
})
|
|
105
90
|
}
|
|
106
91
|
};
|
|
107
92
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FunctionsCompiler } from "../../compiler/functions";
|
|
2
2
|
import type { I18nCompiler } from "../../compiler/types";
|
|
3
|
-
export declare const formatTo: ({ hideDefaultLocaleInUrl, }: Pick<I18nCompiler.Config, "hideDefaultLocaleInUrl"
|
|
3
|
+
export declare const formatTo: ({ defaultLocale, hideDefaultLocaleInUrl, }: Pick<I18nCompiler.Config, "defaultLocale" | "hideDefaultLocaleInUrl" | "trailingSlash">, devDebug?: boolean) => FunctionsCompiler;
|
|
4
4
|
declare const _default: (data: I18nCompiler.DataCode<"js">) => {
|
|
5
5
|
formatTo: {
|
|
6
6
|
name: string;
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
3
|
-
import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
4
3
|
|
|
5
|
-
const formatTo = ({
|
|
6
|
-
imports: [
|
|
7
|
-
new ImportsCompiler({
|
|
8
|
-
path: "defaultLocale",
|
|
9
|
-
named: [
|
|
10
|
-
{
|
|
11
|
-
name: "defaultLocale"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
})
|
|
15
|
-
],
|
|
4
|
+
const formatTo = ({ defaultLocale: e, hideDefaultLocaleInUrl: t }, o)=>new FunctionsCompiler({
|
|
5
|
+
imports: [],
|
|
16
6
|
comment: {
|
|
17
7
|
internal: !0
|
|
18
8
|
},
|
|
@@ -34,8 +24,9 @@ const formatTo = ({ hideDefaultLocaleInUrl: e })=>new FunctionsCompiler({
|
|
|
34
24
|
optional: !0
|
|
35
25
|
}
|
|
36
26
|
],
|
|
37
|
-
body: ({ format: a })=>`
|
|
38
|
-
locale = locale ||
|
|
27
|
+
body: ({ format: a })=>`
|
|
28
|
+
locale = locale || "${e}";
|
|
29
|
+
${o ? `
|
|
39
30
|
if (process.env["NODE_ENV"] === "development") {
|
|
40
31
|
if (params) {
|
|
41
32
|
pathname.replace(/\\[(.*?)\\]/g, (_, dynamicKey) => {
|
|
@@ -67,21 +58,17 @@ const formatTo = ({ hideDefaultLocaleInUrl: e })=>new FunctionsCompiler({
|
|
|
67
58
|
});
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
|
-
|
|
61
|
+
` : ""}
|
|
71
62
|
if (params) {
|
|
72
|
-
pathname = pathname.replace(
|
|
73
|
-
/\\[(.*?)\\]/g,
|
|
74
|
-
(_, key) =>
|
|
75
|
-
params[key${"ts" === a ? " as keyof typeof params" : ""}] + "",
|
|
76
|
-
)
|
|
63
|
+
pathname = pathname.replace(/\\[(.*?)\\]/g, (_, key) => params[key${"ts" === a ? " as keyof typeof params" : ""}] + "")
|
|
77
64
|
}
|
|
78
|
-
${
|
|
79
|
-
if (locale !==
|
|
65
|
+
${t ? `
|
|
66
|
+
if (locale !== "${e}") {
|
|
80
67
|
return "/" + locale + (pathname === "/" ? "" : pathname);
|
|
81
68
|
}
|
|
82
69
|
` : ""}
|
|
83
70
|
return pathname;
|
|
84
|
-
|
|
71
|
+
`
|
|
85
72
|
});
|
|
86
73
|
var a = createGenerator("js", (e)=>{
|
|
87
74
|
let { config: a } = e;
|
|
@@ -90,14 +77,12 @@ var a = createGenerator("js", (e)=>{
|
|
|
90
77
|
name: "formatTo",
|
|
91
78
|
ext: "ts",
|
|
92
79
|
index: !1,
|
|
93
|
-
content: ()
|
|
94
|
-
${formatTo(a).$out("ts", {
|
|
80
|
+
content: ()=>formatTo(a, !0).$out("ts", {
|
|
95
81
|
imports: {
|
|
96
82
|
folderUp: 0
|
|
97
83
|
},
|
|
98
84
|
exports: "named"
|
|
99
|
-
})
|
|
100
|
-
`
|
|
85
|
+
})
|
|
101
86
|
}
|
|
102
87
|
};
|
|
103
88
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var loadTranslations_inline = require('./loadTranslations_inline.cjs.js');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var p = createAdapter.createGenerator("js", (a)=>({
|
|
7
7
|
getT: {
|
|
8
8
|
name: "getT",
|
|
9
9
|
ext: "ts",
|
|
@@ -35,4 +35,4 @@ export default getT;
|
|
|
35
35
|
}
|
|
36
36
|
}));
|
|
37
37
|
|
|
38
|
-
module.exports =
|
|
38
|
+
module.exports = p;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { loadTranslations_inline } from './loadTranslations_inline.esm.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var p = createGenerator("js", (a)=>({
|
|
5
5
|
getT: {
|
|
6
6
|
name: "getT",
|
|
7
7
|
ext: "ts",
|
|
@@ -33,4 +33,4 @@ export default getT;
|
|
|
33
33
|
}
|
|
34
34
|
}));
|
|
35
35
|
|
|
36
|
-
export {
|
|
36
|
+
export { p as default };
|
|
@@ -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
|
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 = 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
|
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 { i as default };
|
|
@@ -27,11 +27,15 @@ const setGlobalLocale = (e)=>new functions.FunctionsCompiler({
|
|
|
27
27
|
optional: !1
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
|
-
before: ({ format: e })=>"ts" === e ? `
|
|
31
|
-
declare global {
|
|
30
|
+
before: ({ format: e })=>"ts" === e ? `declare global {
|
|
32
31
|
var ${helpers.GLOBAL_I18N_IDENTIFIER}: I18n.Locale;
|
|
33
|
-
}
|
|
34
|
-
|
|
32
|
+
}
|
|
33
|
+
` : "",
|
|
34
|
+
comment: {
|
|
35
|
+
internal: !0
|
|
36
|
+
},
|
|
37
|
+
body: `global.${helpers.GLOBAL_I18N_IDENTIFIER} = value`,
|
|
38
|
+
implicitReturn: !0
|
|
35
39
|
});
|
|
36
40
|
var l = createAdapter.createGenerator("js", (e)=>({
|
|
37
41
|
setGlobalLocale: {
|
|
@@ -40,9 +44,6 @@ var l = createAdapter.createGenerator("js", (e)=>({
|
|
|
40
44
|
ext: "ts",
|
|
41
45
|
index: !1,
|
|
42
46
|
content: ()=>`
|
|
43
|
-
/**
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
47
|
${setGlobalLocale().$out("ts", {
|
|
47
48
|
imports: {
|
|
48
49
|
folderUp: 1
|
|
@@ -23,11 +23,15 @@ const setGlobalLocale = (e)=>new FunctionsCompiler({
|
|
|
23
23
|
optional: !1
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
|
-
before: ({ format: e })=>"ts" === e ? `
|
|
27
|
-
declare global {
|
|
26
|
+
before: ({ format: e })=>"ts" === e ? `declare global {
|
|
28
27
|
var ${GLOBAL_I18N_IDENTIFIER}: I18n.Locale;
|
|
29
|
-
}
|
|
30
|
-
|
|
28
|
+
}
|
|
29
|
+
` : "",
|
|
30
|
+
comment: {
|
|
31
|
+
internal: !0
|
|
32
|
+
},
|
|
33
|
+
body: `global.${GLOBAL_I18N_IDENTIFIER} = value`,
|
|
34
|
+
implicitReturn: !0
|
|
31
35
|
});
|
|
32
36
|
var l = createGenerator("js", (e)=>({
|
|
33
37
|
setGlobalLocale: {
|
|
@@ -36,9 +40,6 @@ var l = createGenerator("js", (e)=>({
|
|
|
36
40
|
ext: "ts",
|
|
37
41
|
index: !1,
|
|
38
42
|
content: ()=>`
|
|
39
|
-
/**
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
43
|
${setGlobalLocale().$out("ts", {
|
|
43
44
|
imports: {
|
|
44
45
|
folderUp: 1
|
|
@@ -8,17 +8,47 @@ var functions = require('../../compiler/functions.cjs.js');
|
|
|
8
8
|
var helpers = require('../../compiler/helpers.cjs.js');
|
|
9
9
|
var imports = require('../../compiler/imports.cjs.js');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
11
|
+
function getTFunctionsPrefix(t) {
|
|
12
|
+
let { translations: { fnsPrefix: e }, modularized: r } = t;
|
|
13
|
+
return e || r ? "$t_" : "";
|
|
14
|
+
}
|
|
15
|
+
function getTFunction(e, r) {
|
|
16
|
+
let { defaultLocale: a, fnPrefix: o } = r, { id: p, values: s, params: i, plural: c, typeValue: f } = e, P = [], d = `${o}${p}`, $ = "count";
|
|
17
|
+
c && (i = i ? {
|
|
18
|
+
...i,
|
|
19
|
+
[$]: "number"
|
|
20
|
+
} : {
|
|
21
|
+
[$]: "number"
|
|
22
|
+
}), i && P.push({
|
|
23
|
+
name: "params",
|
|
24
|
+
type: helpers.compileDataParamsToType(i),
|
|
25
|
+
optional: !1
|
|
26
|
+
}), P.push({
|
|
27
|
+
name: "locale",
|
|
28
|
+
type: "I18n.Locale",
|
|
29
|
+
optional: !0
|
|
30
|
+
});
|
|
31
|
+
let y = [
|
|
32
|
+
u.types
|
|
33
|
+
], h = "";
|
|
34
|
+
return utils.isPrimitive(s) ? h += m(s) : h += function(e, r) {
|
|
35
|
+
let a = "";
|
|
36
|
+
for(let n in r){
|
|
37
|
+
let o = r[n];
|
|
38
|
+
n === e || utils.areEqual(o, r[e]) || (a += `locale === "${n}" ? ${m(o)} : `);
|
|
39
|
+
}
|
|
40
|
+
return a + m(r[e]);
|
|
41
|
+
}(a, s), c && (y.push(u.tPluralise), h = `tPluralise(${h}, params.${$})`), i && (!c || c && !Object.keys(i).every((t)=>t === $)) && ("Primitive" === f ? (y.push(u.tInterpolateParams), h = `tInterpolateParams(${h}, params)`) : ("Array" === f || "Object" === f) && (y.push(u.tInterpolateParamsDeep), h = `tInterpolateParamsDeep(${h}, params)`)), {
|
|
42
|
+
name: d,
|
|
43
|
+
body: h,
|
|
44
|
+
args: P,
|
|
45
|
+
imports: y
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function m(t) {
|
|
49
|
+
return utils.isString(t) || utils.isNumber(t) ? `"${t}"` : utils.isBoolean(t) ? `${t}` : utils.isArray(t) ? JSON.stringify(t) : `(${JSON.stringify(t)})`;
|
|
50
|
+
}
|
|
51
|
+
let u = {
|
|
22
52
|
types: new imports.ImportsCompiler({
|
|
23
53
|
path: "types",
|
|
24
54
|
named: [
|
|
@@ -36,6 +66,14 @@ let i = {
|
|
|
36
66
|
}
|
|
37
67
|
]
|
|
38
68
|
}),
|
|
69
|
+
tInterpolateParamsDeep: new imports.ImportsCompiler({
|
|
70
|
+
path: "tInterpolateParamsDeep",
|
|
71
|
+
named: [
|
|
72
|
+
{
|
|
73
|
+
name: "tInterpolateParamsDeep"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}),
|
|
39
77
|
tPluralise: new imports.ImportsCompiler({
|
|
40
78
|
path: "tPluralise",
|
|
41
79
|
named: [
|
|
@@ -44,48 +82,35 @@ let i = {
|
|
|
44
82
|
}
|
|
45
83
|
]
|
|
46
84
|
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
name: "params",
|
|
58
|
-
type: `{ ${helpers.dataParamsToTsInterfaceBody(d)} }`,
|
|
59
|
-
optional: !1
|
|
60
|
-
}), y.push({
|
|
61
|
-
name: "locale",
|
|
62
|
-
type: "I18n.Locale",
|
|
63
|
-
optional: !0
|
|
64
|
-
});
|
|
65
|
-
let h = "", P = [
|
|
66
|
-
i.types
|
|
67
|
-
];
|
|
68
|
-
utils.isPrimitive(c) ? h += getTranslationValueOutput(c) : h += getTFunctionBodyWithLocales(a, c), $ && (m = !0, h = `tPluralise(${h}, params.count)`), d && (u = !0, h = `tInterpolateParams(${h}, params)`), u && (P.push(i.tInterpolateParams), l.add(i.tInterpolateParams)), m && (P.push(i.tPluralise), l.add(i.tPluralise)), o.push(new functions.FunctionsCompiler({
|
|
69
|
-
imports: P,
|
|
70
|
-
name: f,
|
|
71
|
-
args: y,
|
|
72
|
-
body: h
|
|
85
|
+
}, c = (t, e)=>{
|
|
86
|
+
let r = [], a = new Set();
|
|
87
|
+
for(let n in a.add(u.types), t){
|
|
88
|
+
let { imports: o, name: p, args: l, body: i } = getTFunction(t[n], e);
|
|
89
|
+
o.forEach((t)=>a.add(t)), r.push(new functions.FunctionsCompiler({
|
|
90
|
+
imports: o,
|
|
91
|
+
name: p,
|
|
92
|
+
args: l,
|
|
93
|
+
body: i,
|
|
94
|
+
implicitReturn: !0
|
|
73
95
|
}));
|
|
74
96
|
}
|
|
75
97
|
return {
|
|
76
|
-
functions:
|
|
77
|
-
allImports:
|
|
98
|
+
functions: r,
|
|
99
|
+
allImports: a
|
|
78
100
|
};
|
|
79
101
|
};
|
|
80
102
|
var d = createAdapter.createGenerator("js", (t)=>{
|
|
81
|
-
let { config: { defaultLocale: e }, options: {
|
|
103
|
+
let { config: { defaultLocale: e }, options: { translations: r, adapter: { modularized: a } }, translations: n } = t, o = getTFunctionsPrefix({
|
|
104
|
+
modularized: a,
|
|
105
|
+
translations: r
|
|
106
|
+
}), { functions: p, allImports: l } = c(n, {
|
|
82
107
|
defaultLocale: e,
|
|
83
108
|
fnPrefix: o
|
|
84
109
|
});
|
|
85
|
-
return a ?
|
|
86
|
-
let
|
|
110
|
+
return a ? p.reduce((t, e)=>{
|
|
111
|
+
let r = o.replace(/_*$/, "");
|
|
87
112
|
return t[e.name] = {
|
|
88
|
-
dir:
|
|
113
|
+
dir: r,
|
|
89
114
|
name: e.name,
|
|
90
115
|
ext: "ts",
|
|
91
116
|
index: !0,
|
|
@@ -101,9 +126,9 @@ var d = createAdapter.createGenerator("js", (t)=>{
|
|
|
101
126
|
name: "$t",
|
|
102
127
|
ext: "ts",
|
|
103
128
|
index: !0,
|
|
104
|
-
content: ()=>"" + (imports.ImportsCompiler.outMany("ts",
|
|
129
|
+
content: ()=>"" + (imports.ImportsCompiler.outMany("ts", l, {
|
|
105
130
|
folderUp: 0
|
|
106
|
-
}) + functions.FunctionsCompiler.outMany("ts",
|
|
131
|
+
}) + functions.FunctionsCompiler.outMany("ts", p, {
|
|
107
132
|
imports: !1,
|
|
108
133
|
exports: "named"
|
|
109
134
|
}))
|
|
@@ -111,8 +136,6 @@ var d = createAdapter.createGenerator("js", (t)=>{
|
|
|
111
136
|
};
|
|
112
137
|
});
|
|
113
138
|
|
|
114
|
-
exports.areEqualTranslationsValues = areEqualTranslationsValues;
|
|
115
139
|
exports.default = d;
|
|
116
|
-
exports.
|
|
117
|
-
exports.
|
|
118
|
-
exports.getTranslationValueOutput = getTranslationValueOutput;
|
|
140
|
+
exports.getTFunction = getTFunction;
|
|
141
|
+
exports.getTFunctionsPrefix = getTFunctionsPrefix;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type FunctionsCompilerDataArg } from "../../compiler/functions";
|
|
2
2
|
import { ImportsCompiler } from "../../compiler/imports";
|
|
3
3
|
import type { I18nCompiler } from "../../compiler/types";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
/**
|
|
5
|
+
* If the user does not specifiy a custom prefix by default we prepend `$t_`
|
|
6
|
+
* when `modularized` option is true
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTFunctionsPrefix(options: {
|
|
9
|
+
translations: I18nCompiler.DataCode<"js">["options"]["translations"];
|
|
10
|
+
modularized: I18nCompiler.DataCode<"js">["options"]["adapter"]["modularized"];
|
|
11
|
+
}): "" | "$t_";
|
|
12
|
+
export declare function getTFunction(translation: I18nCompiler.DataTranslation, options: Pick<I18nCompiler.Config, "defaultLocale"> & {
|
|
9
13
|
fnPrefix: string;
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
}): {
|
|
15
|
+
name: string;
|
|
16
|
+
body: string;
|
|
17
|
+
args: FunctionsCompilerDataArg[];
|
|
18
|
+
imports: ImportsCompiler[];
|
|
13
19
|
};
|
|
14
20
|
declare const _default: (data: I18nCompiler.DataCode<"js">) => {
|
|
15
21
|
$t: {
|