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
12 changes: 9 additions & 3 deletions packages/app/src/context/language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { dict as ja } from "@/i18n/ja"
import { dict as pl } from "@/i18n/pl"
import { dict as ru } from "@/i18n/ru"
import { dict as ar } from "@/i18n/ar"
import { dict as no } from "@/i18n/no"
import { dict as uiEn } from "@opencode-ai/ui/i18n/en"
import { dict as uiZh } from "@opencode-ai/ui/i18n/zh"
import { dict as uiZht } from "@opencode-ai/ui/i18n/zht"
Expand All @@ -27,13 +28,14 @@ import { dict as uiJa } from "@opencode-ai/ui/i18n/ja"
import { dict as uiPl } from "@opencode-ai/ui/i18n/pl"
import { dict as uiRu } from "@opencode-ai/ui/i18n/ru"
import { dict as uiAr } from "@opencode-ai/ui/i18n/ar"
import { dict as uiNo } from "@opencode-ai/ui/i18n/no"

export type Locale = "en" | "zh" | "zht" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru" | "ar"
export type Locale = "en" | "zh" | "zht" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru" | "ar" | "no"

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

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

function detectLocale(): Locale {
if (typeof navigator !== "object") return "en"
Expand All @@ -54,6 +56,7 @@ function detectLocale(): Locale {
if (language.toLowerCase().startsWith("pl")) return "pl"
if (language.toLowerCase().startsWith("ru")) return "ru"
if (language.toLowerCase().startsWith("ar")) return "ar"
if (language.toLowerCase().startsWith("no") || language.toLowerCase().startsWith("nb") || language.toLowerCase().startsWith("nn")) return "no"
}

return "en"
Expand Down Expand Up @@ -81,6 +84,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (store.locale === "pl") return "pl"
if (store.locale === "ru") return "ru"
if (store.locale === "ar") return "ar"
if (store.locale === "no") return "no"
return "en"
})

Expand All @@ -103,6 +107,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
if (locale() === "pl") return { ...base, ...i18n.flatten({ ...pl, ...uiPl }) }
if (locale() === "ru") return { ...base, ...i18n.flatten({ ...ru, ...uiRu }) }
if (locale() === "ar") return { ...base, ...i18n.flatten({ ...ar, ...uiAr }) }
if (locale() === "no") return { ...base, ...i18n.flatten({ ...no, ...uiNo }) }
return { ...base, ...i18n.flatten({ ...ko, ...uiKo }) }
})

Expand All @@ -121,6 +126,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
pl: "language.pl",
ru: "language.ru",
ar: "language.ar",
no: "language.no",
}

