feat(app): polish translations (#9884)

This commit is contained in:
Filip
2026-01-21 22:04:25 +01:00
committed by GitHub
parent 09d2fd57ff
commit 5ca28b6454
11 changed files with 744 additions and 2 deletions

View File

@@ -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"
@@ -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"
@@ -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"
})
@@ -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 }) }
})
@@ -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])