--------- Co-authored-by-agent: Codex <267193182+codex@users.noreply.github.com> Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: RainbowBird <rbxin2003@outlook.com> Co-authored-by: Neko <neko@ayaka.moe>
50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
export const all = {
|
|
'en': 'English',
|
|
'es': 'Español',
|
|
'fr': 'Français',
|
|
'ja': '日本語',
|
|
'ko': '한국어',
|
|
'ru': 'Русский',
|
|
'vi': 'Tiếng Việt',
|
|
'zh-Hans': '简体中文',
|
|
'zh-Hant': '繁體中文',
|
|
}
|
|
|
|
export const localeRemap: Record<string, string> = {
|
|
'zh-CN': 'zh-Hans',
|
|
'zh-TW': 'zh-Hant',
|
|
'zh-HK': 'zh-Hans',
|
|
'zh-Hant': 'zh-Hant',
|
|
'zh-Hans': 'zh-Hans',
|
|
'en': 'en',
|
|
'en-US': 'en',
|
|
'en-GB': 'en',
|
|
'en-AU': 'en',
|
|
'es': 'es',
|
|
'es-ES': 'es',
|
|
'es-MX': 'es',
|
|
'es-AR': 'es',
|
|
'fr': 'fr',
|
|
'fr-FR': 'fr',
|
|
'ja': 'ja',
|
|
'ja-JP': 'ja',
|
|
'ko': 'ko',
|
|
'ko-KR': 'ko',
|
|
'ru': 'ru',
|
|
'ru-RU': 'ru',
|
|
'vi': 'vi',
|
|
'vi-VN': 'vi',
|
|
}
|
|
|
|
export function resolveSupportedLocale(
|
|
locale: string | null | undefined,
|
|
supportedLocales: readonly string[],
|
|
fallbackLocale = 'en',
|
|
): string {
|
|
const normalizedLocale = localeRemap[locale ?? fallbackLocale] ?? locale ?? fallbackLocale
|
|
|
|
return supportedLocales.includes(normalizedLocale)
|
|
? normalizedLocale
|
|
: fallbackLocale
|
|
}
|