feat(app): spanish translations

This commit is contained in:
Adam
2026-01-21 05:22:51 -06:00
parent 118b4f65da
commit 09a9556c70
7 changed files with 656 additions and 2 deletions

View File

@@ -7,17 +7,19 @@ import { dict as en } from "@/i18n/en"
import { dict as zh } from "@/i18n/zh"
import { dict as ko } from "@/i18n/ko"
import { dict as de } from "@/i18n/de"
import { dict as es } from "@/i18n/es"
import { dict as uiEn } from "@opencode-ai/ui/i18n/en"
import { dict as uiZh } from "@opencode-ai/ui/i18n/zh"
import { dict as uiKo } from "@opencode-ai/ui/i18n/ko"
import { dict as uiDe } from "@opencode-ai/ui/i18n/de"
import { dict as uiEs } from "@opencode-ai/ui/i18n/es"
export type Locale = "en" | "zh" | "ko" | "de"
export type Locale = "en" | "zh" | "ko" | "de" | "es"
type RawDictionary = typeof en & typeof uiEn
type Dictionary = i18n.Flatten<RawDictionary>
const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de"]
const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de", "es"]
function detectLocale(): Locale {
if (typeof navigator !== "object") return "en"
@@ -28,6 +30,7 @@ function detectLocale(): Locale {
if (language.toLowerCase().startsWith("zh")) return "zh"
if (language.toLowerCase().startsWith("ko")) return "ko"
if (language.toLowerCase().startsWith("de")) return "de"
if (language.toLowerCase().startsWith("es")) return "es"
}
return "en"
@@ -47,6 +50,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (store.locale === "zh") return "zh"
if (store.locale === "ko") return "ko"
if (store.locale === "de") return "de"
if (store.locale === "es") return "es"
return "en"
})
@@ -61,6 +65,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (locale() === "en") return base
if (locale() === "zh") return { ...base, ...i18n.flatten({ ...zh, ...uiZh }) }
if (locale() === "de") return { ...base, ...i18n.flatten({ ...de, ...uiDe }) }
if (locale() === "es") return { ...base, ...i18n.flatten({ ...es, ...uiEs }) }
return { ...base, ...i18n.flatten({ ...ko, ...uiKo }) }
})
@@ -71,6 +76,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
zh: "language.zh",
ko: "language.ko",
de: "language.de",
es: "language.es",
}
const label = (value: Locale) => t(labelKey[value])