nuxt-i18n-micro 2.9.0 → 2.11.0
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/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/7323731f-46c9-4bc3-8e1d-f2e545f99ff5.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -1
- package/dist/runtime/composables/useI18n.js +2 -1
- package/dist/runtime/plugins/01.plugin.d.ts +4 -1
- package/dist/runtime/plugins/01.plugin.js +17 -2
- package/package.json +33 -31
- package/dist/client/_nuxt/builds/meta/28855ae3-f2e0-4884-ad15-5b88d7bdb030.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1763644598605,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"7323731f-46c9-4bc3-8e1d-f2e545f99ff5",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1763644598605,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"7323731f-46c9-4bc3-8e1d-f2e545f99ff5",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"7323731f-46c9-4bc3-8e1d-f2e545f99ff5","timestamp":1763644592721}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"7323731f-46c9-4bc3-8e1d-f2e545f99ff5","timestamp":1763644592721,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBxwnKtU.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.BqKd8Zt-.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/BYEpoBUk.js">
|
|
11
|
-
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/XZXfxmri.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1763644598606,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"7323731f-46c9-4bc3-8e1d-f2e545f99ff5",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -844,7 +844,8 @@ const module = defineNuxtModule({
|
|
|
844
844
|
return selectedForm.trim().replace("{count}", count.toString());
|
|
845
845
|
},
|
|
846
846
|
customRegexMatcher: void 0,
|
|
847
|
-
excludePatterns: void 0
|
|
847
|
+
excludePatterns: void 0,
|
|
848
|
+
missingWarn: true
|
|
848
849
|
},
|
|
849
850
|
async setup(options, nuxt) {
|
|
850
851
|
const defaultLocale = process.env.DEFAULT_LOCALE ?? options.defaultLocale ?? "en";
|
|
@@ -937,6 +938,7 @@ const module = defineNuxtModule({
|
|
|
937
938
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
938
939
|
// @ts-ignore
|
|
939
940
|
globalLocaleRoutes: mergedGlobalLocaleRoutes,
|
|
941
|
+
missingWarn: options.missingWarn ?? true,
|
|
940
942
|
experimental: {
|
|
941
943
|
i18nPreviousPageFallback: options.experimental?.i18nPreviousPageFallback ?? false,
|
|
942
944
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -23,7 +23,8 @@ export function useI18n() {
|
|
|
23
23
|
$switchRoute: nuxtApp.$switchRoute,
|
|
24
24
|
$localeRoute: nuxtApp.$localeRoute,
|
|
25
25
|
$localePath: nuxtApp.$localePath,
|
|
26
|
-
$loadPageTranslations: nuxtApp.$loadPageTranslations
|
|
26
|
+
$loadPageTranslations: nuxtApp.$loadPageTranslations,
|
|
27
|
+
$setMissingHandler: nuxtApp.$setMissingHandler
|
|
27
28
|
};
|
|
28
29
|
const noDollarInjections = Object.fromEntries(
|
|
29
30
|
Object.entries(injections).map(([key, value]) => [key.slice(1), value])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouteLocationNormalizedLoaded, RouteLocationRaw, RouteLocationResolved, RouteLocationResolvedGeneric, RouteLocationNamedRaw } from 'vue-router';
|
|
2
2
|
import { useTranslationHelper } from 'nuxt-i18n-micro-core';
|
|
3
|
-
import type { Locale, I18nRouteParams, Params, Translations, CleanTranslation } from 'nuxt-i18n-micro-types';
|
|
3
|
+
import type { Locale, I18nRouteParams, Params, Translations, CleanTranslation, MissingHandler } from 'nuxt-i18n-micro-types';
|
|
4
4
|
declare const _default: import("nuxt/app").Plugin<{
|
|
5
5
|
i18n: undefined;
|
|
6
6
|
__micro: boolean;
|
|
@@ -29,6 +29,7 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
29
29
|
localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
30
30
|
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
31
31
|
loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
|
|
32
|
+
setMissingHandler: (handler: MissingHandler | null) => void;
|
|
32
33
|
helper: {
|
|
33
34
|
hasCache(locale: string, page: string): boolean;
|
|
34
35
|
getCache(locale: string, routeName: string): Map<string, unknown> | undefined;
|
|
@@ -71,6 +72,7 @@ declare const _default: import("nuxt/app").Plugin<{
|
|
|
71
72
|
localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
72
73
|
setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
73
74
|
loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
|
|
75
|
+
setMissingHandler: (handler: MissingHandler | null) => void;
|
|
74
76
|
helper: {
|
|
75
77
|
hasCache(locale: string, page: string): boolean;
|
|
76
78
|
getCache(locale: string, routeName: string): Map<string, unknown> | undefined;
|
|
@@ -112,5 +114,6 @@ export interface PluginsInjections {
|
|
|
112
114
|
$localePath: (to: RouteLocationNamedRaw | RouteLocationResolvedGeneric | string, locale?: string) => string;
|
|
113
115
|
$setI18nRouteParams: (value: I18nRouteParams) => I18nRouteParams;
|
|
114
116
|
$loadPageTranslations: (locale: string, routeName: string, translations: Translations) => Promise<void>;
|
|
117
|
+
$setMissingHandler: (handler: MissingHandler | null) => void;
|
|
115
118
|
helper: ReturnType<typeof useTranslationHelper>;
|
|
116
119
|
}
|
|
@@ -24,12 +24,18 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
24
24
|
const i18nHelper = useTranslationHelper(translationCaches);
|
|
25
25
|
let hashLocaleDefault = null;
|
|
26
26
|
let noPrefixDefault = null;
|
|
27
|
+
let cookieLocaleDefault = null;
|
|
27
28
|
if (i18nConfig.hashMode) {
|
|
28
29
|
hashLocaleDefault = await nuxtApp.runWithContext(() => useCookie("hash-locale").value);
|
|
29
30
|
}
|
|
30
31
|
if (isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
31
32
|
noPrefixDefault = await nuxtApp.runWithContext(() => useCookie("no-prefix-locale").value);
|
|
32
33
|
}
|
|
34
|
+
let cookieLocaleName = null;
|
|
35
|
+
if (!i18nConfig.hashMode && !isNoPrefixStrategy(i18nConfig.strategy)) {
|
|
36
|
+
cookieLocaleName = i18nConfig.localeCookie || "user-locale";
|
|
37
|
+
cookieLocaleDefault = await nuxtApp.runWithContext(() => useCookie(cookieLocaleName).value);
|
|
38
|
+
}
|
|
33
39
|
const routeService = new RouteService(
|
|
34
40
|
i18nConfig,
|
|
35
41
|
router,
|
|
@@ -40,12 +46,16 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
40
46
|
nuxtApp.runWithContext(() => {
|
|
41
47
|
return useCookie(name).value = value;
|
|
42
48
|
});
|
|
43
|
-
}
|
|
49
|
+
},
|
|
50
|
+
cookieLocaleDefault,
|
|
51
|
+
cookieLocaleName
|
|
44
52
|
);
|
|
45
53
|
const translationService = new FormatService();
|
|
46
54
|
const i18nRouteParams = useState("i18n-route-params", () => ({}));
|
|
47
55
|
const previousPageInfo = useState("i18n-previous-page", () => null);
|
|
48
56
|
const enablePreviousPageFallback = i18nConfig.experimental?.i18nPreviousPageFallback ?? false;
|
|
57
|
+
const missingWarn = i18nConfig.missingWarn ?? true;
|
|
58
|
+
const customMissingHandler = useState("i18n-missing-handler", () => null);
|
|
49
59
|
nuxtApp.hook("page:finish", () => {
|
|
50
60
|
if (import.meta.client) {
|
|
51
61
|
previousPageInfo.value = null;
|
|
@@ -134,7 +144,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
if (!value) {
|
|
137
|
-
if (
|
|
147
|
+
if (customMissingHandler.value) {
|
|
148
|
+
customMissingHandler.value(locale, key, routeName);
|
|
149
|
+
} else if (missingWarn && isDev && import.meta.client) {
|
|
138
150
|
console.warn(`Not found '${key}' key in '${locale}' locale messages for route '${routeName}'.`);
|
|
139
151
|
}
|
|
140
152
|
value = defaultValue === void 0 ? key : defaultValue;
|
|
@@ -240,6 +252,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
240
252
|
loadPageTranslations: async (locale, routeName, translations) => {
|
|
241
253
|
await i18nHelper.loadPageTranslations(locale, routeName, translations);
|
|
242
254
|
},
|
|
255
|
+
setMissingHandler: (handler) => {
|
|
256
|
+
customMissingHandler.value = handler;
|
|
257
|
+
},
|
|
243
258
|
helper: i18nHelper
|
|
244
259
|
// Оставляем helper, он может быть полезен для продвинутых пользователей
|
|
245
260
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.",
|
|
5
5
|
"repository": "s00d/nuxt-i18n-micro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,6 +48,32 @@
|
|
|
48
48
|
"dist",
|
|
49
49
|
"internals.d.mts"
|
|
50
50
|
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"prepack": "pnpm --filter \"./packages/**\" run build && nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && pnpm run client:build",
|
|
53
|
+
"dev": "nuxi dev playground",
|
|
54
|
+
"dev:build": "nuxi build playground",
|
|
55
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
56
|
+
"dev:generate": "nuxi generate playground",
|
|
57
|
+
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:vitest && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
58
|
+
"lint": "eslint .",
|
|
59
|
+
"lint:fix": "eslint . --fix",
|
|
60
|
+
"test": "playwright test",
|
|
61
|
+
"test:vitest": "vitest run",
|
|
62
|
+
"test:watch": "vitest watch",
|
|
63
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
64
|
+
"test:workspaces": "pnpm recursive run test",
|
|
65
|
+
"client:build": "nuxi generate client",
|
|
66
|
+
"client:prepare": "nuxi client:prepare client",
|
|
67
|
+
"client:dev": "nuxi dev client --port 3300",
|
|
68
|
+
"clean": "find . \\( -name 'node_modules' -o -name '.nuxt' -o -name '.output' -o -name 'dist' \\) -type d -prune -exec rm -rf '{}' + && find . \\( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \\) -type f -exec rm -f '{}' +",
|
|
69
|
+
"typecheck": "tsc --noEmit",
|
|
70
|
+
"typecheck:nuxt": "nuxt typecheck --no-emit",
|
|
71
|
+
"docs:dev": "vitepress dev docs",
|
|
72
|
+
"docs:build": "vitepress build docs",
|
|
73
|
+
"docs:serve": "vitepress serve docs",
|
|
74
|
+
"docs:clean-dev": "vitepress dev docs --clean-cache",
|
|
75
|
+
"docs:preview": "vitepress preview docs"
|
|
76
|
+
},
|
|
51
77
|
"stackblitz": {
|
|
52
78
|
"startCommand": "pnpm install && pnpm --filter \"./packages/**\" run build && pnpm run dev:prepare && pnpm run dev",
|
|
53
79
|
"env": {
|
|
@@ -59,11 +85,11 @@
|
|
|
59
85
|
"@nuxt/kit": "^3.18.1 || ^4.0.0",
|
|
60
86
|
"chokidar": "^3.6.0",
|
|
61
87
|
"globby": "^14.1.0",
|
|
88
|
+
"nuxt-i18n-micro-core": "workspace:*",
|
|
89
|
+
"nuxt-i18n-micro-test-utils": "workspace:*",
|
|
90
|
+
"nuxt-i18n-micro-types": "workspace:*",
|
|
62
91
|
"sirv": "^2.0.4",
|
|
63
|
-
"ufo": "^1.5.4"
|
|
64
|
-
"nuxt-i18n-micro-core": "1.0.24",
|
|
65
|
-
"nuxt-i18n-micro-types": "1.0.14",
|
|
66
|
-
"nuxt-i18n-micro-test-utils": "1.0.7"
|
|
92
|
+
"ufo": "^1.5.4"
|
|
67
93
|
},
|
|
68
94
|
"devDependencies": {
|
|
69
95
|
"@nuxt/devtools": "^2.6.3",
|
|
@@ -95,29 +121,5 @@
|
|
|
95
121
|
"client",
|
|
96
122
|
"test/fixtures/**/*"
|
|
97
123
|
],
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
"dev:build": "nuxi build playground",
|
|
101
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
102
|
-
"dev:generate": "nuxi generate playground",
|
|
103
|
-
"release": "pnpm run lint && pnpm run typecheck && pnpm run test:types && pnpm run test && pnpm run test:vitest && pnpm run test:workspaces && pnpm run prepack && changelogen --release && pnpm publish -r && git push --follow-tags",
|
|
104
|
-
"lint": "eslint .",
|
|
105
|
-
"lint:fix": "eslint . --fix",
|
|
106
|
-
"test": "playwright test",
|
|
107
|
-
"test:vitest": "vitest run",
|
|
108
|
-
"test:watch": "vitest watch",
|
|
109
|
-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
110
|
-
"test:workspaces": "pnpm recursive run test",
|
|
111
|
-
"client:build": "nuxi generate client",
|
|
112
|
-
"client:prepare": "nuxi client:prepare client",
|
|
113
|
-
"client:dev": "nuxi dev client --port 3300",
|
|
114
|
-
"clean": "find . \\( -name 'node_modules' -o -name '.nuxt' -o -name '.output' -o -name 'dist' \\) -type d -prune -exec rm -rf '{}' + && find . \\( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \\) -type f -exec rm -f '{}' +",
|
|
115
|
-
"typecheck": "tsc --noEmit",
|
|
116
|
-
"typecheck:nuxt": "nuxt typecheck --no-emit",
|
|
117
|
-
"docs:dev": "vitepress dev docs",
|
|
118
|
-
"docs:build": "vitepress build docs",
|
|
119
|
-
"docs:serve": "vitepress serve docs",
|
|
120
|
-
"docs:clean-dev": "vitepress dev docs --clean-cache",
|
|
121
|
-
"docs:preview": "vitepress preview docs"
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
+
"packageManager": "pnpm@9.14.2"
|
|
125
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"28855ae3-f2e0-4884-ad15-5b88d7bdb030","timestamp":1763478933376,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|