@@ -5,6 +5,7 @@ import { createSimpleContext } from "@opencode-ai/ui/context"
55import { Persist , persisted } from "@/utils/persist"
66import { dict as en } from "@/i18n/en"
77import { dict as zh } from "@/i18n/zh"
8+ import { dict as zht } from "@/i18n/zht"
89import { dict as ko } from "@/i18n/ko"
910import { dict as de } from "@/i18n/de"
1011import { dict as es } from "@/i18n/es"
@@ -15,6 +16,7 @@ import { dict as pl } from "@/i18n/pl"
1516import { dict as ru } from "@/i18n/ru"
1617import { dict as uiEn } from "@opencode-ai/ui/i18n/en"
1718import { dict as uiZh } from "@opencode-ai/ui/i18n/zh"
19+ import { dict as uiZht } from "@opencode-ai/ui/i18n/zht"
1820import { dict as uiKo } from "@opencode-ai/ui/i18n/ko"
1921import { dict as uiDe } from "@opencode-ai/ui/i18n/de"
2022import { dict as uiEs } from "@opencode-ai/ui/i18n/es"
@@ -24,20 +26,23 @@ import { dict as uiJa } from "@opencode-ai/ui/i18n/ja"
2426import { dict as uiPl } from "@opencode-ai/ui/i18n/pl"
2527import { dict as uiRu } from "@opencode-ai/ui/i18n/ru"
2628
27- export type Locale = "en" | "zh" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru"
29+ export type Locale = "en" | "zh" | "zht" | " ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru"
2830
2931type RawDictionary = typeof en & typeof uiEn
3032type Dictionary = i18n . Flatten < RawDictionary >
3133
32- const LOCALES : readonly Locale [ ] = [ "en" , "zh" , "ko" , "de" , "es" , "fr" , "da" , "ja" , "pl" , "ru" ]
34+ const LOCALES : readonly Locale [ ] = [ "en" , "zh" , "zht" , " ko", "de" , "es" , "fr" , "da" , "ja" , "pl" , "ru" ]
3335
3436function detectLocale ( ) : Locale {
3537 if ( typeof navigator !== "object" ) return "en"
3638
3739 const languages = navigator . languages ?. length ? navigator . languages : [ navigator . language ]
3840 for ( const language of languages ) {
3941 if ( ! language ) continue
40- if ( language . toLowerCase ( ) . startsWith ( "zh" ) ) return "zh"
42+ if ( language . toLowerCase ( ) . startsWith ( "zh" ) ) {
43+ if ( language . toLowerCase ( ) . includes ( "hant" ) ) return "zht"
44+ return "zh"
45+ }
4146 if ( language . toLowerCase ( ) . startsWith ( "ko" ) ) return "ko"
4247 if ( language . toLowerCase ( ) . startsWith ( "de" ) ) return "de"
4348 if ( language . toLowerCase ( ) . startsWith ( "es" ) ) return "es"
@@ -63,6 +68,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
6368
6469 const locale = createMemo < Locale > ( ( ) => {
6570 if ( store . locale === "zh" ) return "zh"
71+ if ( store . locale === "zht" ) return "zht"
6672 if ( store . locale === "ko" ) return "ko"
6773 if ( store . locale === "de" ) return "de"
6874 if ( store . locale === "es" ) return "es"
@@ -84,6 +90,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
8490 const dict = createMemo < Dictionary > ( ( ) => {
8591 if ( locale ( ) === "en" ) return base
8692 if ( locale ( ) === "zh" ) return { ...base , ...i18n . flatten ( { ...zh , ...uiZh } ) }
93+ if ( locale ( ) === "zht" ) return { ...base , ...i18n . flatten ( { ...zht , ...uiZht } ) }
8794 if ( locale ( ) === "de" ) return { ...base , ...i18n . flatten ( { ...de , ...uiDe } ) }
8895 if ( locale ( ) === "es" ) return { ...base , ...i18n . flatten ( { ...es , ...uiEs } ) }
8996 if ( locale ( ) === "fr" ) return { ...base , ...i18n . flatten ( { ...fr , ...uiFr } ) }
@@ -99,6 +106,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
99106 const labelKey : Record < Locale , keyof Dictionary > = {
100107 en : "language.en" ,
101108 zh : "language.zh" ,
109+ zht : "language.zht" ,
102110 ko : "language.ko" ,
103111 de : "language.de" ,
104112 es : "language.es" ,
0 commit comments