mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-19 22:34:15 +00:00
[bugfix] Fix Chinese locale detection to properly handle traditional Chinese
- Update getDefaultLocale() to distinguish between zh-CN (simplified) and zh-TW/zh-HK/zh-Hant (traditional) - Fixes issue where browsers set to traditional Chinese were incorrectly defaulting to simplified Chinese translations - Preserves existing behavior for all other languages Fixes #5151 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
18
src/i18n.ts
18
src/i18n.ts
@@ -58,10 +58,26 @@ const messages = {
|
||||
ar: buildLocale(ar, arNodes, arCommands, arSettings)
|
||||
}
|
||||
|
||||
function getDefaultLocale(): string {
|
||||
const lang = navigator.language
|
||||
|
||||
// Handle Chinese variants specifically to distinguish between simplified and traditional
|
||||
if (lang.startsWith('zh-')) {
|
||||
return lang.startsWith('zh-TW') ||
|
||||
lang.startsWith('zh-HK') ||
|
||||
lang.startsWith('zh-Hant')
|
||||
? 'zh-TW'
|
||||
: 'zh'
|
||||
}
|
||||
|
||||
// For other languages, use the existing logic
|
||||
return lang.split('-')[0] || 'en'
|
||||
}
|
||||
|
||||
export const i18n = createI18n({
|
||||
// Must set `false`, as Vue I18n Legacy API is for Vue 2
|
||||
legacy: false,
|
||||
locale: navigator.language.split('-')[0] || 'en',
|
||||
locale: getDefaultLocale(),
|
||||
fallbackLocale: 'en',
|
||||
messages,
|
||||
// Ignore warnings for locale options as each option is in its own language.
|
||||
|
||||
Reference in New Issue
Block a user