是包名取错了,应该是zh而不是zh-cn.这样仍用原来的代码逻辑是对的。

This commit is contained in:
celebrateyang 2024-10-17 16:34:22 +08:00
parent 90a54781ef
commit 61453fb63e
25 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,5 @@
{ {
"en": "english", "en": "english",
"ru": "русский", "ru": "русский",
"zh-CN": "中文" "zh": "中文"
} }

View File

@ -21,7 +21,7 @@ for (const [path, loader] of Object.entries(locFiles)) {
}; };
} }
const defaultLocale = 'zh-cn'; const defaultLocale = 'en';
const languages: Record<string, string> = _languages; const languages: Record<string, string> = _languages;
const config: Config<{ const config: Config<{

View File

@ -12,9 +12,12 @@ export const load: Load = async ({ url }) => {
const { pathname } = url; const { pathname } = url;
let preferredLocale = defaultLocale; let preferredLocale = defaultLocale;
console.log("preferredLocale 1=========>", preferredLocale);
if (browser) { if (browser) {
preferredLocale = get((await import('$lib/i18n/locale')).default); preferredLocale = get((await import('$lib/i18n/locale')).default);
console.log("preferredLocale 2=========>", preferredLocale);
} }
await loadTranslations(preferredLocale, pathname); await loadTranslations(preferredLocale, pathname);