nuxt-i18n-micro 1.13.3 → 1.14.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 +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/cef9112f-2f86-40b3-9815-286383780fe2.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/components/i18n-switcher.vue +3 -0
- package/dist/runtime/plugins/01.plugin.js +5 -6
- package/dist/runtime/translationHelper.d.ts +2 -2
- package/dist/runtime/translationHelper.js +4 -4
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/5ea89697-ba72-411f-a61a-8d8be203f3a9.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"cef9112f-2f86-40b3-9815-286383780fe2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"cef9112f-2f86-40b3-9815-286383780fe2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"cef9112f-2f86-40b3-9815-286383780fe2","timestamp":1725543893300}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"cef9112f-2f86-40b3-9815-286383780fe2","timestamp":1725543893300,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.21ZDxC33.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/DzdJBprQ.js">
|
|
11
11
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/D1fvHJQV.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__">[{"serverRendered":1},false]</script>
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"cef9112f-2f86-40b3-9815-286383780fe2",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
|
@@ -35,7 +35,7 @@ interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
|
35
35
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
36
36
|
|
|
37
37
|
interface ModuleHooks {
|
|
38
|
-
'i18n:register': (registerModule: (translations: unknown, locale
|
|
38
|
+
'i18n:register': (registerModule: (translations: unknown, locale?: string) => void, locale: string) => HookResult;
|
|
39
39
|
}
|
|
40
40
|
declare module '@nuxt/schema' {
|
|
41
41
|
interface ConfigSchema {
|
package/dist/module.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
|
35
35
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
36
36
|
|
|
37
37
|
interface ModuleHooks {
|
|
38
|
-
'i18n:register': (registerModule: (translations: unknown, locale
|
|
38
|
+
'i18n:register': (registerModule: (translations: unknown, locale?: string) => void, locale: string) => HookResult;
|
|
39
39
|
}
|
|
40
40
|
declare module '@nuxt/schema' {
|
|
41
41
|
interface ConfigSchema {
|
package/dist/module.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :style="[wrapperStyle, customWrapperStyle]">
|
|
3
3
|
<button
|
|
4
|
+
class="language-switcher"
|
|
4
5
|
:style="[buttonStyle, customButtonStyle]"
|
|
5
6
|
@click="toggleDropdown"
|
|
6
7
|
>
|
|
@@ -17,9 +18,11 @@
|
|
|
17
18
|
:style="[itemStyle, customItemStyle]"
|
|
18
19
|
>
|
|
19
20
|
<NuxtLink
|
|
21
|
+
:class="`switcher-locale-${locale.code}`"
|
|
20
22
|
:to="getLocaleLink(locale)"
|
|
21
23
|
:style="[linkStyle, locale.code === currentLocale ? activeLinkStyle : {}, locale.code === currentLocale ? disabledLinkStyle : {}, customLinkStyle]"
|
|
22
24
|
:hreflang="locale.iso || locale.code"
|
|
25
|
+
@click="toggleDropdown"
|
|
23
26
|
>
|
|
24
27
|
{{ localeLabel(locale) }}
|
|
25
28
|
</NuxtLink>
|
|
@@ -72,10 +72,6 @@ function formatDate(value, locale, options) {
|
|
|
72
72
|
return new Intl.DateTimeFormat(locale, options).format(new Date(value));
|
|
73
73
|
}
|
|
74
74
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
75
|
-
const registerI18nModule = (translations, locale) => {
|
|
76
|
-
i18nHelper.mergeGlobalTranslation(locale, translations);
|
|
77
|
-
};
|
|
78
|
-
await nuxtApp.callHook("i18n:register", registerI18nModule);
|
|
79
75
|
if (!nuxtApp.payload.data.translations) {
|
|
80
76
|
nuxtApp.payload.data.translations = {};
|
|
81
77
|
}
|
|
@@ -104,16 +100,19 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
104
100
|
await loadTranslationsIfNeeded(locale, initialRouteName);
|
|
105
101
|
}
|
|
106
102
|
useRouter().beforeEach(async (to, from, next) => {
|
|
103
|
+
const locale = getCurrentLocale(to, i18nConfig);
|
|
107
104
|
if (import.meta.client) {
|
|
108
|
-
const locale = getCurrentLocale(to, i18nConfig);
|
|
109
105
|
const data = await $fetch(`/_locales/general/${locale}/data.json?v=${i18nConfig.dateBuild}`, { baseURL: i18nConfig.baseURL });
|
|
110
106
|
await i18nHelper.loadTranslations(locale, data ?? {});
|
|
111
107
|
}
|
|
112
108
|
if (import.meta.client && !i18nConfig.disablePageLocales) {
|
|
113
|
-
const locale = getCurrentLocale(to, i18nConfig);
|
|
114
109
|
const routeName = getRouteName(to, locale);
|
|
115
110
|
await loadTranslationsIfNeeded(locale, routeName);
|
|
116
111
|
}
|
|
112
|
+
await nuxtApp.callHook("i18n:register", (translations, selectedLocale) => {
|
|
113
|
+
const routeName = getRouteName(to, locale);
|
|
114
|
+
i18nHelper.mergeTranslation(selectedLocale ?? locale, routeName, translations, true);
|
|
115
|
+
}, locale);
|
|
117
116
|
next();
|
|
118
117
|
});
|
|
119
118
|
const getTranslation = (key, params, defaultValue) => {
|
|
@@ -3,8 +3,8 @@ export declare function useTranslationHelper(): {
|
|
|
3
3
|
hasCache(locale: string, page: string): boolean;
|
|
4
4
|
getCache(locale: string, routeName: string): Map<string, unknown>;
|
|
5
5
|
setCache(locale: string, routeName: string, cache: Map<string, Translations | unknown>): void;
|
|
6
|
-
mergeTranslation(locale: string, routeName: string, newTranslations: Translations): void;
|
|
7
|
-
mergeGlobalTranslation(locale: string, newTranslations: Translations): void;
|
|
6
|
+
mergeTranslation(locale: string, routeName: string, newTranslations: Translations, force?: boolean): void;
|
|
7
|
+
mergeGlobalTranslation(locale: string, newTranslations: Translations, force?: boolean): void;
|
|
8
8
|
hasGeneralTranslation(locale: string): boolean;
|
|
9
9
|
hasPageTranslation(locale: string, routeName: string): boolean;
|
|
10
10
|
getTranslation: <T = unknown>(locale: string, routeName: string, key: string) => T | null;
|
|
@@ -39,8 +39,8 @@ export function useTranslationHelper() {
|
|
|
39
39
|
serverTranslationInit[`${locale}:index`] = true;
|
|
40
40
|
serverTranslationInit[cacheKey] = true;
|
|
41
41
|
},
|
|
42
|
-
mergeTranslation(locale, routeName, newTranslations) {
|
|
43
|
-
if (!routeLocaleCache[`${locale}:${routeName}`]) {
|
|
42
|
+
mergeTranslation(locale, routeName, newTranslations, force = false) {
|
|
43
|
+
if (!force && !routeLocaleCache[`${locale}:${routeName}`]) {
|
|
44
44
|
console.error(`marge: route ${locale}:${routeName} not loaded`);
|
|
45
45
|
}
|
|
46
46
|
routeLocaleCache[`${locale}:${routeName}`] = {
|
|
@@ -48,8 +48,8 @@ export function useTranslationHelper() {
|
|
|
48
48
|
...newTranslations
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
|
-
mergeGlobalTranslation(locale, newTranslations) {
|
|
52
|
-
if (!generalLocaleCache[`${locale}`]) {
|
|
51
|
+
mergeGlobalTranslation(locale, newTranslations, force = false) {
|
|
52
|
+
if (!force && !generalLocaleCache[`${locale}`]) {
|
|
53
53
|
console.error(`marge: route ${locale} not loaded`);
|
|
54
54
|
}
|
|
55
55
|
generalLocaleCache[locale] = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"5ea89697-ba72-411f-a61a-8d8be203f3a9","timestamp":1725472070372,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|