@koine/i18n 2.0.0-beta.134 → 2.0.0-beta.135
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/formatTo.cjs.js +58 -23
- package/adapter-js/generators/formatTo.d.ts +4 -1
- package/adapter-js/generators/formatTo.esm.js +55 -23
- package/adapter-js/generators/to.cjs.js +14 -16
- package/adapter-js/generators/to.esm.js +14 -16
- package/adapter-js/index.cjs.js +1 -1
- package/adapter-next/generators/next-redirects.cjs.js +4 -3
- package/adapter-next/generators/next-redirects.d.ts +1 -0
- package/adapter-next/generators/next-redirects.esm.js +4 -3
- package/adapter-next/generators/next-rewrites.cjs.js +4 -3
- package/adapter-next/generators/next-rewrites.d.ts +1 -0
- package/adapter-next/generators/next-rewrites.esm.js +4 -3
- package/adapter-next/generators/router-app/I18nLayout.cjs.js +9 -9
- package/adapter-next/generators/router-app/I18nLayout.esm.js +9 -9
- package/adapter-next/generators/router-app/I18nLayoutRoot.cjs.js +4 -4
- package/adapter-next/generators/router-app/I18nLayoutRoot.esm.js +4 -4
- package/adapter-next/generators/router-app/I18nPage.cjs.js +7 -7
- package/adapter-next/generators/router-app/I18nPage.esm.js +7 -7
- package/adapter-next/generators/router-app/i18nServer.cjs.js +5 -5
- package/adapter-next/generators/router-app/i18nServer.esm.js +5 -5
- package/adapter-next/generators/webpack-define.cjs.js +110 -48
- package/adapter-next/generators/webpack-define.d.ts +11 -4
- package/adapter-next/generators/webpack-define.esm.js +112 -50
- package/adapter-next/plugin-shared.cjs.js +18 -32
- package/adapter-next/plugin-shared.esm.js +18 -32
- package/adapter-react/generators/I18nLocaleContext.cjs.js +2 -2
- package/adapter-react/generators/I18nLocaleContext.esm.js +2 -2
- package/adapter-react/generators/getLocale.cjs.js +2 -2
- package/adapter-react/generators/getLocale.esm.js +2 -2
- package/adapter-react/generators/getT.cjs.js +2 -2
- package/adapter-react/generators/getT.esm.js +2 -2
- package/adapter-react/generators/getTo.cjs.js +5 -5
- package/adapter-react/generators/getTo.esm.js +5 -5
- package/package.json +3 -3
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
formatTo: {
|
|
9
|
-
name: "formatTo",
|
|
10
|
-
ext: "ts",
|
|
11
|
-
index: !1,
|
|
12
|
-
content: ()=>`
|
|
13
|
-
import { defaultLocale } from "./defaultLocale";
|
|
5
|
+
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
6
|
+
var functions = require('../../compiler/functions.cjs.js');
|
|
7
|
+
var imports = require('../../compiler/imports.cjs.js');
|
|
14
8
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
const formatTo = ({ hideDefaultLocaleInUrl: e })=>new functions.FunctionsCompiler({
|
|
10
|
+
imports: [
|
|
11
|
+
new imports.ImportsCompiler({
|
|
12
|
+
path: "defaultLocale",
|
|
13
|
+
named: [
|
|
14
|
+
{
|
|
15
|
+
name: "defaultLocale"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
],
|
|
20
|
+
comment: {
|
|
21
|
+
internal: !0
|
|
22
|
+
},
|
|
23
|
+
name: "tInterpolateParams",
|
|
24
|
+
args: [
|
|
25
|
+
{
|
|
26
|
+
name: "locale",
|
|
27
|
+
type: "string | undefined",
|
|
28
|
+
optional: !1
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "pathname",
|
|
32
|
+
type: "string",
|
|
33
|
+
optional: !1
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "params",
|
|
37
|
+
type: "object",
|
|
38
|
+
optional: !0
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
body: ({ format: a })=>`{
|
|
23
42
|
locale = locale || defaultLocale;
|
|
24
43
|
if (process.env["NODE_ENV"] === "development") {
|
|
25
44
|
if (params) {
|
|
26
45
|
pathname.replace(/\\[(.*?)\\]/g, (_, dynamicKey) => {
|
|
27
|
-
const key = dynamicKey as Extract<keyof typeof params, string
|
|
46
|
+
const key = dynamicKey${"ts" === a ? " as Extract<keyof typeof params, string>" : ""};
|
|
28
47
|
|
|
29
48
|
if (!(key in params)) {
|
|
30
49
|
console.warn(
|
|
@@ -57,19 +76,35 @@ export function formatTo(
|
|
|
57
76
|
pathname = pathname.replace(
|
|
58
77
|
/\\[(.*?)\\]/g,
|
|
59
78
|
(_, key) =>
|
|
60
|
-
params[key as keyof typeof params] + "",
|
|
79
|
+
params[key${"ts" === a ? " as keyof typeof params" : ""}] + "",
|
|
61
80
|
)
|
|
62
81
|
}
|
|
63
|
-
${
|
|
82
|
+
${e ? `
|
|
64
83
|
if (locale !== defaultLocale) {
|
|
65
84
|
return "/" + locale + (pathname === "/" ? "" : pathname);
|
|
66
85
|
}
|
|
67
86
|
` : ""}
|
|
68
87
|
return pathname;
|
|
69
|
-
}
|
|
88
|
+
}`
|
|
89
|
+
});
|
|
90
|
+
var a = createAdapter.createGenerator("js", (e)=>{
|
|
91
|
+
let { config: a } = e;
|
|
92
|
+
return {
|
|
93
|
+
formatTo: {
|
|
94
|
+
name: "formatTo",
|
|
95
|
+
ext: "ts",
|
|
96
|
+
index: !1,
|
|
97
|
+
content: ()=>`
|
|
98
|
+
${formatTo(a).$out("ts", {
|
|
99
|
+
imports: {
|
|
100
|
+
folderUp: 0
|
|
101
|
+
},
|
|
102
|
+
exports: "named"
|
|
103
|
+
})}
|
|
70
104
|
`
|
|
71
105
|
}
|
|
72
106
|
};
|
|
73
107
|
});
|
|
74
108
|
|
|
75
|
-
|
|
109
|
+
exports.default = a;
|
|
110
|
+
exports.formatTo = formatTo;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { FunctionsCompiler } from "../../compiler/functions";
|
|
2
|
+
import type { I18nCompiler } from "../../compiler/types";
|
|
3
|
+
export declare const formatTo: ({ hideDefaultLocaleInUrl, }: Pick<I18nCompiler.Config, "hideDefaultLocaleInUrl">) => FunctionsCompiler;
|
|
4
|
+
declare const _default: (data: I18nCompiler.DataCode<"js">) => {
|
|
2
5
|
formatTo: {
|
|
3
6
|
name: string;
|
|
4
7
|
ext: "ts";
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
|
+
import { FunctionsCompiler } from '../../compiler/functions.esm.js';
|
|
3
|
+
import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
const formatTo = ({ hideDefaultLocaleInUrl: e })=>new FunctionsCompiler({
|
|
6
|
+
imports: [
|
|
7
|
+
new ImportsCompiler({
|
|
8
|
+
path: "defaultLocale",
|
|
9
|
+
named: [
|
|
10
|
+
{
|
|
11
|
+
name: "defaultLocale"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
comment: {
|
|
17
|
+
internal: !0
|
|
18
|
+
},
|
|
19
|
+
name: "tInterpolateParams",
|
|
20
|
+
args: [
|
|
21
|
+
{
|
|
22
|
+
name: "locale",
|
|
23
|
+
type: "string | undefined",
|
|
24
|
+
optional: !1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "pathname",
|
|
28
|
+
type: "string",
|
|
29
|
+
optional: !1
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "params",
|
|
33
|
+
type: "object",
|
|
34
|
+
optional: !0
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
body: ({ format: a })=>`{
|
|
21
38
|
locale = locale || defaultLocale;
|
|
22
39
|
if (process.env["NODE_ENV"] === "development") {
|
|
23
40
|
if (params) {
|
|
24
41
|
pathname.replace(/\\[(.*?)\\]/g, (_, dynamicKey) => {
|
|
25
|
-
const key = dynamicKey as Extract<keyof typeof params, string
|
|
42
|
+
const key = dynamicKey${"ts" === a ? " as Extract<keyof typeof params, string>" : ""};
|
|
26
43
|
|
|
27
44
|
if (!(key in params)) {
|
|
28
45
|
console.warn(
|
|
@@ -55,19 +72,34 @@ export function formatTo(
|
|
|
55
72
|
pathname = pathname.replace(
|
|
56
73
|
/\\[(.*?)\\]/g,
|
|
57
74
|
(_, key) =>
|
|
58
|
-
params[key as keyof typeof params] + "",
|
|
75
|
+
params[key${"ts" === a ? " as keyof typeof params" : ""}] + "",
|
|
59
76
|
)
|
|
60
77
|
}
|
|
61
|
-
${
|
|
78
|
+
${e ? `
|
|
62
79
|
if (locale !== defaultLocale) {
|
|
63
80
|
return "/" + locale + (pathname === "/" ? "" : pathname);
|
|
64
81
|
}
|
|
65
82
|
` : ""}
|
|
66
83
|
return pathname;
|
|
67
|
-
}
|
|
84
|
+
}`
|
|
85
|
+
});
|
|
86
|
+
var a = createGenerator("js", (e)=>{
|
|
87
|
+
let { config: a } = e;
|
|
88
|
+
return {
|
|
89
|
+
formatTo: {
|
|
90
|
+
name: "formatTo",
|
|
91
|
+
ext: "ts",
|
|
92
|
+
index: !1,
|
|
93
|
+
content: ()=>`
|
|
94
|
+
${formatTo(a).$out("ts", {
|
|
95
|
+
imports: {
|
|
96
|
+
folderUp: 0
|
|
97
|
+
},
|
|
98
|
+
exports: "named"
|
|
99
|
+
})}
|
|
68
100
|
`
|
|
69
101
|
}
|
|
70
102
|
};
|
|
71
103
|
});
|
|
72
104
|
|
|
73
|
-
export { a as default };
|
|
105
|
+
export { a as default, formatTo };
|
|
@@ -31,10 +31,10 @@ let n = (t, o)=>{
|
|
|
31
31
|
]
|
|
32
32
|
})
|
|
33
33
|
}, s = (e, r)=>{
|
|
34
|
-
let { defaultLocale: s, locales: i,
|
|
35
|
-
for(let r in
|
|
36
|
-
let i = "", { pathnames:
|
|
37
|
-
|
|
34
|
+
let { defaultLocale: s, locales: i, fnPrefix: d } = r, m = [], u = 1 === i.length, p = new Set();
|
|
35
|
+
for(let r in p.add(l.formatTo), p.add(l.types), e.byId){
|
|
36
|
+
let i = "", { pathnames: p, params: c } = e.byId[r], f = `${d}${utils.changeCaseSnake(r)}`, I = `I18n.RouteParams["${r}"]`, g = [];
|
|
37
|
+
c && g.push({
|
|
38
38
|
name: "params",
|
|
39
39
|
type: I,
|
|
40
40
|
optional: !1
|
|
@@ -43,31 +43,29 @@ let n = (t, o)=>{
|
|
|
43
43
|
type: "I18n.Locale",
|
|
44
44
|
optional: !0
|
|
45
45
|
});
|
|
46
|
-
let R =
|
|
47
|
-
utils.isString(
|
|
46
|
+
let R = u ? '""' : "locale", h = c ? ", params" : "";
|
|
47
|
+
utils.isString(p) ? i += `formatTo(${R}, "${p}"${h});` : i += `formatTo(${R}, ${n(s, p)}${h});`, m.push(new functions.FunctionsCompiler({
|
|
48
48
|
imports: [
|
|
49
49
|
l.formatTo,
|
|
50
50
|
l.types
|
|
51
51
|
],
|
|
52
|
-
name:
|
|
52
|
+
name: f,
|
|
53
53
|
args: g,
|
|
54
54
|
body: i
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
57
|
return {
|
|
58
|
-
functions:
|
|
59
|
-
|
|
60
|
-
allImports: c
|
|
58
|
+
functions: m,
|
|
59
|
+
allImports: p
|
|
61
60
|
};
|
|
62
61
|
}, i = ({ config: t, routes: o, options: { routes: { fnsPrefix: e }, adapter: { modularized: n } } })=>{
|
|
63
|
-
let
|
|
62
|
+
let l = e || n ? "$to_" : "", { functions: i, allImports: d } = s(o, {
|
|
64
63
|
defaultLocale: t.defaultLocale,
|
|
65
64
|
locales: t.locales,
|
|
66
|
-
|
|
67
|
-
modularized: n
|
|
65
|
+
fnPrefix: l
|
|
68
66
|
});
|
|
69
|
-
return n ?
|
|
70
|
-
dir:
|
|
67
|
+
return n ? i.reduce((t, o)=>(t[o.name] = {
|
|
68
|
+
dir: l.replace(/_*$/, ""),
|
|
71
69
|
name: o.name,
|
|
72
70
|
ext: "ts",
|
|
73
71
|
index: !0,
|
|
@@ -84,7 +82,7 @@ let n = (t, o)=>{
|
|
|
84
82
|
index: !0,
|
|
85
83
|
content: ()=>"" + (imports.ImportsCompiler.outMany("ts", d, {
|
|
86
84
|
folderUp: 0
|
|
87
|
-
}) + functions.FunctionsCompiler.outMany("ts",
|
|
85
|
+
}) + functions.FunctionsCompiler.outMany("ts", i, {
|
|
88
86
|
imports: !1,
|
|
89
87
|
exports: "named"
|
|
90
88
|
}))
|
|
@@ -29,10 +29,10 @@ let n = (t, o)=>{
|
|
|
29
29
|
]
|
|
30
30
|
})
|
|
31
31
|
}, s = (e, r)=>{
|
|
32
|
-
let { defaultLocale: s, locales: i,
|
|
33
|
-
for(let r in
|
|
34
|
-
let i = "", { pathnames:
|
|
35
|
-
|
|
32
|
+
let { defaultLocale: s, locales: i, fnPrefix: d } = r, m = [], u = 1 === i.length, p = new Set();
|
|
33
|
+
for(let r in p.add(l.formatTo), p.add(l.types), e.byId){
|
|
34
|
+
let i = "", { pathnames: p, params: c } = e.byId[r], f = `${d}${changeCaseSnake(r)}`, I = `I18n.RouteParams["${r}"]`, g = [];
|
|
35
|
+
c && g.push({
|
|
36
36
|
name: "params",
|
|
37
37
|
type: I,
|
|
38
38
|
optional: !1
|
|
@@ -41,31 +41,29 @@ let n = (t, o)=>{
|
|
|
41
41
|
type: "I18n.Locale",
|
|
42
42
|
optional: !0
|
|
43
43
|
});
|
|
44
|
-
let R =
|
|
45
|
-
isString(
|
|
44
|
+
let R = u ? '""' : "locale", h = c ? ", params" : "";
|
|
45
|
+
isString(p) ? i += `formatTo(${R}, "${p}"${h});` : i += `formatTo(${R}, ${n(s, p)}${h});`, m.push(new FunctionsCompiler({
|
|
46
46
|
imports: [
|
|
47
47
|
l.formatTo,
|
|
48
48
|
l.types
|
|
49
49
|
],
|
|
50
|
-
name:
|
|
50
|
+
name: f,
|
|
51
51
|
args: g,
|
|
52
52
|
body: i
|
|
53
53
|
}));
|
|
54
54
|
}
|
|
55
55
|
return {
|
|
56
|
-
functions:
|
|
57
|
-
|
|
58
|
-
allImports: c
|
|
56
|
+
functions: m,
|
|
57
|
+
allImports: p
|
|
59
58
|
};
|
|
60
59
|
}, i = ({ config: t, routes: o, options: { routes: { fnsPrefix: e }, adapter: { modularized: n } } })=>{
|
|
61
|
-
let
|
|
60
|
+
let l = e || n ? "$to_" : "", { functions: i, allImports: d } = s(o, {
|
|
62
61
|
defaultLocale: t.defaultLocale,
|
|
63
62
|
locales: t.locales,
|
|
64
|
-
|
|
65
|
-
modularized: n
|
|
63
|
+
fnPrefix: l
|
|
66
64
|
});
|
|
67
|
-
return n ?
|
|
68
|
-
dir:
|
|
65
|
+
return n ? i.reduce((t, o)=>(t[o.name] = {
|
|
66
|
+
dir: l.replace(/_*$/, ""),
|
|
69
67
|
name: o.name,
|
|
70
68
|
ext: "ts",
|
|
71
69
|
index: !0,
|
|
@@ -82,7 +80,7 @@ let n = (t, o)=>{
|
|
|
82
80
|
index: !0,
|
|
83
81
|
content: ()=>"" + (ImportsCompiler.outMany("ts", d, {
|
|
84
82
|
folderUp: 0
|
|
85
|
-
}) + FunctionsCompiler.outMany("ts",
|
|
83
|
+
}) + FunctionsCompiler.outMany("ts", i, {
|
|
86
84
|
imports: !1,
|
|
87
85
|
exports: "named"
|
|
88
86
|
}))
|
package/adapter-js/index.cjs.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var redirects = require('../redirects.cjs.js');
|
|
5
5
|
|
|
6
|
-
var t = createAdapter.createGenerator("next", (
|
|
7
|
-
let { config:
|
|
6
|
+
var t = createAdapter.createGenerator("next", (r)=>{
|
|
7
|
+
let { config: i, options: o, routes: d } = r, n = JSON.stringify(redirects.generateRedirects(i, o.routes, d.byId), null, 2);
|
|
8
8
|
return {
|
|
9
9
|
nextRedirects: {
|
|
10
|
+
dir: createAdapter.createGenerator.dirs.internal,
|
|
10
11
|
name: "next-redirects",
|
|
11
12
|
ext: "js",
|
|
12
13
|
index: !1,
|
|
@@ -14,7 +15,7 @@ var t = createAdapter.createGenerator("next", (e)=>{
|
|
|
14
15
|
/**
|
|
15
16
|
* @type {import("next/dist/lib/load-custom-routes").Redirect[]}
|
|
16
17
|
*/
|
|
17
|
-
module.exports = ${
|
|
18
|
+
module.exports = ${n}
|
|
18
19
|
`
|
|
19
20
|
}
|
|
20
21
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { generateRedirects } from '../redirects.esm.js';
|
|
3
3
|
|
|
4
|
-
var t = createGenerator("next", (
|
|
5
|
-
let { config:
|
|
4
|
+
var t = createGenerator("next", (r)=>{
|
|
5
|
+
let { config: i, options: o, routes: d } = r, n = JSON.stringify(generateRedirects(i, o.routes, d.byId), null, 2);
|
|
6
6
|
return {
|
|
7
7
|
nextRedirects: {
|
|
8
|
+
dir: createGenerator.dirs.internal,
|
|
8
9
|
name: "next-redirects",
|
|
9
10
|
ext: "js",
|
|
10
11
|
index: !1,
|
|
@@ -12,7 +13,7 @@ var t = createGenerator("next", (e)=>{
|
|
|
12
13
|
/**
|
|
13
14
|
* @type {import("next/dist/lib/load-custom-routes").Redirect[]}
|
|
14
15
|
*/
|
|
15
|
-
module.exports = ${
|
|
16
|
+
module.exports = ${n}
|
|
16
17
|
`
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
var createAdapter = require('../../compiler/createAdapter.cjs.js');
|
|
4
4
|
var rewrites = require('../rewrites.cjs.js');
|
|
5
5
|
|
|
6
|
-
var o = createAdapter.createGenerator("next", (
|
|
7
|
-
let { config:
|
|
6
|
+
var o = createAdapter.createGenerator("next", (r)=>{
|
|
7
|
+
let { config: i, routes: o, options: n } = r, s = JSON.stringify(rewrites.generateRewrites(i, n.routes, o.byId), null, 2);
|
|
8
8
|
return {
|
|
9
9
|
nextRewrites: {
|
|
10
|
+
dir: createAdapter.createGenerator.dirs.internal,
|
|
10
11
|
name: "next-rewrites",
|
|
11
12
|
ext: "js",
|
|
12
13
|
index: !1,
|
|
@@ -14,7 +15,7 @@ var o = createAdapter.createGenerator("next", (e)=>{
|
|
|
14
15
|
/**
|
|
15
16
|
* @type {import("next/dist/lib/load-custom-routes").Rewrite[]}
|
|
16
17
|
*/
|
|
17
|
-
module.exports = ${
|
|
18
|
+
module.exports = ${s}
|
|
18
19
|
`
|
|
19
20
|
}
|
|
20
21
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createGenerator } from '../../compiler/createAdapter.esm.js';
|
|
2
2
|
import { generateRewrites } from '../rewrites.esm.js';
|
|
3
3
|
|
|
4
|
-
var o = createGenerator("next", (
|
|
5
|
-
let { config:
|
|
4
|
+
var o = createGenerator("next", (r)=>{
|
|
5
|
+
let { config: i, routes: o, options: n } = r, s = JSON.stringify(generateRewrites(i, n.routes, o.byId), null, 2);
|
|
6
6
|
return {
|
|
7
7
|
nextRewrites: {
|
|
8
|
+
dir: createGenerator.dirs.internal,
|
|
8
9
|
name: "next-rewrites",
|
|
9
10
|
ext: "js",
|
|
10
11
|
index: !1,
|
|
@@ -12,7 +13,7 @@ var o = createGenerator("next", (e)=>{
|
|
|
12
13
|
/**
|
|
13
14
|
* @type {import("next/dist/lib/load-custom-routes").Rewrite[]}
|
|
14
15
|
*/
|
|
15
|
-
module.exports = ${
|
|
16
|
+
module.exports = ${s}
|
|
16
17
|
`
|
|
17
18
|
}
|
|
18
19
|
};
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
var getI18nDictionaries_inline = require('../../../adapter-js/generators/getI18nDictionaries_inline.cjs.js');
|
|
4
4
|
var createAdapter = require('../../../compiler/createAdapter.cjs.js');
|
|
5
5
|
|
|
6
|
-
var a = createAdapter.createGenerator("next", (
|
|
7
|
-
let { options: { routes: { localeParamName:
|
|
6
|
+
var a = createAdapter.createGenerator("next", (e)=>{
|
|
7
|
+
let { options: { routes: { localeParamName: a } } } = e;
|
|
8
8
|
return {
|
|
9
9
|
I18nLayout: {
|
|
10
|
-
dir:
|
|
10
|
+
dir: createAdapter.createGenerator.dirs.server,
|
|
11
11
|
name: "I18nLayout",
|
|
12
12
|
ext: "tsx",
|
|
13
13
|
index: !1,
|
|
@@ -62,7 +62,7 @@ export const I18nLayout = async ({
|
|
|
62
62
|
*
|
|
63
63
|
* **For App Router only**
|
|
64
64
|
*/
|
|
65
|
-
I18nLayout.locale = (props: any) => props.params.${
|
|
65
|
+
I18nLayout.locale = (props: any) => props.params.${a};
|
|
66
66
|
|
|
67
67
|
type Configurator = {
|
|
68
68
|
/**
|
|
@@ -97,7 +97,7 @@ type Configurator = {
|
|
|
97
97
|
* };
|
|
98
98
|
* });
|
|
99
99
|
*
|
|
100
|
-
* // 2) export the metadata (maybe only in /app/[${
|
|
100
|
+
* // 2) export the metadata (maybe only in /app/[${a}]/layout.tsx)
|
|
101
101
|
*
|
|
102
102
|
* // with a sync function
|
|
103
103
|
* export const generateMetadata = layout.generateMetadata((props) => {
|
|
@@ -111,7 +111,7 @@ type Configurator = {
|
|
|
111
111
|
*
|
|
112
112
|
* // 3) export the default component
|
|
113
113
|
*
|
|
114
|
-
* // 3a) in /app/[${
|
|
114
|
+
* // 3a) in /app/[${a}]/layout.tsx)
|
|
115
115
|
*
|
|
116
116
|
* // only thing to do is to spread the i18nHtmlAttrs prop on the <html> element
|
|
117
117
|
* export default layout.default((props) => {
|
|
@@ -125,7 +125,7 @@ type Configurator = {
|
|
|
125
125
|
* );
|
|
126
126
|
* });
|
|
127
127
|
*
|
|
128
|
-
* // 3b) in /app/[${
|
|
128
|
+
* // 3b) in /app/[${a}]/ ...folders... /layout.tsx)
|
|
129
129
|
*
|
|
130
130
|
* // with a sync function (if you do not need to await)
|
|
131
131
|
* export default layout.default((props) => {
|
|
@@ -150,7 +150,7 @@ export const createI18nLayout = <
|
|
|
150
150
|
| Configurator,
|
|
151
151
|
) => {
|
|
152
152
|
const resolveConfigurator = async (props: I18n.Props<TProps>) => {
|
|
153
|
-
const localeParam = props.params?.${
|
|
153
|
+
const localeParam = props.params?.${a};
|
|
154
154
|
const config = configurator
|
|
155
155
|
? typeof configurator === "function"
|
|
156
156
|
? await configurator(props, localeParam)
|
|
@@ -162,7 +162,7 @@ export const createI18nLayout = <
|
|
|
162
162
|
};
|
|
163
163
|
|
|
164
164
|
return {
|
|
165
|
-
generateStaticParams: () => locales.map((l) => ({ ${
|
|
165
|
+
generateStaticParams: () => locales.map((l) => ({ ${a}: l })),
|
|
166
166
|
generateMetadata: (
|
|
167
167
|
impl: (
|
|
168
168
|
props: TProps & { locale: I18n.Locale },
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getI18nDictionaries_inline } from '../../../adapter-js/generators/getI18nDictionaries_inline.esm.js';
|
|
2
2
|
import { createGenerator } from '../../../compiler/createAdapter.esm.js';
|
|
3
3
|
|
|
4
|
-
var a = createGenerator("next", (
|
|
5
|
-
let { options: { routes: { localeParamName:
|
|
4
|
+
var a = createGenerator("next", (e)=>{
|
|
5
|
+
let { options: { routes: { localeParamName: a } } } = e;
|
|
6
6
|
return {
|
|
7
7
|
I18nLayout: {
|
|
8
|
-
dir:
|
|
8
|
+
dir: createGenerator.dirs.server,
|
|
9
9
|
name: "I18nLayout",
|
|
10
10
|
ext: "tsx",
|
|
11
11
|
index: !1,
|
|
@@ -60,7 +60,7 @@ export const I18nLayout = async ({
|
|
|
60
60
|
*
|
|
61
61
|
* **For App Router only**
|
|
62
62
|
*/
|
|
63
|
-
I18nLayout.locale = (props: any) => props.params.${
|
|
63
|
+
I18nLayout.locale = (props: any) => props.params.${a};
|
|
64
64
|
|
|
65
65
|
type Configurator = {
|
|
66
66
|
/**
|
|
@@ -95,7 +95,7 @@ type Configurator = {
|
|
|
95
95
|
* };
|
|
96
96
|
* });
|
|
97
97
|
*
|
|
98
|
-
* // 2) export the metadata (maybe only in /app/[${
|
|
98
|
+
* // 2) export the metadata (maybe only in /app/[${a}]/layout.tsx)
|
|
99
99
|
*
|
|
100
100
|
* // with a sync function
|
|
101
101
|
* export const generateMetadata = layout.generateMetadata((props) => {
|
|
@@ -109,7 +109,7 @@ type Configurator = {
|
|
|
109
109
|
*
|
|
110
110
|
* // 3) export the default component
|
|
111
111
|
*
|
|
112
|
-
* // 3a) in /app/[${
|
|
112
|
+
* // 3a) in /app/[${a}]/layout.tsx)
|
|
113
113
|
*
|
|
114
114
|
* // only thing to do is to spread the i18nHtmlAttrs prop on the <html> element
|
|
115
115
|
* export default layout.default((props) => {
|
|
@@ -123,7 +123,7 @@ type Configurator = {
|
|
|
123
123
|
* );
|
|
124
124
|
* });
|
|
125
125
|
*
|
|
126
|
-
* // 3b) in /app/[${
|
|
126
|
+
* // 3b) in /app/[${a}]/ ...folders... /layout.tsx)
|
|
127
127
|
*
|
|
128
128
|
* // with a sync function (if you do not need to await)
|
|
129
129
|
* export default layout.default((props) => {
|
|
@@ -148,7 +148,7 @@ export const createI18nLayout = <
|
|
|
148
148
|
| Configurator,
|
|
149
149
|
) => {
|
|
150
150
|
const resolveConfigurator = async (props: I18n.Props<TProps>) => {
|
|
151
|
-
const localeParam = props.params?.${
|
|
151
|
+
const localeParam = props.params?.${a};
|
|
152
152
|
const config = configurator
|
|
153
153
|
? typeof configurator === "function"
|
|
154
154
|
? await configurator(props, localeParam)
|
|
@@ -160,7 +160,7 @@ export const createI18nLayout = <
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
return {
|
|
163
|
-
generateStaticParams: () => locales.map((l) => ({ ${
|
|
163
|
+
generateStaticParams: () => locales.map((l) => ({ ${a}: l })),
|
|
164
164
|
generateMetadata: (
|
|
165
165
|
impl: (
|
|
166
166
|
props: TProps & { locale: I18n.Locale },
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var createAdapter = require('../../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
|
-
var p = createAdapter.createGenerator("next", (
|
|
6
|
-
let { options: { routes: { localeParamName:
|
|
5
|
+
var p = createAdapter.createGenerator("next", (o)=>{
|
|
6
|
+
let { options: { routes: { localeParamName: e } } } = o;
|
|
7
7
|
return {
|
|
8
8
|
I18nLayoutRoot: {
|
|
9
|
-
dir:
|
|
9
|
+
dir: createAdapter.createGenerator.dirs.server,
|
|
10
10
|
name: "I18nLayoutRoot",
|
|
11
11
|
ext: "tsx",
|
|
12
12
|
index: !1,
|
|
@@ -21,7 +21,7 @@ type I18nLayoutRootProps = React.PropsWithChildren;
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Use this _only once_ in the root \`layout.tsx\` at root folder of your app
|
|
24
|
-
* directory (one up than the \`[${
|
|
24
|
+
* directory (one up than the \`[${e}]\` folder).
|
|
25
25
|
*
|
|
26
26
|
* **For App Router only**
|
|
27
27
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createGenerator } from '../../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
|
-
var p = createGenerator("next", (
|
|
4
|
-
let { options: { routes: { localeParamName:
|
|
3
|
+
var p = createGenerator("next", (o)=>{
|
|
4
|
+
let { options: { routes: { localeParamName: e } } } = o;
|
|
5
5
|
return {
|
|
6
6
|
I18nLayoutRoot: {
|
|
7
|
-
dir:
|
|
7
|
+
dir: createGenerator.dirs.server,
|
|
8
8
|
name: "I18nLayoutRoot",
|
|
9
9
|
ext: "tsx",
|
|
10
10
|
index: !1,
|
|
@@ -19,7 +19,7 @@ type I18nLayoutRootProps = React.PropsWithChildren;
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Use this _only once_ in the root \`layout.tsx\` at root folder of your app
|
|
22
|
-
* directory (one up than the \`[${
|
|
22
|
+
* directory (one up than the \`[${e}]\` folder).
|
|
23
23
|
*
|
|
24
24
|
* **For App Router only**
|
|
25
25
|
*/
|