vite-plugin-i18n-ally
Advanced tools
Comparing version 5.2.8 to 5.2.9
@@ -9,3 +9,4 @@ import { Detector } from './types.js'; | ||
cacheUserLanguage(lng: string, options: { | ||
cache: number; | ||
cache: number | string; | ||
languages: string[]; | ||
}): void; | ||
@@ -12,0 +13,0 @@ } |
@@ -14,13 +14,12 @@ // src/client/detectors/path.ts | ||
cacheUserLanguage(lng, options) { | ||
const { cache: cachePathIndex } = options; | ||
const { cache: cachePathIndex, languages } = options; | ||
const index = typeof cachePathIndex === "number" ? cachePathIndex : 0; | ||
const currentURL = new URL(window.location.href); | ||
const language = currentURL.pathname.match(regex); | ||
setTimeout(() => { | ||
if (!Array.isArray(language)) return; | ||
if (language[index] === `/${lng}`) return; | ||
language.splice(index, 0, `/${lng}`); | ||
currentURL.pathname = language.join(""); | ||
window.history.replaceState({}, "", currentURL); | ||
}); | ||
if (!Array.isArray(language)) return; | ||
if (language[index] === `/${lng}`) return; | ||
const delIndex = languages.some((l) => language[index] === `/${l}`) ? 1 : 0; | ||
language.splice(index, delIndex, `/${lng}`); | ||
currentURL.pathname = language.join(""); | ||
window.history.replaceState({}, "", currentURL); | ||
} | ||
@@ -27,0 +26,0 @@ }; |
@@ -14,3 +14,3 @@ // src/client/detectors/query-string.ts | ||
currentURL.searchParams.set(cache, lng); | ||
window.history.replaceState({ path: currentURL.href }, "", currentURL.href); | ||
window.history.replaceState({}, "", currentURL); | ||
}); | ||
@@ -17,0 +17,0 @@ } |
@@ -8,2 +8,3 @@ interface Detector<L extends Record<string, any> = Record<string, any>, C extends Record<string, any> = Record<string, any>> { | ||
cache: any; | ||
languages: string[]; | ||
} & C) => void; | ||
@@ -10,0 +11,0 @@ } |
@@ -88,3 +88,4 @@ import { resources } from 'virtual:i18n-ally-async-resource'; | ||
cache: d.lookup || "lang", | ||
...omit(d, ["detect", "lookup", "cache"]) | ||
...omit(d, ["detect", "lookup", "cache"]), | ||
languages: this.allLanguages | ||
}); | ||
@@ -91,0 +92,0 @@ }); |
{ | ||
"name": "vite-plugin-i18n-ally", | ||
"version": "5.2.8", | ||
"version": "5.2.9", | ||
"description": "Vite plugin for automatic lazy loading of i18n resources", | ||
@@ -52,6 +52,6 @@ "type": "module", | ||
"dependencies": { | ||
"debug": "^4.3.7", | ||
"debug": "^4.4.0", | ||
"fast-glob": "^3.3.2", | ||
"find-up": "^7.0.0", | ||
"importx": "^0.5.0", | ||
"importx": "^0.5.1", | ||
"js-yaml": "^4.1.0", | ||
@@ -63,3 +63,3 @@ "json5": "^2.2.3", | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.6.0", | ||
"@commitlint/cli": "^19.6.1", | ||
"@minko-fe/commitlint-config": "^2.1.2", | ||
@@ -74,9 +74,9 @@ "@minko-fe/eslint-config": "^4.1.1", | ||
"@types/lodash-es": "^4.17.12", | ||
"@types/node": "^22.10.0", | ||
"@types/react": "^18.3.12", | ||
"bumpp": "^9.8.1", | ||
"@types/node": "^22.10.2", | ||
"@types/react": "^18.3.18", | ||
"bumpp": "^9.9.2", | ||
"clone-deep": "^4.0.1", | ||
"conventional-changelog-cli": "^5.0.0", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^9.15.0", | ||
"eslint": "^9.17.0", | ||
"i18next": "23.5.1", | ||
@@ -90,3 +90,3 @@ "jsdom": "^22.1.0", | ||
"simple-git-hooks": "^2.11.1", | ||
"taze": "^0.17.2", | ||
"taze": "^0.18.0", | ||
"tsup": "8.3.0", | ||
@@ -96,5 +96,5 @@ "tsup-plugin-bundleless": "^1.2.0", | ||
"vitepress": "^1.5.0", | ||
"vitest": "^2.1.6", | ||
"vitest": "^2.1.8", | ||
"vitest-e2e": "^0.0.10", | ||
"vite-plugin-i18n-ally": "5.2.8" | ||
"vite-plugin-i18n-ally": "5.2.9" | ||
}, | ||
@@ -101,0 +101,0 @@ "simple-git-hooks": { |
Sorry, the diff of this file is not supported yet
181284
5113
Updateddebug@^4.4.0
Updatedimportx@^0.5.1