@koine/i18n 2.0.0-beta.68 → 2.0.0-beta.69
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/api.cjs.js +17 -9
- package/api.esm.js +17 -9
- package/package.json +3 -3
package/api.cjs.js
CHANGED
|
@@ -297,7 +297,7 @@ let pluralRules = new Intl.PluralRules();
|
|
|
297
297
|
|
|
298
298
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
299
|
export let tPluralise = (values: any, count: number) =>
|
|
300
|
-
values[count] || values[pluralRules.select(count)] || values["other"];
|
|
300
|
+
values[count] || values[pluralRules.select(count)] || (count === 0 ? values.zero : values["other"]);
|
|
301
301
|
|
|
302
302
|
export default tPluralise;
|
|
303
303
|
`);
|
|
@@ -448,6 +448,11 @@ export function toSpa<
|
|
|
448
448
|
// FIXME: actually the locale will be prepended if hideDefaultLocaleInUrl will be false
|
|
449
449
|
"", // do not pass the locale so that won't be prepended
|
|
450
450
|
(routesSpa[fullId] as Record<string, string>)[locale],
|
|
451
|
+
args.length === 2
|
|
452
|
+
? args[0]
|
|
453
|
+
: args[0] && !isLocale(args[0])
|
|
454
|
+
? args[0]
|
|
455
|
+
: void 0,
|
|
451
456
|
) as I18n.RouteSpa[Root][Path];
|
|
452
457
|
}
|
|
453
458
|
|
|
@@ -1297,19 +1302,22 @@ export const useToSpa = () => {
|
|
|
1297
1302
|
const locale = useLocale();
|
|
1298
1303
|
return <
|
|
1299
1304
|
Root extends keyof I18n.RouteSpa,
|
|
1300
|
-
Path extends Extract<keyof I18n.RouteSpa[Root], string
|
|
1305
|
+
Path extends Extract<keyof I18n.RouteSpa[Root], string>,
|
|
1301
1306
|
>(
|
|
1307
|
+
root: Root,
|
|
1308
|
+
path: Path,
|
|
1302
1309
|
...args: I18n.RouteJoinedId<Root, Path> extends I18n.RouteIdDynamic
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1310
|
+
? [params: I18n.RouteParams[I18n.RouteJoinedId<Root, Path>]]
|
|
1311
|
+
: I18n.RouteJoinedId<Root, Path> extends I18n.RouteIdStatic
|
|
1312
|
+
? []
|
|
1313
|
+
: never
|
|
1307
1314
|
) => {
|
|
1308
|
-
const [
|
|
1315
|
+
const [params] = args;
|
|
1309
1316
|
return (
|
|
1317
|
+
// prettier-ignore
|
|
1310
1318
|
// @ts-expect-error FIXME: types
|
|
1311
|
-
params ? toSpa(root, path, params, locale) : toSpa(root, path, locale)
|
|
1312
|
-
)
|
|
1319
|
+
(params ? toSpa(root, path, params, locale) : toSpa(root, path, locale)) as I18n.RouteSpa[Root][Path]
|
|
1320
|
+
);
|
|
1313
1321
|
};
|
|
1314
1322
|
};
|
|
1315
1323
|
|
package/api.esm.js
CHANGED
|
@@ -275,7 +275,7 @@ let pluralRules = new Intl.PluralRules();
|
|
|
275
275
|
|
|
276
276
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
277
277
|
export let tPluralise = (values: any, count: number) =>
|
|
278
|
-
values[count] || values[pluralRules.select(count)] || values["other"];
|
|
278
|
+
values[count] || values[pluralRules.select(count)] || (count === 0 ? values.zero : values["other"]);
|
|
279
279
|
|
|
280
280
|
export default tPluralise;
|
|
281
281
|
`);
|
|
@@ -426,6 +426,11 @@ export function toSpa<
|
|
|
426
426
|
// FIXME: actually the locale will be prepended if hideDefaultLocaleInUrl will be false
|
|
427
427
|
"", // do not pass the locale so that won't be prepended
|
|
428
428
|
(routesSpa[fullId] as Record<string, string>)[locale],
|
|
429
|
+
args.length === 2
|
|
430
|
+
? args[0]
|
|
431
|
+
: args[0] && !isLocale(args[0])
|
|
432
|
+
? args[0]
|
|
433
|
+
: void 0,
|
|
429
434
|
) as I18n.RouteSpa[Root][Path];
|
|
430
435
|
}
|
|
431
436
|
|
|
@@ -1275,19 +1280,22 @@ export const useToSpa = () => {
|
|
|
1275
1280
|
const locale = useLocale();
|
|
1276
1281
|
return <
|
|
1277
1282
|
Root extends keyof I18n.RouteSpa,
|
|
1278
|
-
Path extends Extract<keyof I18n.RouteSpa[Root], string
|
|
1283
|
+
Path extends Extract<keyof I18n.RouteSpa[Root], string>,
|
|
1279
1284
|
>(
|
|
1285
|
+
root: Root,
|
|
1286
|
+
path: Path,
|
|
1280
1287
|
...args: I18n.RouteJoinedId<Root, Path> extends I18n.RouteIdDynamic
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1288
|
+
? [params: I18n.RouteParams[I18n.RouteJoinedId<Root, Path>]]
|
|
1289
|
+
: I18n.RouteJoinedId<Root, Path> extends I18n.RouteIdStatic
|
|
1290
|
+
? []
|
|
1291
|
+
: never
|
|
1285
1292
|
) => {
|
|
1286
|
-
const [
|
|
1293
|
+
const [params] = args;
|
|
1287
1294
|
return (
|
|
1295
|
+
// prettier-ignore
|
|
1288
1296
|
// @ts-expect-error FIXME: types
|
|
1289
|
-
params ? toSpa(root, path, params, locale) : toSpa(root, path, locale)
|
|
1290
|
-
)
|
|
1297
|
+
(params ? toSpa(root, path, params, locale) : toSpa(root, path, locale)) as I18n.RouteSpa[Root][Path]
|
|
1298
|
+
);
|
|
1291
1299
|
};
|
|
1292
1300
|
};
|
|
1293
1301
|
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "@koine/i18n",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/node": "2.0.0-beta.
|
|
6
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/node": "2.0.0-beta.69",
|
|
6
|
+
"@koine/utils": "2.0.0-beta.69",
|
|
7
7
|
"glob": "^10.3.10",
|
|
8
8
|
"webpack": "^5.90.1",
|
|
9
9
|
"minimatch": "^9.0.3",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
},
|
|
59
59
|
"module": "./index.esm.js",
|
|
60
60
|
"main": "./index.cjs.js",
|
|
61
|
-
"version": "2.0.0-beta.
|
|
61
|
+
"version": "2.0.0-beta.69"
|
|
62
62
|
}
|