nuxt-i18n-micro 1.1.4 → 1.1.6
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/README.md +21 -2
- 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/dae24a88-5573-405d-9c95-67ec6422e7cd.json +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/01.plugin.d.ts +1 -1
- package/dist/runtime/composables/useI18n.d.ts +2 -0
- package/dist/runtime/composables/useI18n.js +14 -0
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/8cae28bb-c853-4f0b-a682-e12f6c86c094.json +0 -1
package/README.md
CHANGED
|
@@ -176,6 +176,25 @@ $mergeTranslations({
|
|
|
176
176
|
})
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
## useNuxtApp
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { useNuxtApp } from '#imports'
|
|
183
|
+
|
|
184
|
+
const { $getLocale, $switchLocale, $getLocales, $localeRoute, $t } = useNuxtApp()
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Composable
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import { useI18n } from '#imports'
|
|
191
|
+
|
|
192
|
+
const { $getLocale, $switchLocale, $getLocales, $localeRoute, $t } = useI18n()
|
|
193
|
+
// or
|
|
194
|
+
const i18n = useI18n()
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
|
|
179
198
|
## Example
|
|
180
199
|
|
|
181
200
|
```vue
|
|
@@ -212,9 +231,9 @@ $mergeTranslations({
|
|
|
212
231
|
</template>
|
|
213
232
|
|
|
214
233
|
<script setup>
|
|
215
|
-
import {
|
|
234
|
+
import { useI18n } from '#imports'
|
|
216
235
|
|
|
217
|
-
const { $getLocale, $switchLocale, $getLocales, $localeRoute, $t, $tc } =
|
|
236
|
+
const { $getLocale, $switchLocale, $getLocales, $localeRoute, $t, $tc } = useI18n()
|
|
218
237
|
</script>
|
|
219
238
|
|
|
220
239
|
```
|
package/dist/client/200.html
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.B4KzowuE.css">
|
|
9
9
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/HZLiFEh-.js">
|
|
10
10
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/6EJ4fAZ2.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"dae24a88-5573-405d-9c95-67ec6422e7cd",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/client/404.html
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.B4KzowuE.css">
|
|
9
9
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/HZLiFEh-.js">
|
|
10
10
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/6EJ4fAZ2.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"dae24a88-5573-405d-9c95-67ec6422e7cd",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"id":"
|
|
1
|
+
{"id":"dae24a88-5573-405d-9c95-67ec6422e7cd","timestamp":1723891230132}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"id":"dae24a88-5573-405d-9c95-67ec6422e7cd","timestamp":1723891230132,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|
package/dist/client/index.html
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
<link rel="prefetch" as="style" href="/__nuxt-i18n-micro/_nuxt/error-500.B4KzowuE.css">
|
|
9
9
|
<link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/HZLiFEh-.js">
|
|
10
10
|
<script type="module" src="/__nuxt-i18n-micro/_nuxt/6EJ4fAZ2.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"serverRendered":1},false]</script>
|
|
11
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"
|
|
11
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"dae24a88-5573-405d-9c95-67ec6422e7cd",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { useNuxt, defineNuxtModule, createResolver, addPlugin, addServerHandler, extendPages } from '@nuxt/kit';
|
|
4
|
+
import { useNuxt, defineNuxtModule, createResolver, addPlugin, addImportsDir, addServerHandler, extendPages } from '@nuxt/kit';
|
|
5
5
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
6
6
|
|
|
7
7
|
const DEVTOOLS_UI_PORT = 3030;
|
|
@@ -121,6 +121,7 @@ const module = defineNuxtModule({
|
|
|
121
121
|
order: 3
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
124
125
|
if (options.includeDefaultLocaleRoute) {
|
|
125
126
|
addServerHandler({
|
|
126
127
|
middleware: true,
|
|
@@ -24,7 +24,7 @@ declare const _default: import("#app").Plugin<{
|
|
|
24
24
|
localeRoute: (to: RouteLocationRaw, locale?: string) => RouteLocationRaw;
|
|
25
25
|
}>;
|
|
26
26
|
export default _default;
|
|
27
|
-
interface PluginsInjections {
|
|
27
|
+
export interface PluginsInjections {
|
|
28
28
|
$getLocale: () => string;
|
|
29
29
|
$getLocales: () => string[];
|
|
30
30
|
$t: <T extends Record<string, string | number | boolean>>(key: string, params?: T, defaultValue?: string) => string | number | boolean | Translations | PluralTranslations | unknown[] | unknown | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useNuxtApp } from "#imports";
|
|
2
|
+
export function useI18n() {
|
|
3
|
+
const nuxtApp = useNuxtApp();
|
|
4
|
+
return {
|
|
5
|
+
$getLocale: nuxtApp.$getLocale,
|
|
6
|
+
$getLocales: nuxtApp.$getLocales,
|
|
7
|
+
$t: nuxtApp.$t,
|
|
8
|
+
$tc: nuxtApp.$tc,
|
|
9
|
+
$mergeTranslations: nuxtApp.$mergeTranslations,
|
|
10
|
+
$switchLocale: nuxtApp.$switchLocale,
|
|
11
|
+
$localeRoute: nuxtApp.$localeRoute,
|
|
12
|
+
$loadPageTranslations: nuxtApp.$loadPageTranslations
|
|
13
|
+
};
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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":"8cae28bb-c853-4f0b-a682-e12f6c86c094","timestamp":1723888233762,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|