nuxt-i18n-micro 1.28.0 → 1.29.1
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/c6bfb7b0-9919-40d4-b4ae-cc005b332740.json +1 -0
- package/dist/client/index.html +2 -2
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/i18n-link.vue +2 -1
- package/dist/runtime/components/i18n-switcher.vue +2 -1
- package/dist/runtime/components/i18n-t.vue +5 -4
- package/dist/runtime/components/i18n-t.vue.d.ts +1 -1
- package/dist/runtime/composables/useLocaleHead.js +1 -1
- package/dist/runtime/plugins/01.plugin.d.ts +1 -1
- package/dist/runtime/plugins/01.plugin.js +8 -11
- package/dist/runtime/plugins/03.define.js +2 -2
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -1
- package/dist/client/_nuxt/builds/meta/be20711c-09b4-4275-a779-8234f5aad9c8.json +0 -1
package/dist/client/200.html
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729513243724,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"c6bfb7b0-9919-40d4-b4ae-cc005b332740",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-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729513243724,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"c6bfb7b0-9919-40d4-b4ae-cc005b332740",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"c6bfb7b0-9919-40d4-b4ae-cc005b332740","timestamp":1729513225644}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"c6bfb7b0-9919-40d4-b4ae-cc005b332740","timestamp":1729513225644,"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-i18n-micro/_nuxt/0GmYR_kR.js">
|
|
9
9
|
<link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.CBAEdpZV.css">
|
|
10
10
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/2C6ahHCU.js">
|
|
11
|
-
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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-i18n-micro",buildId:"
|
|
11
|
+
<script type="module" src="/__nuxt-i18n-micro/_nuxt/Czi4MokJ.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},1729513243725,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"c6bfb7b0-9919-40d4-b4ae-cc005b332740",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import type { RouteLocationRaw } from 'vue-router'
|
|
12
|
+
import type { PluginsInjections } from '../../runtime/plugins/01.plugin'
|
|
12
13
|
import { useNuxtApp, computed, useRoute, useRouter } from '#imports'
|
|
13
14
|
|
|
14
|
-
const { $localeRoute } = useNuxtApp()
|
|
15
|
+
const { $localeRoute } = useNuxtApp().$i18n as PluginsInjections
|
|
15
16
|
|
|
16
17
|
interface Props {
|
|
17
18
|
to: RouteLocationRaw | string
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
import { ref, computed } from 'vue'
|
|
41
41
|
import type { CSSProperties } from 'vue'
|
|
42
42
|
import type { Locale } from '../../types'
|
|
43
|
+
import type { PluginsInjections } from '../../runtime/plugins/01.plugin'
|
|
43
44
|
import { useNuxtApp } from '#app'
|
|
44
45
|
import { useRoute } from '#imports'
|
|
45
46
|
|
|
@@ -67,7 +68,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
67
68
|
customIconStyle: () => ({}),
|
|
68
69
|
})
|
|
69
70
|
|
|
70
|
-
const { $localeRoute, $getLocales, $getLocale, $getLocaleName } = useNuxtApp()
|
|
71
|
+
const { $localeRoute, $getLocales, $getLocale, $getLocaleName } = useNuxtApp().$i18n as PluginsInjections
|
|
71
72
|
const locales = ref($getLocales())
|
|
72
73
|
const currentLocale = computed(() => $getLocale())
|
|
73
74
|
const currentLocaleName = computed(() => $getLocaleName())
|
|
@@ -39,19 +39,20 @@ export default defineComponent({
|
|
|
39
39
|
setup(props, { slots, attrs }) {
|
|
40
40
|
return () => {
|
|
41
41
|
const options = {};
|
|
42
|
+
const { $getLocale, $t, $tc } = useNuxtApp().$i18n;
|
|
42
43
|
if (props.plural !== void 0) {
|
|
43
44
|
if (props.customPluralRule) {
|
|
44
45
|
return h(props.tag, { ...attrs, innerHTML: props.customPluralRule(
|
|
45
46
|
props.keypath,
|
|
46
47
|
Number.parseInt(props.plural.toString()),
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
$getLocale(),
|
|
49
|
+
$t
|
|
49
50
|
) });
|
|
50
51
|
} else {
|
|
51
|
-
return h(props.tag, { ...attrs, innerHTML:
|
|
52
|
+
return h(props.tag, { ...attrs, innerHTML: $tc(props.keypath, Number.parseInt(props.plural.toString())) });
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
|
-
const translation = (
|
|
55
|
+
const translation = ($t(props.keypath, { ...props.params, ...options }) ?? "").toString();
|
|
55
56
|
if (props.hideIfEmpty && !translation.trim()) {
|
|
56
57
|
return props.defaultValue ?? null;
|
|
57
58
|
}
|
|
@@ -67,8 +67,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
67
67
|
default: null;
|
|
68
68
|
};
|
|
69
69
|
}>> & Readonly<{}>, {
|
|
70
|
-
tag: string;
|
|
71
70
|
params: Record<string, string | number | boolean>;
|
|
71
|
+
tag: string;
|
|
72
72
|
defaultValue: string;
|
|
73
73
|
html: boolean;
|
|
74
74
|
hideIfEmpty: boolean;
|
|
@@ -8,7 +8,7 @@ export const useLocaleHead = ({ addDirAttribute = true, identifierAttribute = "i
|
|
|
8
8
|
});
|
|
9
9
|
function updateMeta() {
|
|
10
10
|
const { defaultLocale, includeDefaultLocaleRoute } = useRuntimeConfig().public.i18nConfig;
|
|
11
|
-
const { $getLocales, $getLocale } = useNuxtApp();
|
|
11
|
+
const { $getLocales, $getLocale } = useNuxtApp().$i18n;
|
|
12
12
|
const route = useRoute();
|
|
13
13
|
const locale = unref($getLocale());
|
|
14
14
|
const routeName = (route.name ?? "").toString();
|
|
@@ -57,7 +57,7 @@ declare const _default: import("#app").Plugin<{
|
|
|
57
57
|
export default _default;
|
|
58
58
|
export interface PluginsInjections {
|
|
59
59
|
$getLocale: () => string;
|
|
60
|
-
$getLocaleName: () => string;
|
|
60
|
+
$getLocaleName: () => string | null;
|
|
61
61
|
$getLocales: () => Locale[];
|
|
62
62
|
$defaultLocale: () => string | undefined;
|
|
63
63
|
$getRouteName: (route?: RouteLocationNormalizedLoaded | RouteLocationResolvedGeneric, locale?: string) => string;
|
|
@@ -17,18 +17,12 @@ function getCurrentLocale(route, i18nConfig, hashLocale) {
|
|
|
17
17
|
return (route.params?.locale ?? i18nConfig.defaultLocale).toString();
|
|
18
18
|
}
|
|
19
19
|
function getCurrentName(route, i18nConfig, hashLocale) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} else if (route.params?.locale) {
|
|
24
|
-
currentLocale = (route.params?.locale ?? i18nConfig.defaultLocale).toString();
|
|
25
|
-
}
|
|
26
|
-
const checkLocale = i18nConfig.locales?.find((l) => l.code === currentLocale);
|
|
27
|
-
if (!checkLocale || !checkLocale.displayName) {
|
|
28
|
-
console.warn(`current locale name not found`);
|
|
20
|
+
const currentLocaleCode = getCurrentLocale(route, i18nConfig, hashLocale);
|
|
21
|
+
const checkLocale = i18nConfig.locales?.find((l) => l.code === currentLocaleCode);
|
|
22
|
+
if (!checkLocale) {
|
|
29
23
|
return null;
|
|
30
24
|
}
|
|
31
|
-
return checkLocale
|
|
25
|
+
return checkLocale?.displayName ?? null;
|
|
32
26
|
}
|
|
33
27
|
function getRouteName(route, locale) {
|
|
34
28
|
return (route?.name ?? "").toString().replace("localized-", "").replace(new RegExp(`-${locale}$`), "");
|
|
@@ -296,7 +290,10 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
296
290
|
return i18nRouteParams.value;
|
|
297
291
|
}
|
|
298
292
|
};
|
|
299
|
-
provideData
|
|
293
|
+
const $provideData = Object.fromEntries(
|
|
294
|
+
Object.entries(provideData).map(([key, value]) => [`$${key}`, value])
|
|
295
|
+
);
|
|
296
|
+
provideData.i18n = { ...provideData, ...$provideData };
|
|
300
297
|
return {
|
|
301
298
|
provide: provideData
|
|
302
299
|
};
|
|
@@ -53,8 +53,8 @@ export default defineNuxtPlugin(async (_nuxtApp) => {
|
|
|
53
53
|
if (Object.values(normalizedLocales).length) {
|
|
54
54
|
if (normalizedLocales[currentLocale]) {
|
|
55
55
|
const translation = normalizedLocales[currentLocale];
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const { $mergeTranslations } = useNuxtApp().$i18n;
|
|
57
|
+
$mergeTranslations(translation);
|
|
58
58
|
}
|
|
59
59
|
if (!normalizedLocales[currentLocale]) {
|
|
60
60
|
let defaultRouteName = route.name?.toString().replace("localized-", "").replace(new RegExp(`-${currentLocale}$`), "");
|
package/dist/types.d.mts
CHANGED
|
@@ -4,4 +4,4 @@ declare module '@nuxt/schema' {
|
|
|
4
4
|
interface NuxtHooks extends ModuleHooks {}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export { type
|
|
7
|
+
export { type PluginsInjections } from './module.js'
|
package/dist/types.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ declare module '@nuxt/schema' {
|
|
|
4
4
|
interface NuxtHooks extends ModuleHooks {}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export { type
|
|
7
|
+
export { type PluginsInjections } from './module'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.1",
|
|
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",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"client:build": "nuxi generate client",
|
|
54
54
|
"client:dev": "nuxi dev client --port 3300",
|
|
55
55
|
"typecheck": "tsc --noEmit",
|
|
56
|
+
"typecheck:nuxt": "nuxt typecheck --no-emit",
|
|
56
57
|
"docs:dev": "vitepress dev docs",
|
|
57
58
|
"docs:build": "vitepress build docs",
|
|
58
59
|
"docs:serve": "vitepress serve docs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"be20711c-09b4-4275-a779-8234f5aad9c8","timestamp":1729325910015,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|