@koine/i18n 2.0.0-beta.215 → 2.0.0-beta.217
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/t.cjs.js +20 -19
- package/adapter-js/generators/t.esm.js +20 -19
- package/adapter-js/generators/to.cjs.js +5 -5
- package/adapter-js/generators/to.esm.js +5 -5
- package/adapter-next/generators/router-app/I18nLayout.cjs.js +14 -14
- package/adapter-next/generators/router-app/I18nLayout.esm.js +14 -14
- package/adapter-next/generators/router-app/I18nLayoutRoot.cjs.js +6 -6
- package/adapter-next/generators/router-app/I18nLayoutRoot.esm.js +6 -6
- package/adapter-next/generators/router-app/I18nPage.cjs.js +11 -11
- package/adapter-next/generators/router-app/I18nPage.esm.js +11 -11
- package/adapter-next/generators/router-app/i18nServer.cjs.js +25 -25
- package/adapter-next/generators/router-app/i18nServer.esm.js +25 -25
- package/adapter-next/generators/router-pages/I18nApp.cjs.js +13 -10
- package/adapter-next/generators/router-pages/I18nApp.esm.js +13 -10
- package/adapter-next/generators/router-pages/I18nDocument.cjs.js +8 -5
- package/adapter-next/generators/router-pages/I18nDocument.esm.js +8 -5
- package/adapter-next/generators/router-pages/I18nHead.cjs.js +7 -4
- package/adapter-next/generators/router-pages/I18nHead.esm.js +7 -4
- package/adapter-next/generators/router-pages/I18nSetter.cjs.js +10 -7
- package/adapter-next/generators/router-pages/I18nSetter.esm.js +10 -7
- package/adapter-next/generators/router-pages/i18nGet.cjs.js +15 -15
- package/adapter-next/generators/router-pages/i18nGet.esm.js +15 -15
- package/adapter-react/generators/I18nEffects.cjs.js +6 -3
- package/adapter-react/generators/I18nEffects.esm.js +6 -3
- package/adapter-react/generators/I18nHeadTags.cjs.js +7 -4
- package/adapter-react/generators/I18nHeadTags.esm.js +7 -4
- package/adapter-react/generators/I18nMetadata.cjs.js +9 -6
- package/adapter-react/generators/I18nMetadata.esm.js +9 -6
- package/adapter-react/generators/I18nRoute.cjs.js +10 -7
- package/adapter-react/generators/I18nRoute.esm.js +10 -7
- package/adapter-react/generators/I18nTranslate.cjs.js +18 -15
- package/adapter-react/generators/I18nTranslate.esm.js +18 -15
- package/adapter-react/generators/Trans.cjs.js +8 -8
- package/adapter-react/generators/Trans.esm.js +8 -8
- package/adapter-react/generators/getT.cjs.js +10 -7
- package/adapter-react/generators/getT.esm.js +10 -7
- package/adapter-react/generators/getTo.cjs.js +8 -8
- package/adapter-react/generators/getTo.esm.js +8 -8
- package/adapter-react/generators/locale.cjs.js +9 -6
- package/adapter-react/generators/locale.esm.js +9 -6
- package/adapter-react/generators/useRouteId.cjs.js +6 -3
- package/adapter-react/generators/useRouteId.esm.js +6 -3
- package/adapter-react/generators/useTo.cjs.js +5 -5
- package/adapter-react/generators/useTo.esm.js +5 -5
- package/adapter-react/generators/useToSpa.cjs.js +8 -5
- package/adapter-react/generators/useToSpa.esm.js +8 -5
- package/package.json +4 -4
|
@@ -12,24 +12,24 @@ var types = require('./types.cjs.js');
|
|
|
12
12
|
|
|
13
13
|
let c = "count";
|
|
14
14
|
function getTFunction(t, r) {
|
|
15
|
-
let { params: n, plural: o } = t, { single: l } = r, { body:
|
|
16
|
-
let { values: n, params: o, plural: l, typeValue:
|
|
17
|
-
|
|
15
|
+
let { params: n, plural: o } = t, { single: l } = r, { body: s, imports: m } = function(t, r) {
|
|
16
|
+
let { values: n, params: o, plural: l, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = r, y = !u && !p, h = [
|
|
17
|
+
d.types
|
|
18
18
|
];
|
|
19
|
-
return l && h.push(
|
|
19
|
+
return l && h.push(d.pluralise), o && ("Primitive" === s ? h.push(d.interpolateParams) : ("Array" === s || "Object" === s) && h.push(d.interpolateParamsDeep)), {
|
|
20
20
|
imports: h,
|
|
21
21
|
body: (t)=>{
|
|
22
22
|
let r = y ? "locale = locale || globalThis." + constants.GLOBAL_I18N_IDENTIFIER + "; " : "";
|
|
23
23
|
r += "return ";
|
|
24
|
-
let
|
|
25
|
-
return utils.isPrimitive(n) ?
|
|
24
|
+
let p = "";
|
|
25
|
+
return utils.isPrimitive(n) ? p += f(n, t) : p += function(t, r, n, a) {
|
|
26
26
|
let o = "";
|
|
27
27
|
if (n) for(let n in r){
|
|
28
28
|
let i = r[n];
|
|
29
|
-
n === t || utils.areEqual(i, r[t]) || (o += `locale === "${n}" ? ${
|
|
29
|
+
n === t || utils.areEqual(i, r[t]) || (o += `locale === "${n}" ? ${f(i, a)} : `);
|
|
30
30
|
}
|
|
31
|
-
return o +
|
|
32
|
-
}(m, n, y, t), l && (
|
|
31
|
+
return o + f(r[t], a);
|
|
32
|
+
}(m, n, y, t), l && (p = `pluralise(${p}, params.${c}${y ? ", locale" : ""})`), o && ("Primitive" === s ? p = `interpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `interpolateParamsDeep(${p}, params)`)), r + p;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
}(t, r), u = [], y = n ? o ? {
|
|
@@ -50,16 +50,16 @@ function getTFunction(t, r) {
|
|
|
50
50
|
description: "Use this to override the current locale" + (l ? " (in case you add other locales to your project)" : ""),
|
|
51
51
|
defaultComment: "current locale"
|
|
52
52
|
}), {
|
|
53
|
-
body:
|
|
53
|
+
body: s,
|
|
54
54
|
args: u,
|
|
55
55
|
imports: m
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function f(e, { format: a }) {
|
|
59
59
|
let i = "ts" === a ? " as const" : "";
|
|
60
|
-
return utils.isString(e)
|
|
60
|
+
return utils.isString(e) ? `${JSON.stringify(e)}${i}` : utils.isNumber(e) ? `${e}${i}` : utils.isBoolean(e) ? `${e}` : utils.isArray(e) ? JSON.stringify(e) + i : `(${JSON.stringify(e)}${i})`;
|
|
61
61
|
}
|
|
62
|
-
let
|
|
62
|
+
let d = {
|
|
63
63
|
types: types.getImportTypes(),
|
|
64
64
|
interpolateParams: new imports.ImportsCompiler({
|
|
65
65
|
path: "internal/interpolateParams",
|
|
@@ -87,15 +87,16 @@ let f = {
|
|
|
87
87
|
})
|
|
88
88
|
};
|
|
89
89
|
var y = createAdapter.createGenerator("js", (e)=>{
|
|
90
|
-
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports:
|
|
90
|
+
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports: p } = ((e, t)=>{
|
|
91
91
|
let r = [], n = new Set();
|
|
92
|
-
for(let a in n.add(
|
|
93
|
-
let o = e[a], { imports: i, args: l, body:
|
|
94
|
-
|
|
92
|
+
for(let a in n.add(d.types), e){
|
|
93
|
+
let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
|
|
94
|
+
for (let e of i)n.add(e);
|
|
95
|
+
r.push(new functions.FunctionsCompiler({
|
|
95
96
|
imports: i,
|
|
96
97
|
name: o.fnName,
|
|
97
98
|
args: l,
|
|
98
|
-
body:
|
|
99
|
+
body: p,
|
|
99
100
|
comment: {
|
|
100
101
|
tags: [
|
|
101
102
|
{
|
|
@@ -133,7 +134,7 @@ var y = createAdapter.createGenerator("js", (e)=>{
|
|
|
133
134
|
index: false,
|
|
134
135
|
content: ()=>{
|
|
135
136
|
let e = "";
|
|
136
|
-
return e += imports.ImportsCompiler.outMany("ts",
|
|
137
|
+
return e += imports.ImportsCompiler.outMany("ts", p, {
|
|
137
138
|
folderUp: 0
|
|
138
139
|
}), e += functions.FunctionsCompiler.outMany("ts", l, {
|
|
139
140
|
imports: false,
|
|
@@ -8,24 +8,24 @@ import { getImportTypes } from './types.esm.js';
|
|
|
8
8
|
|
|
9
9
|
let c = "count";
|
|
10
10
|
function getTFunction(t, r) {
|
|
11
|
-
let { params: n, plural: o } = t, { single: l } = r, { body:
|
|
12
|
-
let { values: n, params: o, plural: l, typeValue:
|
|
13
|
-
|
|
11
|
+
let { params: n, plural: o } = t, { single: l } = r, { body: s, imports: m } = function(t, r) {
|
|
12
|
+
let { values: n, params: o, plural: l, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = r, y = !u && !p, h = [
|
|
13
|
+
d.types
|
|
14
14
|
];
|
|
15
|
-
return l && h.push(
|
|
15
|
+
return l && h.push(d.pluralise), o && ("Primitive" === s ? h.push(d.interpolateParams) : ("Array" === s || "Object" === s) && h.push(d.interpolateParamsDeep)), {
|
|
16
16
|
imports: h,
|
|
17
17
|
body: (t)=>{
|
|
18
18
|
let r = y ? "locale = locale || globalThis." + GLOBAL_I18N_IDENTIFIER + "; " : "";
|
|
19
19
|
r += "return ";
|
|
20
|
-
let
|
|
21
|
-
return isPrimitive(n) ?
|
|
20
|
+
let p = "";
|
|
21
|
+
return isPrimitive(n) ? p += f(n, t) : p += function(t, r, n, a) {
|
|
22
22
|
let o = "";
|
|
23
23
|
if (n) for(let n in r){
|
|
24
24
|
let i = r[n];
|
|
25
|
-
n === t || areEqual(i, r[t]) || (o += `locale === "${n}" ? ${
|
|
25
|
+
n === t || areEqual(i, r[t]) || (o += `locale === "${n}" ? ${f(i, a)} : `);
|
|
26
26
|
}
|
|
27
|
-
return o +
|
|
28
|
-
}(m, n, y, t), l && (
|
|
27
|
+
return o + f(r[t], a);
|
|
28
|
+
}(m, n, y, t), l && (p = `pluralise(${p}, params.${c}${y ? ", locale" : ""})`), o && ("Primitive" === s ? p = `interpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `interpolateParamsDeep(${p}, params)`)), r + p;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
}(t, r), u = [], y = n ? o ? {
|
|
@@ -46,16 +46,16 @@ function getTFunction(t, r) {
|
|
|
46
46
|
description: "Use this to override the current locale" + (l ? " (in case you add other locales to your project)" : ""),
|
|
47
47
|
defaultComment: "current locale"
|
|
48
48
|
}), {
|
|
49
|
-
body:
|
|
49
|
+
body: s,
|
|
50
50
|
args: u,
|
|
51
51
|
imports: m
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function f(e, { format: a }) {
|
|
55
55
|
let i = "ts" === a ? " as const" : "";
|
|
56
|
-
return isString(e)
|
|
56
|
+
return isString(e) ? `${JSON.stringify(e)}${i}` : isNumber(e) ? `${e}${i}` : isBoolean(e) ? `${e}` : isArray(e) ? JSON.stringify(e) + i : `(${JSON.stringify(e)}${i})`;
|
|
57
57
|
}
|
|
58
|
-
let
|
|
58
|
+
let d = {
|
|
59
59
|
types: getImportTypes(),
|
|
60
60
|
interpolateParams: new ImportsCompiler({
|
|
61
61
|
path: "internal/interpolateParams",
|
|
@@ -83,15 +83,16 @@ let f = {
|
|
|
83
83
|
})
|
|
84
84
|
};
|
|
85
85
|
var y = createGenerator("js", (e)=>{
|
|
86
|
-
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports:
|
|
86
|
+
let { config: t, options: { translations: r, adapter: { options: { modularize: n } } }, translations: a } = e, o = e.options.write?.addImportExtensions ? ".js" : "", { dir: i } = r.functions, { functions: l, allImports: p } = ((e, t)=>{
|
|
87
87
|
let r = [], n = new Set();
|
|
88
|
-
for(let a in n.add(
|
|
89
|
-
let o = e[a], { imports: i, args: l, body:
|
|
90
|
-
|
|
88
|
+
for(let a in n.add(d.types), e){
|
|
89
|
+
let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
|
|
90
|
+
for (let e of i)n.add(e);
|
|
91
|
+
r.push(new FunctionsCompiler({
|
|
91
92
|
imports: i,
|
|
92
93
|
name: o.fnName,
|
|
93
94
|
args: l,
|
|
94
|
-
body:
|
|
95
|
+
body: p,
|
|
95
96
|
comment: {
|
|
96
97
|
tags: [
|
|
97
98
|
{
|
|
@@ -129,7 +130,7 @@ var y = createGenerator("js", (e)=>{
|
|
|
129
130
|
index: false,
|
|
130
131
|
content: ()=>{
|
|
131
132
|
let e = "";
|
|
132
|
-
return e += ImportsCompiler.outMany("ts",
|
|
133
|
+
return e += ImportsCompiler.outMany("ts", p, {
|
|
133
134
|
folderUp: 0
|
|
134
135
|
}), e += FunctionsCompiler.outMany("ts", l, {
|
|
135
136
|
imports: false,
|
|
@@ -11,19 +11,19 @@ var types = require('./types.cjs.js');
|
|
|
11
11
|
|
|
12
12
|
function getToFunction(o, e) {
|
|
13
13
|
let { id: r, params: n } = o, s = function(o, e) {
|
|
14
|
-
let { params: r, pathnames: n
|
|
14
|
+
let { params: r, pathnames: n } = o, { defaultLocale: s, single: l } = e, i = !l, u = l ? '""' : "locale", d = r ? ", params" : "";
|
|
15
15
|
return (o)=>{
|
|
16
|
-
let e =
|
|
16
|
+
let e = i ? `locale = locale || globalThis.${constants.GLOBAL_I18N_IDENTIFIER}; ` : "";
|
|
17
17
|
e += "return ";
|
|
18
18
|
let r = "";
|
|
19
|
-
return utils.isString(n) ? r += `formatTo(${
|
|
19
|
+
return utils.isString(n) ? r += `formatTo(${u}, "${n}"${d})` : r += `formatTo(${u}, ${function(t, o, { format: e }) {
|
|
20
20
|
let a = "ts" === e ? " as const" : "", r = "";
|
|
21
21
|
for(let e in o){
|
|
22
22
|
let n = o[e];
|
|
23
23
|
e !== t && n !== o[t] && (r += `locale === "${e}" ? "${n}"${a} : `);
|
|
24
24
|
}
|
|
25
|
-
return r +
|
|
26
|
-
}(
|
|
25
|
+
return r + `"${o[t]}"${a}`;
|
|
26
|
+
}(s, n, o)}${d})`, e + r;
|
|
27
27
|
};
|
|
28
28
|
}(o, e), l = [];
|
|
29
29
|
return n && l.push({
|
|
@@ -7,19 +7,19 @@ import { getImportTypes } from './types.esm.js';
|
|
|
7
7
|
|
|
8
8
|
function getToFunction(o, e) {
|
|
9
9
|
let { id: r, params: n } = o, s = function(o, e) {
|
|
10
|
-
let { params: r, pathnames: n
|
|
10
|
+
let { params: r, pathnames: n } = o, { defaultLocale: s, single: l } = e, i = !l, u = l ? '""' : "locale", d = r ? ", params" : "";
|
|
11
11
|
return (o)=>{
|
|
12
|
-
let e =
|
|
12
|
+
let e = i ? `locale = locale || globalThis.${GLOBAL_I18N_IDENTIFIER}; ` : "";
|
|
13
13
|
e += "return ";
|
|
14
14
|
let r = "";
|
|
15
|
-
return isString(n) ? r += `formatTo(${
|
|
15
|
+
return isString(n) ? r += `formatTo(${u}, "${n}"${d})` : r += `formatTo(${u}, ${function(t, o, { format: e }) {
|
|
16
16
|
let a = "ts" === e ? " as const" : "", r = "";
|
|
17
17
|
for(let e in o){
|
|
18
18
|
let n = o[e];
|
|
19
19
|
e !== t && n !== o[t] && (r += `locale === "${e}" ? "${n}"${a} : `);
|
|
20
20
|
}
|
|
21
|
-
return r +
|
|
22
|
-
}(
|
|
21
|
+
return r + `"${o[t]}"${a}`;
|
|
22
|
+
}(s, n, o)}${d})`, e + r;
|
|
23
23
|
};
|
|
24
24
|
}(o, e), l = [];
|
|
25
25
|
return n && l.push({
|
|
@@ -4,7 +4,7 @@ var createAdapter = require('../../../compiler/createAdapter.cjs.js');
|
|
|
4
4
|
var constants = require('../../../compiler/constants.cjs.js');
|
|
5
5
|
|
|
6
6
|
var p = createAdapter.createGenerator("next", (a)=>{
|
|
7
|
-
let { options: { routes: { localeParamName:
|
|
7
|
+
let e = a.options.write?.addImportExtensions ? ".js" : "", { options: { routes: { localeParamName: r } } } = a;
|
|
8
8
|
return {
|
|
9
9
|
I18nLayout: {
|
|
10
10
|
dir: createAdapter.createGenerator.dirs.server,
|
|
@@ -14,19 +14,19 @@ var p = createAdapter.createGenerator("next", (a)=>{
|
|
|
14
14
|
content: ()=>`
|
|
15
15
|
import React from "react";
|
|
16
16
|
import type { Metadata } from "next/types";
|
|
17
|
-
import { getI18nDictionaries } from "../internal/getI18nDictionaries";
|
|
18
|
-
import { rtlLocales } from "../internal/rtlLocales";
|
|
19
|
-
import { I18nTranslateProvider } from "../I18nTranslateProvider";
|
|
20
|
-
import { locales } from "../locales";
|
|
21
|
-
import type { I18n } from "../types";
|
|
22
|
-
import { I18nLayoutRoot } from "./I18nLayoutRoot";
|
|
17
|
+
import { getI18nDictionaries } from "../internal/getI18nDictionaries${e}";
|
|
18
|
+
import { rtlLocales } from "../internal/rtlLocales${e}";
|
|
19
|
+
import { I18nTranslateProvider } from "../I18nTranslateProvider${e}";
|
|
20
|
+
import { locales } from "../locales${e}";
|
|
21
|
+
import type { I18n } from "../types${e}";
|
|
22
|
+
import { I18nLayoutRoot } from "./I18nLayoutRoot${e}";
|
|
23
23
|
import {
|
|
24
24
|
type NextProps,
|
|
25
25
|
type I18nNextPropsLayout,
|
|
26
26
|
type I18nProps,
|
|
27
27
|
type I18nServerConfigurator,
|
|
28
28
|
resolveConfigurator,
|
|
29
|
-
} from "./i18nServerHelpers";
|
|
29
|
+
} from "./i18nServerHelpers${e}";
|
|
30
30
|
|
|
31
31
|
type Config = {
|
|
32
32
|
/**
|
|
@@ -83,13 +83,13 @@ export type I18nLayoutCreatedProps<
|
|
|
83
83
|
React.PropsWithChildren<{
|
|
84
84
|
/**
|
|
85
85
|
* Render this in
|
|
86
|
-
* - \`/app/[${
|
|
86
|
+
* - \`/app/[${r}]/layout.tsx\`
|
|
87
87
|
* - \`/app/not-found.tsx\`
|
|
88
88
|
*/
|
|
89
89
|
I18nScript: React.ReactNode;
|
|
90
90
|
/**
|
|
91
91
|
* Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
|
|
92
|
-
* - \`app/[${
|
|
92
|
+
* - \`app/[${r}]/layout.tsx\`
|
|
93
93
|
* - \`app/not-found.tsx\`
|
|
94
94
|
*/
|
|
95
95
|
i18nHtmlAttrs: Pick<
|
|
@@ -119,7 +119,7 @@ export type I18nLayoutCreatedProps<
|
|
|
119
119
|
* };
|
|
120
120
|
* });
|
|
121
121
|
*
|
|
122
|
-
* // 2) export the metadata (maybe only in /app/[${
|
|
122
|
+
* // 2) export the metadata (maybe only in /app/[${r}]/layout.tsx)
|
|
123
123
|
*
|
|
124
124
|
* // with a sync function
|
|
125
125
|
* export const generateMetadata = layout.generateMetadata((props) => {
|
|
@@ -133,7 +133,7 @@ export type I18nLayoutCreatedProps<
|
|
|
133
133
|
*
|
|
134
134
|
* // 3) export the default component
|
|
135
135
|
*
|
|
136
|
-
* // 3a) in /app/[${
|
|
136
|
+
* // 3a) in /app/[${r}]/layout.tsx and /app/not-found.tsx
|
|
137
137
|
*
|
|
138
138
|
* // first spread the i18nHtmlAttrs prop on the <html> element, then render
|
|
139
139
|
* // the {I18nScript} node in the <body>
|
|
@@ -151,7 +151,7 @@ export type I18nLayoutCreatedProps<
|
|
|
151
151
|
* );
|
|
152
152
|
* });
|
|
153
153
|
*
|
|
154
|
-
* // 3b) in /app/[${
|
|
154
|
+
* // 3b) in /app/[${r}]/ ...folders... /layout.tsx)
|
|
155
155
|
*
|
|
156
156
|
* // with a sync function (if you do not need to await)
|
|
157
157
|
* export default layout.default((props) => {
|
|
@@ -170,7 +170,7 @@ export const createI18nLayout =
|
|
|
170
170
|
<TConfigurator extends I18nServerConfigurator<Config, TProps>>(
|
|
171
171
|
configurator?: TConfigurator,
|
|
172
172
|
) => ({
|
|
173
|
-
generateStaticParams: () => locales.map((l) => ({ ${
|
|
173
|
+
generateStaticParams: () => locales.map((l) => ({ ${r}: l })),
|
|
174
174
|
generateMetadata: (
|
|
175
175
|
impl: (
|
|
176
176
|
props: I18nProps<TProps, Config, TConfigurator>,
|
|
@@ -2,7 +2,7 @@ import { createGenerator } from '../../../compiler/createAdapter.esm.js';
|
|
|
2
2
|
import { GLOBAL_I18N_IDENTIFIER } from '../../../compiler/constants.esm.js';
|
|
3
3
|
|
|
4
4
|
var p = createGenerator("next", (a)=>{
|
|
5
|
-
let { options: { routes: { localeParamName:
|
|
5
|
+
let e = a.options.write?.addImportExtensions ? ".js" : "", { options: { routes: { localeParamName: r } } } = a;
|
|
6
6
|
return {
|
|
7
7
|
I18nLayout: {
|
|
8
8
|
dir: createGenerator.dirs.server,
|
|
@@ -12,19 +12,19 @@ var p = createGenerator("next", (a)=>{
|
|
|
12
12
|
content: ()=>`
|
|
13
13
|
import React from "react";
|
|
14
14
|
import type { Metadata } from "next/types";
|
|
15
|
-
import { getI18nDictionaries } from "../internal/getI18nDictionaries";
|
|
16
|
-
import { rtlLocales } from "../internal/rtlLocales";
|
|
17
|
-
import { I18nTranslateProvider } from "../I18nTranslateProvider";
|
|
18
|
-
import { locales } from "../locales";
|
|
19
|
-
import type { I18n } from "../types";
|
|
20
|
-
import { I18nLayoutRoot } from "./I18nLayoutRoot";
|
|
15
|
+
import { getI18nDictionaries } from "../internal/getI18nDictionaries${e}";
|
|
16
|
+
import { rtlLocales } from "../internal/rtlLocales${e}";
|
|
17
|
+
import { I18nTranslateProvider } from "../I18nTranslateProvider${e}";
|
|
18
|
+
import { locales } from "../locales${e}";
|
|
19
|
+
import type { I18n } from "../types${e}";
|
|
20
|
+
import { I18nLayoutRoot } from "./I18nLayoutRoot${e}";
|
|
21
21
|
import {
|
|
22
22
|
type NextProps,
|
|
23
23
|
type I18nNextPropsLayout,
|
|
24
24
|
type I18nProps,
|
|
25
25
|
type I18nServerConfigurator,
|
|
26
26
|
resolveConfigurator,
|
|
27
|
-
} from "./i18nServerHelpers";
|
|
27
|
+
} from "./i18nServerHelpers${e}";
|
|
28
28
|
|
|
29
29
|
type Config = {
|
|
30
30
|
/**
|
|
@@ -81,13 +81,13 @@ export type I18nLayoutCreatedProps<
|
|
|
81
81
|
React.PropsWithChildren<{
|
|
82
82
|
/**
|
|
83
83
|
* Render this in
|
|
84
|
-
* - \`/app/[${
|
|
84
|
+
* - \`/app/[${r}]/layout.tsx\`
|
|
85
85
|
* - \`/app/not-found.tsx\`
|
|
86
86
|
*/
|
|
87
87
|
I18nScript: React.ReactNode;
|
|
88
88
|
/**
|
|
89
89
|
* Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
|
|
90
|
-
* - \`app/[${
|
|
90
|
+
* - \`app/[${r}]/layout.tsx\`
|
|
91
91
|
* - \`app/not-found.tsx\`
|
|
92
92
|
*/
|
|
93
93
|
i18nHtmlAttrs: Pick<
|
|
@@ -117,7 +117,7 @@ export type I18nLayoutCreatedProps<
|
|
|
117
117
|
* };
|
|
118
118
|
* });
|
|
119
119
|
*
|
|
120
|
-
* // 2) export the metadata (maybe only in /app/[${
|
|
120
|
+
* // 2) export the metadata (maybe only in /app/[${r}]/layout.tsx)
|
|
121
121
|
*
|
|
122
122
|
* // with a sync function
|
|
123
123
|
* export const generateMetadata = layout.generateMetadata((props) => {
|
|
@@ -131,7 +131,7 @@ export type I18nLayoutCreatedProps<
|
|
|
131
131
|
*
|
|
132
132
|
* // 3) export the default component
|
|
133
133
|
*
|
|
134
|
-
* // 3a) in /app/[${
|
|
134
|
+
* // 3a) in /app/[${r}]/layout.tsx and /app/not-found.tsx
|
|
135
135
|
*
|
|
136
136
|
* // first spread the i18nHtmlAttrs prop on the <html> element, then render
|
|
137
137
|
* // the {I18nScript} node in the <body>
|
|
@@ -149,7 +149,7 @@ export type I18nLayoutCreatedProps<
|
|
|
149
149
|
* );
|
|
150
150
|
* });
|
|
151
151
|
*
|
|
152
|
-
* // 3b) in /app/[${
|
|
152
|
+
* // 3b) in /app/[${r}]/ ...folders... /layout.tsx)
|
|
153
153
|
*
|
|
154
154
|
* // with a sync function (if you do not need to await)
|
|
155
155
|
* export default layout.default((props) => {
|
|
@@ -168,7 +168,7 @@ export const createI18nLayout =
|
|
|
168
168
|
<TConfigurator extends I18nServerConfigurator<Config, TProps>>(
|
|
169
169
|
configurator?: TConfigurator,
|
|
170
170
|
) => ({
|
|
171
|
-
generateStaticParams: () => locales.map((l) => ({ ${
|
|
171
|
+
generateStaticParams: () => locales.map((l) => ({ ${r}: l })),
|
|
172
172
|
generateMetadata: (
|
|
173
173
|
impl: (
|
|
174
174
|
props: I18nProps<TProps, Config, TConfigurator>,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var createAdapter = require('../../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
5
|
var n = createAdapter.createGenerator("next", (o)=>{
|
|
6
|
-
let { options: { routes: { localeParamName:
|
|
6
|
+
let e = o.options.write?.addImportExtensions ? ".js" : "", { options: { routes: { localeParamName: r } } } = o;
|
|
7
7
|
return {
|
|
8
8
|
I18nLayoutRoot: {
|
|
9
9
|
dir: createAdapter.createGenerator.dirs.server,
|
|
@@ -12,16 +12,16 @@ var n = createAdapter.createGenerator("next", (o)=>{
|
|
|
12
12
|
index: false,
|
|
13
13
|
content: ()=>`
|
|
14
14
|
import React from "react";
|
|
15
|
-
import { defaultMetadata } from "../internal/defaultMetadata";
|
|
16
|
-
import { I18nMetadataProvider } from "../internal/I18nMetadataProvider";
|
|
17
|
-
import { I18nRouteProvider } from "../internal/I18nRouteProvider";
|
|
18
|
-
import type { I18n } from "../types";
|
|
15
|
+
import { defaultMetadata } from "../internal/defaultMetadata${e}";
|
|
16
|
+
import { I18nMetadataProvider } from "../internal/I18nMetadataProvider${e}";
|
|
17
|
+
import { I18nRouteProvider } from "../internal/I18nRouteProvider${e}";
|
|
18
|
+
import type { I18n } from "../types${e}";
|
|
19
19
|
|
|
20
20
|
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 \`[${r}]\` folder).
|
|
25
25
|
*
|
|
26
26
|
* **For App Router only**
|
|
27
27
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator } from '../../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
3
|
var n = createGenerator("next", (o)=>{
|
|
4
|
-
let { options: { routes: { localeParamName:
|
|
4
|
+
let e = o.options.write?.addImportExtensions ? ".js" : "", { options: { routes: { localeParamName: r } } } = o;
|
|
5
5
|
return {
|
|
6
6
|
I18nLayoutRoot: {
|
|
7
7
|
dir: createGenerator.dirs.server,
|
|
@@ -10,16 +10,16 @@ var n = createGenerator("next", (o)=>{
|
|
|
10
10
|
index: false,
|
|
11
11
|
content: ()=>`
|
|
12
12
|
import React from "react";
|
|
13
|
-
import { defaultMetadata } from "../internal/defaultMetadata";
|
|
14
|
-
import { I18nMetadataProvider } from "../internal/I18nMetadataProvider";
|
|
15
|
-
import { I18nRouteProvider } from "../internal/I18nRouteProvider";
|
|
16
|
-
import type { I18n } from "../types";
|
|
13
|
+
import { defaultMetadata } from "../internal/defaultMetadata${e}";
|
|
14
|
+
import { I18nMetadataProvider } from "../internal/I18nMetadataProvider${e}";
|
|
15
|
+
import { I18nRouteProvider } from "../internal/I18nRouteProvider${e}";
|
|
16
|
+
import type { I18n } from "../types${e}";
|
|
17
17
|
|
|
18
18
|
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 \`[${r}]\` folder).
|
|
23
23
|
*
|
|
24
24
|
* **For App Router only**
|
|
25
25
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var createAdapter = require('../../../compiler/createAdapter.cjs.js');
|
|
4
4
|
|
|
5
5
|
var i = createAdapter.createGenerator("next", (a)=>{
|
|
6
|
-
let { config: { single:
|
|
6
|
+
let t = a.options.write?.addImportExtensions ? ".js" : "", { config: { single: o } } = a;
|
|
7
7
|
return {
|
|
8
8
|
I18nPage: {
|
|
9
9
|
dir: createAdapter.createGenerator.dirs.server,
|
|
@@ -13,21 +13,21 @@ var i = createAdapter.createGenerator("next", (a)=>{
|
|
|
13
13
|
content: ()=>`
|
|
14
14
|
import React from "react";
|
|
15
15
|
import type { Metadata } from "next/types";
|
|
16
|
-
import { getI18nDictionaries } from "../internal/getI18nDictionaries";
|
|
17
|
-
import { getI18nMetadata } from "../internal/getI18nMetadata";
|
|
18
|
-
import { I18nMetadataSetter } from "../internal/I18nMetadataSetter";
|
|
19
|
-
import { I18nRouteSetter } from "../internal/I18nRouteSetter";
|
|
20
|
-
import { I18nTranslateProvider } from "../I18nTranslateProvider";
|
|
21
|
-
import { locales } from "../locales";
|
|
22
|
-
import type { I18n } from "../types";
|
|
23
|
-
import { getServerLocale } from "./getServerLocale";
|
|
16
|
+
import { getI18nDictionaries } from "../internal/getI18nDictionaries${t}";
|
|
17
|
+
import { getI18nMetadata } from "../internal/getI18nMetadata${t}";
|
|
18
|
+
import { I18nMetadataSetter } from "../internal/I18nMetadataSetter${t}";
|
|
19
|
+
import { I18nRouteSetter } from "../internal/I18nRouteSetter${t}";
|
|
20
|
+
import { I18nTranslateProvider } from "../I18nTranslateProvider${t}";
|
|
21
|
+
import { locales } from "../locales${t}";
|
|
22
|
+
import type { I18n } from "../types${t}";
|
|
23
|
+
import { getServerLocale } from "./getServerLocale${t}";
|
|
24
24
|
import {
|
|
25
25
|
type NextProps,
|
|
26
26
|
type I18nNextPropsPage,
|
|
27
27
|
type I18nProps,
|
|
28
28
|
type I18nServerConfigurator,
|
|
29
29
|
resolveConfigurator
|
|
30
|
-
} from "./i18nServerHelpers";
|
|
30
|
+
} from "./i18nServerHelpers${t}";
|
|
31
31
|
|
|
32
32
|
type Config<TRouteId extends I18n.RouteId> = {
|
|
33
33
|
/**
|
|
@@ -38,7 +38,7 @@ type Config<TRouteId extends I18n.RouteId> = {
|
|
|
38
38
|
* Optionally set the translations _namespaces_ to expose to the client
|
|
39
39
|
* components down this page's components tree
|
|
40
40
|
*/
|
|
41
|
-
namespaces?: I18n.TranslationsNamespace[];${
|
|
41
|
+
namespaces?: I18n.TranslationsNamespace[];${o ? "" : `
|
|
42
42
|
/**
|
|
43
43
|
* Optionally set this manually to override the current locale
|
|
44
44
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator } from '../../../compiler/createAdapter.esm.js';
|
|
2
2
|
|
|
3
3
|
var i = createGenerator("next", (a)=>{
|
|
4
|
-
let { config: { single:
|
|
4
|
+
let t = a.options.write?.addImportExtensions ? ".js" : "", { config: { single: o } } = a;
|
|
5
5
|
return {
|
|
6
6
|
I18nPage: {
|
|
7
7
|
dir: createGenerator.dirs.server,
|
|
@@ -11,21 +11,21 @@ var i = createGenerator("next", (a)=>{
|
|
|
11
11
|
content: ()=>`
|
|
12
12
|
import React from "react";
|
|
13
13
|
import type { Metadata } from "next/types";
|
|
14
|
-
import { getI18nDictionaries } from "../internal/getI18nDictionaries";
|
|
15
|
-
import { getI18nMetadata } from "../internal/getI18nMetadata";
|
|
16
|
-
import { I18nMetadataSetter } from "../internal/I18nMetadataSetter";
|
|
17
|
-
import { I18nRouteSetter } from "../internal/I18nRouteSetter";
|
|
18
|
-
import { I18nTranslateProvider } from "../I18nTranslateProvider";
|
|
19
|
-
import { locales } from "../locales";
|
|
20
|
-
import type { I18n } from "../types";
|
|
21
|
-
import { getServerLocale } from "./getServerLocale";
|
|
14
|
+
import { getI18nDictionaries } from "../internal/getI18nDictionaries${t}";
|
|
15
|
+
import { getI18nMetadata } from "../internal/getI18nMetadata${t}";
|
|
16
|
+
import { I18nMetadataSetter } from "../internal/I18nMetadataSetter${t}";
|
|
17
|
+
import { I18nRouteSetter } from "../internal/I18nRouteSetter${t}";
|
|
18
|
+
import { I18nTranslateProvider } from "../I18nTranslateProvider${t}";
|
|
19
|
+
import { locales } from "../locales${t}";
|
|
20
|
+
import type { I18n } from "../types${t}";
|
|
21
|
+
import { getServerLocale } from "./getServerLocale${t}";
|
|
22
22
|
import {
|
|
23
23
|
type NextProps,
|
|
24
24
|
type I18nNextPropsPage,
|
|
25
25
|
type I18nProps,
|
|
26
26
|
type I18nServerConfigurator,
|
|
27
27
|
resolveConfigurator
|
|
28
|
-
} from "./i18nServerHelpers";
|
|
28
|
+
} from "./i18nServerHelpers${t}";
|
|
29
29
|
|
|
30
30
|
type Config<TRouteId extends I18n.RouteId> = {
|
|
31
31
|
/**
|
|
@@ -36,7 +36,7 @@ type Config<TRouteId extends I18n.RouteId> = {
|
|
|
36
36
|
* Optionally set the translations _namespaces_ to expose to the client
|
|
37
37
|
* components down this page's components tree
|
|
38
38
|
*/
|
|
39
|
-
namespaces?: I18n.TranslationsNamespace[];${
|
|
39
|
+
namespaces?: I18n.TranslationsNamespace[];${o ? "" : `
|
|
40
40
|
/**
|
|
41
41
|
* Optionally set this manually to override the current locale
|
|
42
42
|
*/
|