mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-25 07:16:02 +00:00
fix(i18n): handle extended locale subtags like zh-Hans-CN
normalizeLocale now correctly maps Windows-style locale strings (e.g. "zh-Hans-CN") to "zh-CN" by trying lang-region before falling back to the base language. Bare "zh" is also mapped to "zh-CN". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6724a1ce6b
commit
af94d74ad8
@@ -96,8 +96,17 @@ function normalizeLocale(locale: string | null | undefined): AppLocale {
|
||||
)
|
||||
if (canonical) return canonical
|
||||
|
||||
// Handle extended subtags like "zh-Hans-CN" → try "zh-CN"
|
||||
const parts = locale.split('-')
|
||||
if (parts.length >= 3) {
|
||||
const langRegion = `${parts[0]}-${parts[parts.length - 1]}`
|
||||
if (isSupportedLocale(langRegion)) {
|
||||
return langRegion
|
||||
}
|
||||
}
|
||||
|
||||
// Language-only fallback (e.g. "zh" matches "zh-CN")
|
||||
const lang = locale.split('-')[0].toLowerCase()
|
||||
const lang = parts[0].toLowerCase()
|
||||
const byLang = SUPPORTED_LOCALES.find((l) => l.split('-')[0].toLowerCase() === lang)
|
||||
if (byLang) return byLang
|
||||
|
||||
|
||||
Reference in New Issue
Block a user