nuxt-i18n-micro 1.36.0 → 1.37.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 +10 -10
- package/dist/client/404.html +10 -10
- package/dist/client/_nuxt/{B1xCwjDF.js → CBccCxXK.js} +1 -1
- package/dist/client/_nuxt/{CzPI1GQJ.js → DNen4El9.js} +1 -1
- package/dist/client/_nuxt/{DsNZE4Dc.js → Ltm7XuUs.js} +1 -1
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/d48170a8-5b86-44b8-8103-1aa6250c5f55.json +1 -0
- package/dist/client/_nuxt/n4MbYZHF.js +3822 -0
- package/dist/client/index.html +10 -10
- package/dist/module.json +1 -1
- package/dist/module.mjs +31 -16
- package/dist/runtime/translation-server-middleware.d.ts +1 -1
- package/dist/runtime/translation-server-middleware.js +1 -2
- package/internals.d.ts +0 -4
- package/package.json +1 -1
- package/dist/client/_nuxt/builds/meta/166e9332-75a4-41da-96ec-b2e17e8c07d9.json +0 -1
- package/dist/client/_nuxt/fYVA_EiS.js +0 -3822
package/dist/client/index.html
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
|
|
2
2
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
-
<link rel="stylesheet" href="/
|
|
4
|
-
<link rel="modulepreload" as="script" crossorigin href="/
|
|
5
|
-
<link rel="prefetch" as="script" crossorigin href="/
|
|
6
|
-
<link rel="prefetch" as="style" crossorigin href="/
|
|
7
|
-
<link rel="prefetch" as="script" crossorigin href="/
|
|
8
|
-
<link rel="prefetch" as="script" crossorigin href="/
|
|
9
|
-
<link rel="prefetch" as="style" crossorigin href="/
|
|
10
|
-
<link rel="prefetch" as="script" crossorigin href="/
|
|
11
|
-
<script type="module" src="/
|
|
12
|
-
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/
|
|
3
|
+
<link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.BWujgj23.css" crossorigin>
|
|
4
|
+
<link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/n4MbYZHF.js">
|
|
5
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/B6E6ObS_.js">
|
|
6
|
+
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.SWzu_puR.css">
|
|
7
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Ltm7XuUs.js">
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBccCxXK.js">
|
|
9
|
+
<link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.Bkv_zTjr.css">
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DNen4El9.js">
|
|
11
|
+
<script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/n4MbYZHF.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},1733208468833,false]</script>
|
|
12
|
+
<script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"d48170a8-5b86-44b8-8103-1aa6250c5f55",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
1
|
+
import path, { resolve } from 'node:path';
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import fs__default, { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { useNuxt, defineNuxtModule, useLogger, createResolver, addTemplate, addPlugin, addImportsDir, addServerHandler, addComponentsDir, addTypeTemplate, extendPages, addPrerenderRoutes } from '@nuxt/kit';
|
|
5
5
|
import { watch } from 'chokidar';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
6
7
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
8
|
+
import sirv from 'sirv';
|
|
7
9
|
|
|
8
10
|
const DEVTOOLS_UI_PORT = 3030;
|
|
9
11
|
const DEVTOOLS_UI_ROUTE = "/__nuxt-i18n-micro";
|
|
10
|
-
|
|
12
|
+
const distDir = resolve(fileURLToPath(import.meta.url), "..");
|
|
13
|
+
const clientDir = resolve(distDir, "client");
|
|
14
|
+
function setupDevToolsUI(options, resolve2) {
|
|
11
15
|
const nuxt = useNuxt();
|
|
12
|
-
const clientPath =
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const clientPath = resolve2("./client");
|
|
17
|
+
const clientDirExists = fs.existsSync(clientPath);
|
|
18
|
+
const ROUTE_PATH = `${nuxt.options.app.baseURL || "/"}/__nuxt-i18n-micro`.replace(/\/+/g, "/");
|
|
19
|
+
const ROUTE_CLIENT = `${ROUTE_PATH}/client`;
|
|
20
|
+
if (clientDirExists) {
|
|
21
|
+
nuxt.hook("vite:serverCreated", (server) => {
|
|
22
|
+
const indexHtmlPath = path.join(clientDir, "index.html");
|
|
23
|
+
const indexContent = fs.readFileSync(indexHtmlPath);
|
|
24
|
+
const handleStatic = sirv(clientDir, {
|
|
25
|
+
dev: true,
|
|
26
|
+
single: false
|
|
27
|
+
});
|
|
28
|
+
const handleIndex = async (res) => {
|
|
29
|
+
res.setHeader("Content-Type", "text/html");
|
|
30
|
+
res.statusCode = 200;
|
|
31
|
+
res.write((await indexContent).toString().replace(/\/__NUXT_DEVTOOLS_I18N_BASE__\//g, `${ROUTE_CLIENT}/`));
|
|
32
|
+
res.end();
|
|
33
|
+
};
|
|
34
|
+
server.middlewares.use(ROUTE_CLIENT, (req, res) => {
|
|
35
|
+
if (req.url === "/")
|
|
36
|
+
return handleIndex(res);
|
|
37
|
+
return handleStatic(req, res, () => handleIndex(res));
|
|
38
|
+
});
|
|
18
39
|
});
|
|
19
40
|
} else {
|
|
20
41
|
nuxt.hook("vite:extendConfig", (config) => {
|
|
@@ -81,7 +102,7 @@ function setupDevToolsUI(options, resolve) {
|
|
|
81
102
|
icon: "carbon:language",
|
|
82
103
|
view: {
|
|
83
104
|
type: "iframe",
|
|
84
|
-
src:
|
|
105
|
+
src: ROUTE_CLIENT
|
|
85
106
|
}
|
|
86
107
|
});
|
|
87
108
|
});
|
|
@@ -451,9 +472,7 @@ const module = defineNuxtModule({
|
|
|
451
472
|
addTemplate({
|
|
452
473
|
filename: "i18n.plural.mjs",
|
|
453
474
|
write: true,
|
|
454
|
-
getContents: () => `
|
|
455
|
-
export const plural = ${options.plural.toString()};
|
|
456
|
-
`
|
|
475
|
+
getContents: () => `export const plural = ${options.plural.toString()};`
|
|
457
476
|
});
|
|
458
477
|
const apiBaseUrl = (process.env.NUXT_I18N_APP_BASE_URL ?? options.apiBaseUrl ?? "_locales").replace(/^\/+|\/+$|\/{2,}/, "");
|
|
459
478
|
nuxt.options.runtimeConfig.public.i18nConfig = {
|
|
@@ -598,10 +617,6 @@ const module = defineNuxtModule({
|
|
|
598
617
|
imports: ["useTranslationServerMiddleware"]
|
|
599
618
|
});
|
|
600
619
|
}
|
|
601
|
-
nitroConfig.virtual = nitroConfig.virtual || {};
|
|
602
|
-
nitroConfig.virtual["#internal/i18n/options.mjs"] = () => `
|
|
603
|
-
export const defaultLocale = "${options.defaultLocale}";
|
|
604
|
-
`;
|
|
605
620
|
const routes = nitroConfig.prerender?.routes || [];
|
|
606
621
|
nuxt.options.generate.routes = Array.isArray(nuxt.options.generate.routes) ? nuxt.options.generate.routes : [];
|
|
607
622
|
const pages = nuxt.options.generate.routes || [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { H3Event } from 'h3';
|
|
2
|
-
export declare const useTranslationServerMiddleware: (event: H3Event, currentLocale?: string) => Promise<(key: string) => string>;
|
|
2
|
+
export declare const useTranslationServerMiddleware: (event: H3Event, defaultLocale?: string, currentLocale?: string) => Promise<(key: string) => string>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getQuery, getCookie } from "h3";
|
|
2
2
|
import { useTranslationHelper } from "./translationHelper.js";
|
|
3
|
-
import { defaultLocale } from "#internal/i18n/options.mjs";
|
|
4
3
|
async function fetchTranslations(locale) {
|
|
5
4
|
try {
|
|
6
5
|
const translations = await $fetch(`/_locales/general/${locale}/data.json`);
|
|
@@ -10,7 +9,7 @@ async function fetchTranslations(locale) {
|
|
|
10
9
|
return {};
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
export const useTranslationServerMiddleware = async (event, currentLocale) => {
|
|
12
|
+
export const useTranslationServerMiddleware = async (event, defaultLocale, currentLocale) => {
|
|
14
13
|
const { getTranslation, loadTranslations, hasGeneralTranslation } = useTranslationHelper();
|
|
15
14
|
const locale = (currentLocale || event.context.params?.locale || getQuery(event)?.locale || getCookie(event, "user-locale") || event.headers.get("accept-language")?.split(",")[0] || defaultLocale || "en").toString();
|
|
16
15
|
if (!hasGeneralTranslation(locale)) {
|
package/internals.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-i18n-micro",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.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":"166e9332-75a4-41da-96ec-b2e17e8c07d9","timestamp":1733171878036,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
|