@koine/i18n 2.0.0-beta.190 → 2.0.0-beta.192
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/types.cjs.js +44 -63
- package/adapter-js/generators/types.esm.js +44 -63
- package/adapter-next/generators/router-app/I18nLayout.cjs.js +72 -70
- package/adapter-next/generators/router-app/I18nLayout.esm.js +72 -70
- package/adapter-next/generators/router-app/I18nPage.cjs.js +94 -173
- package/adapter-next/generators/router-app/I18nPage.esm.js +94 -173
- package/adapter-next/generators/router-app/i18nServer.cjs.js +114 -3
- package/adapter-next/generators/router-app/i18nServer.d.ts +7 -0
- package/adapter-next/generators/router-app/i18nServer.esm.js +114 -3
- package/adapter-next/index.d.ts +7 -0
- package/package.json +3 -3
|
@@ -9,15 +9,15 @@ var imports = require('../../compiler/imports.cjs.js');
|
|
|
9
9
|
var pluralisation = require('../../compiler/pluralisation.cjs.js');
|
|
10
10
|
|
|
11
11
|
function getTypeLocale(e) {
|
|
12
|
-
return
|
|
12
|
+
return d(e.locales);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function d(e, t = !0) {
|
|
15
15
|
return (t ? e.sort() : e).filter(utils.isString).map((e)=>`"${e}"`).join(" | ");
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function y(e, t) {
|
|
18
|
+
return d(Object.keys(e.byId).filter((a)=>t(a, e.byId[a]))) || "never";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function m(e) {
|
|
21
21
|
return `{
|
|
22
22
|
${e.join("\n ")}
|
|
23
23
|
}`;
|
|
@@ -32,13 +32,13 @@ const getImportTypes = ()=>new imports.ImportsCompiler({
|
|
|
32
32
|
]
|
|
33
33
|
});
|
|
34
34
|
var x = createAdapter.createGenerator("js", (i)=>{
|
|
35
|
-
let { options: { routes: {
|
|
36
|
-
let { config: i, routes:
|
|
35
|
+
let { options: { routes: { tokens: { idDelimiter: d } }, translations: { tokens: { keyDelimiter: u, namespaceDelimiter: h } } } } = i, f = function(s) {
|
|
36
|
+
let { config: i, routes: d, options: u } = s;
|
|
37
37
|
return {
|
|
38
38
|
Locale: getTypeLocale(i),
|
|
39
|
-
RouteIdStatic: d
|
|
40
|
-
RouteIdDynamic: d
|
|
41
|
-
RouteSpa:
|
|
39
|
+
RouteIdStatic: y(d, (e, { params: t })=>!t),
|
|
40
|
+
RouteIdDynamic: y(d, (e, { params: t })=>!!t),
|
|
41
|
+
RouteSpa: m(function(e, t, a) {
|
|
42
42
|
let n = Object.keys(t.byId).reduce((e, a)=>{
|
|
43
43
|
if (t.byId[a].inWildcard) for(let n = 0; n < t.wildcardIds.length; n++){
|
|
44
44
|
let s = t.wildcardIds[n];
|
|
@@ -55,28 +55,28 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
55
55
|
s.push(`"${o}": { ${l.join(" ")} }`);
|
|
56
56
|
}
|
|
57
57
|
return s;
|
|
58
|
-
}(i,
|
|
59
|
-
RoutePathnames:
|
|
58
|
+
}(i, d, u)),
|
|
59
|
+
RoutePathnames: m(function(e, t) {
|
|
60
60
|
let a = [];
|
|
61
61
|
for(let n in t.byId){
|
|
62
62
|
let s = t.byId[n];
|
|
63
63
|
a.push(`"${s.id}": "${s.pathnames[e.defaultLocale]}";`);
|
|
64
64
|
}
|
|
65
65
|
return a;
|
|
66
|
-
}(i,
|
|
67
|
-
RouteParams:
|
|
66
|
+
}(i, d)),
|
|
67
|
+
RouteParams: m(function(e) {
|
|
68
68
|
let t = [];
|
|
69
69
|
for(let a in e.byId){
|
|
70
70
|
let { params: n } = e.byId[a];
|
|
71
71
|
n && t.push(`"${a}": ${helpers.compileDataParamsToType(n)};`);
|
|
72
72
|
}
|
|
73
73
|
return t;
|
|
74
|
-
}(
|
|
75
|
-
TranslationsDictionary:
|
|
76
|
-
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths:
|
|
77
|
-
for(let s = 0; s <
|
|
78
|
-
let { path: o, data: r } =
|
|
79
|
-
|
|
74
|
+
}(d)),
|
|
75
|
+
TranslationsDictionary: m(function(s) {
|
|
76
|
+
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths: d } } } = s, y = helpers.filterInputTranslationFiles(i, d, (e)=>e.locale === o), m = [];
|
|
77
|
+
for(let s = 0; s < y.length; s++){
|
|
78
|
+
let { path: o, data: r } = y[s], i = o.replace(".json", "");
|
|
79
|
+
m.push(`"${i}": ${function s(o) {
|
|
80
80
|
let r = "", i = "";
|
|
81
81
|
if (utils.isBoolean(o) ? i = "boolean" : utils.isString(o) && (i = "string"), i) r += i + ";";
|
|
82
82
|
else if (o) {
|
|
@@ -87,8 +87,8 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
87
87
|
r += "{";
|
|
88
88
|
let t = pluralisation.transformKeysForPlurals(Object.keys(o));
|
|
89
89
|
for(let n = 0; n < t.length; n++){
|
|
90
|
-
let i = t[n],
|
|
91
|
-
r += !utils.isArray(
|
|
90
|
+
let i = t[n], T = o[i] || "";
|
|
91
|
+
r += !utils.isArray(T) && utils.isObject(T) && pluralisation.hasPlurals(T) ? pluralisation.hasOnlyPluralKeys(T) ? `"${i}": string;` : `"${i}": ${s(pluralisation.pickNonPluralValue(T))}` : `"${i}": ${s(T)}`;
|
|
92
92
|
}
|
|
93
93
|
r += "};";
|
|
94
94
|
}
|
|
@@ -96,7 +96,7 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
96
96
|
return (r = r.replace(/;\[\];/g, "[];")).replace(/;+/g, ";");
|
|
97
97
|
}(r)}`);
|
|
98
98
|
}
|
|
99
|
-
return
|
|
99
|
+
return m.sort();
|
|
100
100
|
}(s))
|
|
101
101
|
};
|
|
102
102
|
}(i);
|
|
@@ -111,8 +111,6 @@ var x = createAdapter.createGenerator("js", (i)=>{
|
|
|
111
111
|
declare namespace I18n {
|
|
112
112
|
type Locale = import("../types").I18n.Locale;
|
|
113
113
|
type LocalesMap = import("../types").I18n.LocalesMap;
|
|
114
|
-
type Params = import("../types").I18n.Params;
|
|
115
|
-
type Props = import("../types").I18n.Props;
|
|
116
114
|
type RouteArgs = import("../types").I18n.RouteArgs;
|
|
117
115
|
type RouteId = import("../types").I18n.RouteId;
|
|
118
116
|
type RouteIdDynamic = import("../types").I18n.RouteIdDynamic;
|
|
@@ -142,7 +140,7 @@ declare namespace I18n {
|
|
|
142
140
|
ext: "ts",
|
|
143
141
|
index: !0,
|
|
144
142
|
content: ()=>`
|
|
145
|
-
import type { Split
|
|
143
|
+
import type { Split } from "@koine/utils";
|
|
146
144
|
import type { I18nUtils } from "${process.env.JEST_WORKER_ID ? "../../../types" : "@koine/i18n"}";
|
|
147
145
|
import type { RouteIdError } from "./internal/routesError";
|
|
148
146
|
|
|
@@ -150,7 +148,7 @@ export namespace I18n {
|
|
|
150
148
|
/**
|
|
151
149
|
* Any of the available locale code
|
|
152
150
|
*/
|
|
153
|
-
export type Locale = ${
|
|
151
|
+
export type Locale = ${f.Locale};
|
|
154
152
|
|
|
155
153
|
/**
|
|
156
154
|
* Utility to map values by all available locales
|
|
@@ -159,23 +157,6 @@ export namespace I18n {
|
|
|
159
157
|
*/
|
|
160
158
|
export type LocalesMap<T = any> = Record<Locale, T>;
|
|
161
159
|
|
|
162
|
-
/**
|
|
163
|
-
* Params globally available from the URL/folder structure \`${y}\`,
|
|
164
|
-
* named accordingly to the \`localeParam\` option (e.g. _next.js_ folder structure
|
|
165
|
-
* \`/[${y}]/my-route/page.tsx\`)
|
|
166
|
-
*/
|
|
167
|
-
export type Params = {
|
|
168
|
-
${y}: Locale;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Props available to each page/layout when a root \`localeParam\` is in place
|
|
173
|
-
* (e.g. _next.js_ folder structure \`/[${y}]/my-route/page.tsx\`).
|
|
174
|
-
*/
|
|
175
|
-
export type Props<P = {}> = P & {
|
|
176
|
-
params: Params;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
160
|
/**
|
|
180
161
|
* @internal
|
|
181
162
|
*/
|
|
@@ -196,32 +177,32 @@ export namespace I18n {
|
|
|
196
177
|
/**
|
|
197
178
|
* The static routes available ids
|
|
198
179
|
*/
|
|
199
|
-
export type RouteIdStatic = ${
|
|
180
|
+
export type RouteIdStatic = ${f.RouteIdStatic};
|
|
200
181
|
|
|
201
182
|
/**
|
|
202
183
|
* The dynamic routes available ids
|
|
203
184
|
*/
|
|
204
|
-
export type RouteIdDynamic = ${
|
|
185
|
+
export type RouteIdDynamic = ${f.RouteIdDynamic};
|
|
205
186
|
|
|
206
187
|
/**
|
|
207
188
|
* Route dynamic params dictionary for each dynamic route id
|
|
208
|
-
|
|
209
|
-
|
|
189
|
+
*/
|
|
190
|
+
export type RouteParams = ${f.RouteParams};
|
|
210
191
|
|
|
211
192
|
/**
|
|
212
|
-
* Map every route id to its actual
|
|
193
|
+
* Map every route id to its actual pathname value for the default locale
|
|
213
194
|
*/
|
|
214
|
-
export type RoutePathnames = ${
|
|
195
|
+
export type RoutePathnames = ${f.RoutePathnames};
|
|
215
196
|
|
|
216
197
|
/**
|
|
217
198
|
* Map every SPA path divided by their roots to their actual pathname value for the default locale
|
|
218
199
|
*/
|
|
219
|
-
export type RouteSpa = ${
|
|
200
|
+
export type RouteSpa = ${f.RouteSpa};
|
|
220
201
|
|
|
221
202
|
/**
|
|
222
203
|
* Utility to join two route ids
|
|
223
204
|
*/
|
|
224
|
-
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${
|
|
205
|
+
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${d}\${Tail}\` extends RouteId ? \`\${Root}${d}\${Tail}\` : never;
|
|
225
206
|
|
|
226
207
|
/**
|
|
227
208
|
* Extract all children routes that starts with the given string
|
|
@@ -238,7 +219,7 @@ export namespace I18n {
|
|
|
238
219
|
* The types extracted from the translations JSON files, this is a little
|
|
239
220
|
* more sophisticated than the type result of \`typeof "./en/messages.json"\`
|
|
240
221
|
*/
|
|
241
|
-
export type TranslationsDictionary = ${
|
|
222
|
+
export type TranslationsDictionary = ${f.TranslationsDictionary};
|
|
242
223
|
|
|
243
224
|
/**
|
|
244
225
|
* Any of the available translations dictionary namespaces
|
|
@@ -260,13 +241,13 @@ export namespace I18n {
|
|
|
260
241
|
*
|
|
261
242
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
262
243
|
* - \`namespace\` only a namespace
|
|
263
|
-
* - \`namespace${
|
|
264
|
-
* - \`namespace${
|
|
244
|
+
* - \`namespace${h}myKey\` sub dictionaries within a namespace
|
|
245
|
+
* - \`namespace${h}myKey.nested\` whatever nested level of nesting
|
|
265
246
|
*/
|
|
266
247
|
export type TranslationsChildrenOf<T extends TranslationAtGeneric> =
|
|
267
248
|
T extends TranslationsNamespace
|
|
268
249
|
? TranslationsPaths<TranslationsDictionary[T]>
|
|
269
|
-
: T extends \`\${infer Namespace}${
|
|
250
|
+
: T extends \`\${infer Namespace}${h}\${infer Path}\`
|
|
270
251
|
? Namespace extends TranslationsNamespace
|
|
271
252
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path> extends object
|
|
272
253
|
? TranslationsPaths<I18nUtils.Get<TranslationsDictionary[Namespace], Path>>
|
|
@@ -276,12 +257,12 @@ export namespace I18n {
|
|
|
276
257
|
|
|
277
258
|
/**
|
|
278
259
|
* All translations ancestor partial _paths_ of the given one, e.g. if \`T\` would be
|
|
279
|
-
* \`"area${
|
|
280
|
-
* \`"area${
|
|
260
|
+
* \`"area${u}main${u}[id]${u}edit"\` the generated type would be the union
|
|
261
|
+
* \`"area${u}main${u}[id]" | "area${u}main" | "area"\`.
|
|
281
262
|
*/
|
|
282
263
|
export type TranslationsAncestorsOf<
|
|
283
264
|
T extends string,
|
|
284
|
-
TSeparator extends string = "${
|
|
265
|
+
TSeparator extends string = "${u}",
|
|
285
266
|
> = I18nUtils.BuildRecursiveJoin<Split<T, TSeparator>, TSeparator>;
|
|
286
267
|
|
|
287
268
|
/**
|
|
@@ -289,13 +270,13 @@ export namespace I18n {
|
|
|
289
270
|
*
|
|
290
271
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
291
272
|
* - \`namespace\` only a namespace
|
|
292
|
-
* - \`namespace${
|
|
293
|
-
* - \`namespace${
|
|
273
|
+
* - \`namespace${h}myKey\` sub dictionaries within a namespace
|
|
274
|
+
* - \`namespace${h}myKey${u}nested\` whatever nested level of nesting
|
|
294
275
|
*/
|
|
295
276
|
export type TranslationAt<T extends TranslationAtGeneric> =
|
|
296
277
|
T extends TranslationsNamespace
|
|
297
278
|
? TranslationsDictionary[T]
|
|
298
|
-
: T extends \`\${infer Namespace}${
|
|
279
|
+
: T extends \`\${infer Namespace}${h}\${infer Path}\`
|
|
299
280
|
? Namespace extends TranslationsNamespace
|
|
300
281
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path>
|
|
301
282
|
: never
|
|
@@ -314,7 +295,7 @@ export namespace I18n {
|
|
|
314
295
|
*
|
|
315
296
|
* \`T\` can be any of all possible paths:
|
|
316
297
|
* - \`myKey\` sub dictionaries within a namespace
|
|
317
|
-
* - \`myKey${
|
|
298
|
+
* - \`myKey${u}nested\` whatever nested level of nesting within a namespace
|
|
318
299
|
*/
|
|
319
300
|
export type TranslationAtNamespace<
|
|
320
301
|
TNamespace extends TranslationsNamespace,
|
|
@@ -5,15 +5,15 @@ import { ImportsCompiler } from '../../compiler/imports.esm.js';
|
|
|
5
5
|
import { transformKeysForPlurals, hasPlurals, hasOnlyPluralKeys, pickNonPluralValue } from '../../compiler/pluralisation.esm.js';
|
|
6
6
|
|
|
7
7
|
function getTypeLocale(e) {
|
|
8
|
-
return
|
|
8
|
+
return d(e.locales);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function d(e, t = !0) {
|
|
11
11
|
return (t ? e.sort() : e).filter(isString).map((e)=>`"${e}"`).join(" | ");
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function y(e, t) {
|
|
14
|
+
return d(Object.keys(e.byId).filter((a)=>t(a, e.byId[a]))) || "never";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function m(e) {
|
|
17
17
|
return `{
|
|
18
18
|
${e.join("\n ")}
|
|
19
19
|
}`;
|
|
@@ -28,13 +28,13 @@ const getImportTypes = ()=>new ImportsCompiler({
|
|
|
28
28
|
]
|
|
29
29
|
});
|
|
30
30
|
var x = createGenerator("js", (i)=>{
|
|
31
|
-
let { options: { routes: {
|
|
32
|
-
let { config: i, routes:
|
|
31
|
+
let { options: { routes: { tokens: { idDelimiter: d } }, translations: { tokens: { keyDelimiter: u, namespaceDelimiter: h } } } } = i, f = function(s) {
|
|
32
|
+
let { config: i, routes: d, options: u } = s;
|
|
33
33
|
return {
|
|
34
34
|
Locale: getTypeLocale(i),
|
|
35
|
-
RouteIdStatic: d
|
|
36
|
-
RouteIdDynamic: d
|
|
37
|
-
RouteSpa:
|
|
35
|
+
RouteIdStatic: y(d, (e, { params: t })=>!t),
|
|
36
|
+
RouteIdDynamic: y(d, (e, { params: t })=>!!t),
|
|
37
|
+
RouteSpa: m(function(e, t, a) {
|
|
38
38
|
let n = Object.keys(t.byId).reduce((e, a)=>{
|
|
39
39
|
if (t.byId[a].inWildcard) for(let n = 0; n < t.wildcardIds.length; n++){
|
|
40
40
|
let s = t.wildcardIds[n];
|
|
@@ -51,28 +51,28 @@ var x = createGenerator("js", (i)=>{
|
|
|
51
51
|
s.push(`"${o}": { ${l.join(" ")} }`);
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
|
-
}(i,
|
|
55
|
-
RoutePathnames:
|
|
54
|
+
}(i, d, u)),
|
|
55
|
+
RoutePathnames: m(function(e, t) {
|
|
56
56
|
let a = [];
|
|
57
57
|
for(let n in t.byId){
|
|
58
58
|
let s = t.byId[n];
|
|
59
59
|
a.push(`"${s.id}": "${s.pathnames[e.defaultLocale]}";`);
|
|
60
60
|
}
|
|
61
61
|
return a;
|
|
62
|
-
}(i,
|
|
63
|
-
RouteParams:
|
|
62
|
+
}(i, d)),
|
|
63
|
+
RouteParams: m(function(e) {
|
|
64
64
|
let t = [];
|
|
65
65
|
for(let a in e.byId){
|
|
66
66
|
let { params: n } = e.byId[a];
|
|
67
67
|
n && t.push(`"${a}": ${compileDataParamsToType(n)};`);
|
|
68
68
|
}
|
|
69
69
|
return t;
|
|
70
|
-
}(
|
|
71
|
-
TranslationsDictionary:
|
|
72
|
-
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths:
|
|
73
|
-
for(let s = 0; s <
|
|
74
|
-
let { path: o, data: r } =
|
|
75
|
-
|
|
70
|
+
}(d)),
|
|
71
|
+
TranslationsDictionary: m(function(s) {
|
|
72
|
+
let { config: { defaultLocale: o }, input: { translationFiles: i }, options: { translations: { ignorePaths: d } } } = s, y = filterInputTranslationFiles(i, d, (e)=>e.locale === o), m = [];
|
|
73
|
+
for(let s = 0; s < y.length; s++){
|
|
74
|
+
let { path: o, data: r } = y[s], i = o.replace(".json", "");
|
|
75
|
+
m.push(`"${i}": ${function s(o) {
|
|
76
76
|
let r = "", i = "";
|
|
77
77
|
if (isBoolean(o) ? i = "boolean" : isString(o) && (i = "string"), i) r += i + ";";
|
|
78
78
|
else if (o) {
|
|
@@ -83,8 +83,8 @@ var x = createGenerator("js", (i)=>{
|
|
|
83
83
|
r += "{";
|
|
84
84
|
let t = transformKeysForPlurals(Object.keys(o));
|
|
85
85
|
for(let n = 0; n < t.length; n++){
|
|
86
|
-
let i = t[n],
|
|
87
|
-
r += !isArray(
|
|
86
|
+
let i = t[n], T = o[i] || "";
|
|
87
|
+
r += !isArray(T) && isObject(T) && hasPlurals(T) ? hasOnlyPluralKeys(T) ? `"${i}": string;` : `"${i}": ${s(pickNonPluralValue(T))}` : `"${i}": ${s(T)}`;
|
|
88
88
|
}
|
|
89
89
|
r += "};";
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ var x = createGenerator("js", (i)=>{
|
|
|
92
92
|
return (r = r.replace(/;\[\];/g, "[];")).replace(/;+/g, ";");
|
|
93
93
|
}(r)}`);
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return m.sort();
|
|
96
96
|
}(s))
|
|
97
97
|
};
|
|
98
98
|
}(i);
|
|
@@ -107,8 +107,6 @@ var x = createGenerator("js", (i)=>{
|
|
|
107
107
|
declare namespace I18n {
|
|
108
108
|
type Locale = import("../types").I18n.Locale;
|
|
109
109
|
type LocalesMap = import("../types").I18n.LocalesMap;
|
|
110
|
-
type Params = import("../types").I18n.Params;
|
|
111
|
-
type Props = import("../types").I18n.Props;
|
|
112
110
|
type RouteArgs = import("../types").I18n.RouteArgs;
|
|
113
111
|
type RouteId = import("../types").I18n.RouteId;
|
|
114
112
|
type RouteIdDynamic = import("../types").I18n.RouteIdDynamic;
|
|
@@ -138,7 +136,7 @@ declare namespace I18n {
|
|
|
138
136
|
ext: "ts",
|
|
139
137
|
index: !0,
|
|
140
138
|
content: ()=>`
|
|
141
|
-
import type { Split
|
|
139
|
+
import type { Split } from "@koine/utils";
|
|
142
140
|
import type { I18nUtils } from "${process.env.JEST_WORKER_ID ? "../../../types" : "@koine/i18n"}";
|
|
143
141
|
import type { RouteIdError } from "./internal/routesError";
|
|
144
142
|
|
|
@@ -146,7 +144,7 @@ export namespace I18n {
|
|
|
146
144
|
/**
|
|
147
145
|
* Any of the available locale code
|
|
148
146
|
*/
|
|
149
|
-
export type Locale = ${
|
|
147
|
+
export type Locale = ${f.Locale};
|
|
150
148
|
|
|
151
149
|
/**
|
|
152
150
|
* Utility to map values by all available locales
|
|
@@ -155,23 +153,6 @@ export namespace I18n {
|
|
|
155
153
|
*/
|
|
156
154
|
export type LocalesMap<T = any> = Record<Locale, T>;
|
|
157
155
|
|
|
158
|
-
/**
|
|
159
|
-
* Params globally available from the URL/folder structure \`${y}\`,
|
|
160
|
-
* named accordingly to the \`localeParam\` option (e.g. _next.js_ folder structure
|
|
161
|
-
* \`/[${y}]/my-route/page.tsx\`)
|
|
162
|
-
*/
|
|
163
|
-
export type Params = {
|
|
164
|
-
${y}: Locale;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Props available to each page/layout when a root \`localeParam\` is in place
|
|
169
|
-
* (e.g. _next.js_ folder structure \`/[${y}]/my-route/page.tsx\`).
|
|
170
|
-
*/
|
|
171
|
-
export type Props<P = {}> = P & {
|
|
172
|
-
params: Params;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
156
|
/**
|
|
176
157
|
* @internal
|
|
177
158
|
*/
|
|
@@ -192,32 +173,32 @@ export namespace I18n {
|
|
|
192
173
|
/**
|
|
193
174
|
* The static routes available ids
|
|
194
175
|
*/
|
|
195
|
-
export type RouteIdStatic = ${
|
|
176
|
+
export type RouteIdStatic = ${f.RouteIdStatic};
|
|
196
177
|
|
|
197
178
|
/**
|
|
198
179
|
* The dynamic routes available ids
|
|
199
180
|
*/
|
|
200
|
-
export type RouteIdDynamic = ${
|
|
181
|
+
export type RouteIdDynamic = ${f.RouteIdDynamic};
|
|
201
182
|
|
|
202
183
|
/**
|
|
203
184
|
* Route dynamic params dictionary for each dynamic route id
|
|
204
|
-
|
|
205
|
-
|
|
185
|
+
*/
|
|
186
|
+
export type RouteParams = ${f.RouteParams};
|
|
206
187
|
|
|
207
188
|
/**
|
|
208
|
-
* Map every route id to its actual
|
|
189
|
+
* Map every route id to its actual pathname value for the default locale
|
|
209
190
|
*/
|
|
210
|
-
export type RoutePathnames = ${
|
|
191
|
+
export type RoutePathnames = ${f.RoutePathnames};
|
|
211
192
|
|
|
212
193
|
/**
|
|
213
194
|
* Map every SPA path divided by their roots to their actual pathname value for the default locale
|
|
214
195
|
*/
|
|
215
|
-
export type RouteSpa = ${
|
|
196
|
+
export type RouteSpa = ${f.RouteSpa};
|
|
216
197
|
|
|
217
198
|
/**
|
|
218
199
|
* Utility to join two route ids
|
|
219
200
|
*/
|
|
220
|
-
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${
|
|
201
|
+
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${d}\${Tail}\` extends RouteId ? \`\${Root}${d}\${Tail}\` : never;
|
|
221
202
|
|
|
222
203
|
/**
|
|
223
204
|
* Extract all children routes that starts with the given string
|
|
@@ -234,7 +215,7 @@ export namespace I18n {
|
|
|
234
215
|
* The types extracted from the translations JSON files, this is a little
|
|
235
216
|
* more sophisticated than the type result of \`typeof "./en/messages.json"\`
|
|
236
217
|
*/
|
|
237
|
-
export type TranslationsDictionary = ${
|
|
218
|
+
export type TranslationsDictionary = ${f.TranslationsDictionary};
|
|
238
219
|
|
|
239
220
|
/**
|
|
240
221
|
* Any of the available translations dictionary namespaces
|
|
@@ -256,13 +237,13 @@ export namespace I18n {
|
|
|
256
237
|
*
|
|
257
238
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
258
239
|
* - \`namespace\` only a namespace
|
|
259
|
-
* - \`namespace${
|
|
260
|
-
* - \`namespace${
|
|
240
|
+
* - \`namespace${h}myKey\` sub dictionaries within a namespace
|
|
241
|
+
* - \`namespace${h}myKey.nested\` whatever nested level of nesting
|
|
261
242
|
*/
|
|
262
243
|
export type TranslationsChildrenOf<T extends TranslationAtGeneric> =
|
|
263
244
|
T extends TranslationsNamespace
|
|
264
245
|
? TranslationsPaths<TranslationsDictionary[T]>
|
|
265
|
-
: T extends \`\${infer Namespace}${
|
|
246
|
+
: T extends \`\${infer Namespace}${h}\${infer Path}\`
|
|
266
247
|
? Namespace extends TranslationsNamespace
|
|
267
248
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path> extends object
|
|
268
249
|
? TranslationsPaths<I18nUtils.Get<TranslationsDictionary[Namespace], Path>>
|
|
@@ -272,12 +253,12 @@ export namespace I18n {
|
|
|
272
253
|
|
|
273
254
|
/**
|
|
274
255
|
* All translations ancestor partial _paths_ of the given one, e.g. if \`T\` would be
|
|
275
|
-
* \`"area${
|
|
276
|
-
* \`"area${
|
|
256
|
+
* \`"area${u}main${u}[id]${u}edit"\` the generated type would be the union
|
|
257
|
+
* \`"area${u}main${u}[id]" | "area${u}main" | "area"\`.
|
|
277
258
|
*/
|
|
278
259
|
export type TranslationsAncestorsOf<
|
|
279
260
|
T extends string,
|
|
280
|
-
TSeparator extends string = "${
|
|
261
|
+
TSeparator extends string = "${u}",
|
|
281
262
|
> = I18nUtils.BuildRecursiveJoin<Split<T, TSeparator>, TSeparator>;
|
|
282
263
|
|
|
283
264
|
/**
|
|
@@ -285,13 +266,13 @@ export namespace I18n {
|
|
|
285
266
|
*
|
|
286
267
|
* \`T\` can be any of all possible paths begininng with a namespace:
|
|
287
268
|
* - \`namespace\` only a namespace
|
|
288
|
-
* - \`namespace${
|
|
289
|
-
* - \`namespace${
|
|
269
|
+
* - \`namespace${h}myKey\` sub dictionaries within a namespace
|
|
270
|
+
* - \`namespace${h}myKey${u}nested\` whatever nested level of nesting
|
|
290
271
|
*/
|
|
291
272
|
export type TranslationAt<T extends TranslationAtGeneric> =
|
|
292
273
|
T extends TranslationsNamespace
|
|
293
274
|
? TranslationsDictionary[T]
|
|
294
|
-
: T extends \`\${infer Namespace}${
|
|
275
|
+
: T extends \`\${infer Namespace}${h}\${infer Path}\`
|
|
295
276
|
? Namespace extends TranslationsNamespace
|
|
296
277
|
? I18nUtils.Get<TranslationsDictionary[Namespace], Path>
|
|
297
278
|
: never
|
|
@@ -310,7 +291,7 @@ export namespace I18n {
|
|
|
310
291
|
*
|
|
311
292
|
* \`T\` can be any of all possible paths:
|
|
312
293
|
* - \`myKey\` sub dictionaries within a namespace
|
|
313
|
-
* - \`myKey${
|
|
294
|
+
* - \`myKey${u}nested\` whatever nested level of nesting within a namespace
|
|
314
295
|
*/
|
|
315
296
|
export type TranslationAtNamespace<
|
|
316
297
|
TNamespace extends TranslationsNamespace,
|