This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch 2.0.0
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/2.0.0 by this push:
new 343a5dcf20 fix(i18n): correct locale priority and fix Japanese label
key
343a5dcf20 is described below
commit 343a5dcf20275dda15f34dba7cc3fa48b6e5304f
Author: liuhy <[email protected]>
AuthorDate: Fri Jun 5 09:58:23 2026 +0800
fix(i18n): correct locale priority and fix Japanese label key
- Reorder locale resolution priority: localStorage > backend API > browser
- Fix Japanese locale labelKey from 'ja-JP' to 'ja_JP' for consistency
Co-Authored-By: Claude Opus 4.8 <[email protected]>
---
web-next/components/providers/i18n-provider.tsx | 9 ++++++---
web-next/lib/i18n.ts | 2 +-
web-next/lib/setting-config/view-model.ts | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/web-next/components/providers/i18n-provider.tsx
b/web-next/components/providers/i18n-provider.tsx
index 89a2614460..45935813e1 100644
--- a/web-next/components/providers/i18n-provider.tsx
+++ b/web-next/components/providers/i18n-provider.tsx
@@ -145,6 +145,11 @@ export async function loadLocaleMessages(locale:
LocaleCode, allowRemoteOverride
}
async function resolveInitialLocale(allowRemoteBootstrap: boolean):
Promise<LocaleCode> {
+ // Priority 1: localStorage (user's manual choice should always take
precedence)
+ const stored = readStoredLocale();
+ if (stored) return stored;
+
+ // Priority 2: Backend API system config
if (allowRemoteBootstrap) {
try {
const response = await fetch('/api/config/system', { cache: 'no-store'
});
@@ -160,9 +165,7 @@ async function resolveInitialLocale(allowRemoteBootstrap:
boolean): Promise<Loca
}
}
- const stored = readStoredLocale();
- if (stored) return stored;
-
+ // Priority 3: Browser language
if (typeof window !== 'undefined') {
const browserLocale = window.navigator.languages?.[0] ||
window.navigator.language;
return normalizeLocale(browserLocale);
diff --git a/web-next/lib/i18n.ts b/web-next/lib/i18n.ts
index 0d743407d7..000c5ee1c9 100644
--- a/web-next/lib/i18n.ts
+++ b/web-next/lib/i18n.ts
@@ -7,7 +7,7 @@ export const LOCALES: Array<{ code: LocaleCode; labelKey:
string; abbr: string }
{ code: 'en-US', labelKey: 'settings.system-config.locale.en_US', abbr: '🇬🇧'
},
{ code: 'zh-CN', labelKey: 'settings.system-config.locale.zh_CN', abbr: '🇨🇳'
},
{ code: 'zh-TW', labelKey: 'settings.system-config.locale.zh_TW', abbr: 'ðŸ‡ðŸ‡°'
},
- { code: 'ja-JP', labelKey: 'settings.system-config.locale.ja-JP', abbr: '🇯🇵'
},
+ { code: 'ja-JP', labelKey: 'settings.system-config.locale.ja_JP', abbr: '🇯🇵'
},
{ code: 'pt-BR', labelKey: 'settings.system-config.locale.pt_BR', abbr: '🇧🇷'
}
];
diff --git a/web-next/lib/setting-config/view-model.ts
b/web-next/lib/setting-config/view-model.ts
index 54187b5b7d..75a302a02d 100644
--- a/web-next/lib/setting-config/view-model.ts
+++ b/web-next/lib/setting-config/view-model.ts
@@ -7,7 +7,7 @@ export const SYSTEM_CONFIG_LOCALE_OPTIONS = [
{ value: 'en_US', labelKey: 'settings.system-config.locale.en_US' },
{ value: 'zh_CN', labelKey: 'settings.system-config.locale.zh_CN' },
{ value: 'zh_TW', labelKey: 'settings.system-config.locale.zh_TW' },
- { value: 'ja_JP', labelKey: 'settings.system-config.locale.ja-JP' },
+ { value: 'ja_JP', labelKey: 'settings.system-config.locale.ja_JP' },
{ value: 'pt_BR', labelKey: 'settings.system-config.locale.pt_BR' }
] as const;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]