feat(i18n): add Russian language support (#9882)

This commit is contained in:
Alex Yaroshuk
2026-01-22 05:30:12 +08:00
committed by GitHub
parent c89f6e7ac6
commit 383c2787f9
11 changed files with 749 additions and 3 deletions

View File

@@ -11,6 +11,8 @@ import { dict as es } from "@/i18n/es"
import { dict as fr } from "@/i18n/fr"
import { dict as da } from "@/i18n/da"
import { dict as ja } from "@/i18n/ja"
import { dict as pl } from "@/i18n/pl"
import { dict as ru } from "@/i18n/ru"
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"
@@ -19,15 +21,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"
import { dict as uiRu } from "@opencode-ai/ui/i18n/ru"
export type Locale = "en" | "zh" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl"
export type Locale = "en" | "zh" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru"
type RawDictionary = typeof en & typeof uiEn
type Dictionary = i18n.Flatten<RawDictionary>
const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de", "es", "fr", "da", "ja", "pl"]
const LOCALES: readonly Locale[] = ["en", "zh", "ko", "de", "es", "fr", "da", "ja", "pl", "ru"]
function detectLocale(): Locale {
if (typeof navigator !== "object") return "en"
@@ -43,6 +45,7 @@ function detectLocale(): Locale {
if (language.toLowerCase().startsWith("da")) return "da"
if (language.toLowerCase().startsWith("ja")) return "ja"
if (language.toLowerCase().startsWith("pl")) return "pl"
if (language.toLowerCase().startsWith("ru")) return "ru"
}
return "en"
@@ -67,6 +70,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (store.locale === "da") return "da"
if (store.locale === "ja") return "ja"
if (store.locale === "pl") return "pl"
if (store.locale === "ru") return "ru"
return "en"
})
@@ -86,6 +90,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
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 }) }
if (locale() === "ru") return { ...base, ...i18n.flatten({ ...ru, ...uiRu }) }
return { ...base, ...i18n.flatten({ ...ko, ...uiKo }) }
})
@@ -101,6 +106,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
da: "language.da",
ja: "language.ja",
pl: "language.pl",
ru: "language.ru",
}
const label = (value: Locale) => t(labelKey[value])