Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/app/src/context/language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import { dict as uiEs } from "@opencode-ai/ui/i18n/es"
import { dict as uiFr } from "@opencode-ai/ui/i18n/fr"
import { dict as uiDa } from "@opencode-ai/ui/i18n/da"
import { dict as uiJa } from "@opencode-ai/ui/i18n/ja"
import { dict as pl } from "@/i18n/pl"
import { dict as uiPl } from "@opencode-ai/ui/i18n/pl"

export type Locale = "en" | "zh" | "ko" | "de" | "es" | "fr" | "da" | "ja"
export type Locale = "en" | "zh" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl"

type RawDictionary = typeof en & typeof uiEn
type Dictionary = i18n.Flatten<RawDictionary>

const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de", "es", "fr", "da", "ja"]
const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de", "es", "fr", "da", "ja", "pl"]

function detectLocale(): Locale {
if (typeof navigator !== "object") return "en"
Expand All @@ -40,6 +42,7 @@ function detectLocale(): Locale {
if (language.toLowerCase().startsWith("fr")) return "fr"
if (language.toLowerCase().startsWith("da")) return "da"
if (language.toLowerCase().startsWith("ja")) return "ja"
if (language.toLowerCase().startsWith("pl")) return "pl"
}

return "en"
Expand All @@ -63,6 +66,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (store.locale === "fr") return "fr"
if (store.locale === "da") return "da"
if (store.locale === "ja") return "ja"
if (store.locale === "pl") return "pl"
return "en"
})

Expand All @@ -81,6 +85,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (locale() === "fr") return { ...base, ...i18n.flatten({ ...fr, ...uiFr }) }
if (locale() === "da") return { ...base, ...i18n.flatten({ ...da, ...uiDa }) }
if (locale() === "ja") return { ...base, ...i18n.flatten({ ...ja, ...uiJa }) }
if (locale() === "pl") return { ...base, ...i18n.flatten({ ...pl, ...uiPl }) }
return { ...base, ...i18n.flatten({ ...ko, ...uiKo }) }
})

Expand All @@ -95,6 +100,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
fr: "language.fr",
da: "language.da",
ja: "language.ja",
pl: "language.pl",
}

const label = (value: Locale) => t(labelKey[value])
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const dict = {
"language.fr": "Fransk",
"language.ja": "Japansk",
"language.da": "Dansk",
"language.pl": "Polsk",

"toast.language.title": "Sprog",
"toast.language.description": "Skiftede til {{language}}",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export const dict = {
"language.fr": "Französisch",
"language.ja": "Japanisch",
"language.da": "Dänisch",
"language.pl": "Polnisch",

"toast.language.title": "Sprache",
"toast.language.description": "Zu {{language}} gewechselt",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export const dict = {
"language.fr": "French",
"language.ja": "Japanese",
"language.da": "Danish",
"language.pl": "Polish",

"toast.language.title": "Language",
"toast.language.description": "Switched to {{language}}",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const dict = {
"language.fr": "Francés",
"language.ja": "Japonés",
"language.da": "Danés",
"language.pl": "Polaco",

"toast.language.title": "Idioma",
"toast.language.description": "Cambiado a {{language}}",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const dict = {
"language.fr": "Français",
"language.ja": "Japonais",
"language.da": "Danois",
"language.pl": "Polonais",

"toast.language.title": "Langue",
"toast.language.description": "Passé à {{language}}",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export const dict = {
"language.fr": "フランス語",
"language.ja": "日本語",
"language.da": "デンマーク語",
"language.pl": "ポーランド語",

"toast.language.title": "言語",
"toast.language.description": "{{language}}に切り替えました",
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export const dict = {
"language.fr": "프랑스어",
"language.ja": "일본어",
"language.da": "덴마크어",
"language.pl": "폴란드어",

"toast.language.title": "언어",
"toast.language.description": "{{language}}(으)로 전환됨",
Expand Down
Loading