@nuxtjs/i18n-edge 10.4.0-29727093.ea1e0bb → 10.4.0-29728007.8564ea1
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/dist/module.json +1 -1
- package/dist/module.mjs +32 -9
- package/dist/runtime/composables/index.d.ts +9 -11
- package/package.json +2 -2
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1210,7 +1210,7 @@ const HeistPlugin = (options, ctx, nuxt = useNuxt()) => {
|
|
|
1210
1210
|
}));
|
|
1211
1211
|
};
|
|
1212
1212
|
|
|
1213
|
-
const version = "10.4.0-
|
|
1213
|
+
const version = "10.4.0-29728007.8564ea1";
|
|
1214
1214
|
|
|
1215
1215
|
async function extendBundler(ctx, nuxt) {
|
|
1216
1216
|
const pluginOptions = {
|
|
@@ -1343,14 +1343,30 @@ function generateLoaderOptions(ctx, nuxt) {
|
|
|
1343
1343
|
return { localeLoaders, vueI18nConfigs, normalizedLocales, importStatements: Array.from(importStatements) };
|
|
1344
1344
|
}
|
|
1345
1345
|
const typedRouterAugmentations = `
|
|
1346
|
+
import type {
|
|
1347
|
+
TypesConfig,
|
|
1348
|
+
RouteMapGeneric,
|
|
1349
|
+
RouteLocationAsRelativeGeneric,
|
|
1350
|
+
RouteLocationAsPathGeneric,
|
|
1351
|
+
RouteLocationAsRelativeTypedList,
|
|
1352
|
+
RouteLocationAsStringTypedList,
|
|
1353
|
+
RouteLocationAsPathTypedList,
|
|
1354
|
+
RouteLocationResolvedGeneric,
|
|
1355
|
+
RouteLocationResolvedTypedList,
|
|
1356
|
+
RouteLocationNormalizedLoadedGeneric,
|
|
1357
|
+
} from 'vue-router'
|
|
1358
|
+
|
|
1346
1359
|
declare module 'vue-router' {
|
|
1347
1360
|
export type RouteMapI18n =
|
|
1348
1361
|
TypesConfig extends Record<'RouteNamedMapI18n', infer RouteNamedMap> ? RouteNamedMap : RouteMapGeneric
|
|
1349
1362
|
|
|
1350
1363
|
// Prefer named resolution for i18n
|
|
1364
|
+
// The relative form indexes \`RouteLocationAsRelativeTypedList\` directly instead of using the
|
|
1365
|
+
// \`RouteLocationAsRelativeI18n\` conditional alias so name/params narrowing works (#3962).
|
|
1351
1366
|
export type RouteLocationNamedI18n<Name extends keyof RouteMapI18n = keyof RouteMapI18n> =
|
|
1352
1367
|
| Name
|
|
1353
|
-
|
|
|
1368
|
+
| RouteLocationAsRelativeTypedList<RouteMapI18n>[Name]
|
|
1369
|
+
| RouteLocationAsPathGeneric
|
|
1354
1370
|
/**
|
|
1355
1371
|
* Note: disabled route path string autocompletion, this can break depending on \`strategy\`
|
|
1356
1372
|
* this can be enabled again after route resolve has been improved.
|
|
@@ -1362,7 +1378,9 @@ declare module 'vue-router' {
|
|
|
1362
1378
|
RouteMapGeneric extends RouteMapI18n
|
|
1363
1379
|
? RouteLocationAsStringI18n | RouteLocationAsRelativeGeneric | RouteLocationAsPathGeneric
|
|
1364
1380
|
:
|
|
1365
|
-
|
|
1381
|
+
// \`| (string & {})\` keeps autocompletion while allowing any string, the
|
|
1382
|
+
// helper type vue-router v4 exported for this no longer exists in v5
|
|
1383
|
+
| RouteLocationAsStringTypedList<RouteMapI18n>[Name] | (string & {})
|
|
1366
1384
|
| RouteLocationAsRelativeTypedList<RouteMapI18n>[Name]
|
|
1367
1385
|
|
|
1368
1386
|
export type RouteLocationResolvedI18n<Name extends keyof RouteMapI18n = keyof RouteMapI18n> =
|
|
@@ -1388,7 +1406,7 @@ declare module 'vue-router' {
|
|
|
1388
1406
|
export type RouteLocationAsStringI18n<Name extends keyof RouteMapI18n = keyof RouteMapI18n> =
|
|
1389
1407
|
RouteMapGeneric extends RouteMapI18n
|
|
1390
1408
|
? string
|
|
1391
|
-
:
|
|
1409
|
+
: RouteLocationAsStringTypedList<RouteMapI18n>[Name] | (string & {})
|
|
1392
1410
|
|
|
1393
1411
|
export type RouteLocationAsRelativeI18n<Name extends keyof RouteMapI18n = keyof RouteMapI18n> =
|
|
1394
1412
|
RouteMapGeneric extends RouteMapI18n
|
|
@@ -1552,10 +1570,10 @@ async function setupNitro(ctx, nuxt) {
|
|
|
1552
1570
|
filename: "#internal/i18n-route-resources.mjs",
|
|
1553
1571
|
getContents: () => nuxt.vfs["#build/i18n-route-resources.mjs"] || ""
|
|
1554
1572
|
});
|
|
1555
|
-
const
|
|
1573
|
+
const localeDetector = await resolveLocaleDetectorPath(ctx, nuxt);
|
|
1556
1574
|
addServerTemplate({
|
|
1557
1575
|
filename: "#internal/i18n-locale-detector.mjs",
|
|
1558
|
-
getContents: () =>
|
|
1576
|
+
getContents: () => localeDetector.exists ? `export { default as localeDetector } from ${JSON.stringify(localeDetector.path)}` : `export const localeDetector = undefined`
|
|
1559
1577
|
});
|
|
1560
1578
|
const sharedComposables = ctx.resolver.resolve("runtime/composables/shared");
|
|
1561
1579
|
addServerImports([
|
|
@@ -1576,6 +1594,12 @@ async function setupNitro(ctx, nuxt) {
|
|
|
1576
1594
|
nuxt.hook("nitro:config", async (nitroConfig) => {
|
|
1577
1595
|
nitroConfig.externals = defu(nitroConfig.externals ?? {}, { inline: [ctx.resolver.resolve("./runtime"), ...new Set(ctx.localeInfo.flatMap((x) => x.meta.map((m) => m.path)))] });
|
|
1578
1596
|
nitroConfig.alias["#i18n"] = ctx.resolver.resolve("./runtime/composables/index-server");
|
|
1597
|
+
if (localeDetector.path) {
|
|
1598
|
+
const relativeDetectorPath = relative(nuxt.options.buildDir, localeDetector.path);
|
|
1599
|
+
nuxt.options.typescript.tsConfig.exclude ||= [];
|
|
1600
|
+
nuxt.options.typescript.tsConfig.exclude.push(relativeDetectorPath);
|
|
1601
|
+
nitroConfig.typescript = defu(nitroConfig.typescript ?? {}, { tsConfig: { include: [relativeDetectorPath] } });
|
|
1602
|
+
}
|
|
1579
1603
|
nitroConfig.rollupConfig.plugins = await nitroConfig.rollupConfig.plugins || [];
|
|
1580
1604
|
nitroConfig.rollupConfig.plugins = toArray(nitroConfig.rollupConfig.plugins);
|
|
1581
1605
|
const localePathsByType = getResourcePathsGrouped(ctx.localeInfo);
|
|
@@ -1591,15 +1615,14 @@ async function setupNitro(ctx, nuxt) {
|
|
|
1591
1615
|
async function resolveLocaleDetectorPath(ctx, nuxt) {
|
|
1592
1616
|
const detector = ctx.i18nLayers.find((l) => !!l.i18nDetector)?.i18nDetector;
|
|
1593
1617
|
if (detector == null) {
|
|
1594
|
-
return "";
|
|
1618
|
+
return { path: "", exists: false };
|
|
1595
1619
|
}
|
|
1596
1620
|
const resolved = await resolvePath(detector, { cwd: nuxt.options.rootDir, extensions: EXECUTABLE_EXTENSIONS });
|
|
1597
1621
|
const exists = existsSync(resolved);
|
|
1598
1622
|
if (!exists) {
|
|
1599
1623
|
logger.warn(`localeDetector file '${resolved}' does not exist.`);
|
|
1600
|
-
return "";
|
|
1601
1624
|
}
|
|
1602
|
-
return resolved;
|
|
1625
|
+
return { path: resolved, exists };
|
|
1603
1626
|
}
|
|
1604
1627
|
function getResourcePathsGrouped(localeInfo) {
|
|
1605
1628
|
const groups = { yaml: [], json5: [] };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
2
|
import type { Locale } from 'vue-i18n';
|
|
3
3
|
import type { I18nHeadMetaInfo, I18nHeadOptions, SeoAttributesOptions } from '#internal-i18n-types';
|
|
4
|
-
import type {
|
|
4
|
+
import type { RouteLocationAsPathGeneric, RouteLocationAsRelativeTypedI18n, RouteLocationResolvedI18n, RouteMap, RouteMapI18n } from 'vue-router';
|
|
5
5
|
import type { I18nRouteMeta, RouteLocationGenericPath } from '../types.js';
|
|
6
6
|
import type { NuxtApp } from '#app';
|
|
7
7
|
export * from 'vue-i18n';
|
|
@@ -65,15 +65,13 @@ export type LocaleHeadFunction = (options: I18nHeadOptions) => I18nHeadMetaInfo;
|
|
|
65
65
|
export declare function useLocaleHead({ dir, lang, seo }?: I18nHeadOptions, nuxtApp?: NuxtApp): Ref<I18nHeadMetaInfo>;
|
|
66
66
|
/**
|
|
67
67
|
* NOTE: regarding composables accepting narrowed route arguments
|
|
68
|
-
* route path string autocompletion is disabled as this can break depending on `strategy
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
68
|
+
* route path string autocompletion is disabled as this can break depending on `strategy`,
|
|
69
|
+
* path objects stay `RouteLocationAsPathGeneric` (plain string path) for the same reason.
|
|
70
|
+
* The relative form uses the `RouteLocationAsRelativeTypedI18n` interface instead of the
|
|
71
|
+
* `RouteLocationAsRelativeI18n` conditional alias, matching vue-router's `resolve()`, so
|
|
72
|
+
* `Name` is inferred from the `name` property and name/params narrowing works (#3962).
|
|
73
73
|
*/
|
|
74
|
-
type
|
|
75
|
-
path?: string;
|
|
76
|
-
};
|
|
74
|
+
type RouteLocationI18nInput<Name extends keyof RouteMapI18n = keyof RouteMapI18n> = Name | RouteLocationAsRelativeTypedI18n<RouteMapI18n, Name> | RouteLocationAsPathGeneric;
|
|
77
75
|
/**
|
|
78
76
|
* Resolves the route base name for the given route.
|
|
79
77
|
*
|
|
@@ -100,7 +98,7 @@ export declare function useRouteBaseName(nuxtApp?: NuxtApp): RouteBaseNameFuncti
|
|
|
100
98
|
*
|
|
101
99
|
* @returns Returns the localized path for the given route.
|
|
102
100
|
*/
|
|
103
|
-
export type LocalePathFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(route: Name
|
|
101
|
+
export type LocalePathFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(route: RouteLocationI18nInput<Name>, locale?: Locale) => string;
|
|
104
102
|
/**
|
|
105
103
|
* Returns a {@link LocalePathFunction} used to resolve a localized path.
|
|
106
104
|
* @example
|
|
@@ -119,7 +117,7 @@ export declare function useLocalePath(nuxtApp?: NuxtApp): LocalePathFunction;
|
|
|
119
117
|
*
|
|
120
118
|
* @returns A route or `undefined` if no route was resolved.
|
|
121
119
|
*/
|
|
122
|
-
export type LocaleRouteFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(route: Name
|
|
120
|
+
export type LocaleRouteFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(route: RouteLocationI18nInput<Name>, locale?: Locale) => RouteLocationResolvedI18n<Name> | undefined;
|
|
123
121
|
/**
|
|
124
122
|
* Returns a {@link LocaleRouteFunction} used to resolve localized route objects.
|
|
125
123
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/i18n-edge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.4.0-
|
|
4
|
+
"version": "10.4.0-29728007.8564ea1",
|
|
5
5
|
"description": "Internationalization for Nuxt",
|
|
6
6
|
"contributors": [
|
|
7
7
|
{
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"lint:fix": "eslint . --cache --fix",
|
|
125
125
|
"lint:knip": "knip --workspace .",
|
|
126
126
|
"test": "nuxt-module-build prepare && pnpm test:types && pnpm test:unit && pnpm test:e2e",
|
|
127
|
-
"test:types": "tsc --noEmit",
|
|
127
|
+
"test:types": "tsc --noEmit && pnpm --filter './specs/fixtures/**' test:types",
|
|
128
128
|
"test:unit": "vitest run test -c vitest.config.test.ts",
|
|
129
129
|
"test:e2e": "vitest run specs"
|
|
130
130
|
}
|