const label = (value: Locale) => t(labelKey[value])
Expand All @@ -141,4 +147,4 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
},
}
},
})
})
3 changes: 2 additions & 1 deletion packages/app/src/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const dict = {
"language.ru": "الروسية",
"language.pl": "البولندية",
"language.ar": "العربية",
"language.no": "النرويجية",

"toast.language.title": "لغة",
"toast.language.description": "تم التبديل إلى {{language}}",
Expand Down Expand Up @@ -643,4 +644,4 @@ export const dict = {
"workspace.reset.archived.one": "ستتم أرشفة جلسة واحدة.",
"workspace.reset.archived.many": "ستتم أرشفة {{count}} جلسات.",
"workspace.reset.note": "سيؤدي هذا إلى إعادة تعيين مساحة العمل لتتطابق مع الفرع الافتراضي.",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export const dict = {
"language.ru": "Russisk",
"language.pl": "Polsk",
"language.ar": "Arabisk",
"language.no": "Norsk",

"toast.language.title": "Sprog",
"toast.language.description": "Skiftede til {{language}}",
Expand Down Expand Up @@ -569,4 +570,4 @@ export const dict = {
"workspace.reset.archived.one": "1 session vil blive arkiveret.",
"workspace.reset.archived.many": "{{count}} sessioner vil blive arkiveret.",
"workspace.reset.note": "Dette vil nulstille arbejdsområdet til at matche hovedgrenen.",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export const dict = {
"language.ru": "Russisch",
"language.pl": "Polnisch",
"language.ar": "Arabisch",
"language.no": "Norwegisch",

"toast.language.title": "Sprache",
"toast.language.description": "Zu {{language}} gewechselt",
Expand Down Expand Up @@ -578,4 +579,4 @@ export const dict = {
"workspace.reset.archived.one": "1 Sitzung wird archiviert.",
"workspace.reset.archived.many": "{{count}} Sitzungen werden archiviert.",
"workspace.reset.note": "Dadurch wird der Arbeitsbereich auf den Standard-Branch zurückgesetzt.",
} satisfies Partial<Record<Keys, string>>
} satisfies Partial<Record<Keys, string>>
3 changes: 2 additions & 1 deletion packages/app/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const dict = {
"language.ru": "Russian",
"language.pl": "Polish",
"language.ar": "Arabic",
"language.no": "Norwegian",

"toast.language.title": "Language",
"toast.language.description": "Switched to {{language}}",
Expand Down Expand Up @@ -647,4 +648,4 @@ export const dict = {
"workspace.reset.archived.one": "1 session will be archived.",
"workspace.reset.archived.many": "{{count}} sessions will be archived.",
"workspace.reset.note": "This will reset the workspace to match the default branch.",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export const dict = {
"language.ru": "Ruso",
"language.pl": "Polaco",
"language.ar": "Árabe",
"language.no": "Noruego",

"toast.language.title": "Idioma",
"toast.language.description": "Cambiado a {{language}}",
Expand Down Expand Up @@ -572,4 +573,4 @@ export const dict = {
"workspace.reset.archived.one": "1 sesión será archivada.",
"workspace.reset.archived.many": "{{count}} sesiones serán archivadas.",
"workspace.reset.note": "Esto restablecerá el espacio de trabajo para coincidir con la rama predeterminada.",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export const dict = {
"language.ru": "Russe",
"language.pl": "Polonais",
"language.ar": "Arabe",
"language.no": "Norvégien",

"toast.language.title": "Langue",
"toast.language.description": "Passé à {{language}}",
Expand Down Expand Up @@ -579,4 +580,4 @@ export const dict = {
"workspace.reset.archived.one": "1 session sera archivée.",
"workspace.reset.archived.many": "{{count}} sessions seront archivées.",
"workspace.reset.note": "Cela réinitialisera l'espace de travail pour correspondre à la branche par défaut.",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export const dict = {
"language.ru": "ロシア語",
"language.pl": "ポーランド語",
"language.ar": "アラビア語",
"language.no": "ノルウェー語",

"toast.language.title": "言語",
"toast.language.description": "{{language}}に切り替えました",
Expand Down Expand Up @@ -566,4 +567,4 @@ export const dict = {
"workspace.reset.archived.one": "1つのセッションがアーカイブされます。",
"workspace.reset.archived.many": "{{count}}個のセッションがアーカイブされます。",
"workspace.reset.note": "これにより、ワークスペースはデフォルトブランチと一致するようにリセットされます。",
}
}
3 changes: 2 additions & 1 deletion packages/app/src/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export const dict = {
"language.ru": "러시아어",
"language.pl": "폴란드어",
"language.ar": "아랍어",
"language.no": "노르웨이어",

"toast.language.title": "언어",
"toast.language.description": "{{language}}(으)로 전환됨",
Expand Down Expand Up @@ -567,4 +568,4 @@ export const dict = {
"workspace.reset.archived.one": "1개의 세션이 보관됩니다.",
"workspace.reset.archived.many": "{{count}}개의 세션이 보관됩니다.",
"workspace.reset.note": "이 작업은 작업 공간을 기본 브랜치와 일치하도록 재설정합니다.",
}
}
Loading