From 31c5c4e92437786468ef48b2744cb365e107ab90 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2026 03:32:43 +0000 Subject: [PATCH] fix(app): keep locale names native (#40985) Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> --- packages/app/src/context/language.tsx | 41 +------------------- packages/app/src/i18n/desktop-native.test.ts | 35 +++++++++++++++++ packages/app/src/i18n/desktop-native.ts | 31 +++++++++++++++ 3 files changed, 68 insertions(+), 39 deletions(-) diff --git a/packages/app/src/context/language.tsx b/packages/app/src/context/language.tsx index 8772fd3111a..5ad98034e15 100644 --- a/packages/app/src/context/language.tsx +++ b/packages/app/src/context/language.tsx @@ -9,6 +9,7 @@ import { dict as uiEn } from "@opencode-ai/ui/i18n/en" import { createDesktopNativeBundle, DESKTOP_NATIVE_ENGLISH, + DESKTOP_NATIVE_LABELS, DESKTOP_NATIVE_LOCALES, type DesktopNativeBundle, type DesktopNativeLocale, @@ -69,40 +70,6 @@ const INTL: Record = { sv: "sv-SE", } -const LABEL_KEY: Partial> = { - en: "language.en", - zh: "language.zh", - zht: "language.zht", - ko: "language.ko", - de: "language.de", - es: "language.es", - fr: "language.fr", - da: "language.da", - ja: "language.ja", - pl: "language.pl", - ru: "language.ru", - uk: "language.uk", - ar: "language.ar", - no: "language.no", - br: "language.br", - th: "language.th", - bs: "language.bs", - tr: "language.tr", -} - -const LABEL: Partial> = { - hi: "हिन्दी", - nl: "Nederlands", - id: "Bahasa Indonesia", - vi: "Tiếng Việt", - it: "Italiano", - ur: "اردو", - pa: "پنجابی", - az: "Azərbaycanca", - fi: "Suomi", - sv: "Svenska", -} - const base = i18n.flatten({ ...en, ...uiEn }) const dicts = new Map([["en", base]]) @@ -272,11 +239,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont return i18n.resolveTemplate(current[candidate] ?? current[fallback] ?? fallback, { ...params, count }) } - const label = (value: Locale) => { - const key = LABEL_KEY[value] - if (key) return t(key) - return LABEL[value] ?? value - } + const label = (value: Locale) => DESKTOP_NATIVE_LABELS[value] createEffect(() => { if (typeof document !== "object") return diff --git a/packages/app/src/i18n/desktop-native.test.ts b/packages/app/src/i18n/desktop-native.test.ts index 04a888db066..5409dcaebf0 100644 --- a/packages/app/src/i18n/desktop-native.test.ts +++ b/packages/app/src/i18n/desktop-native.test.ts @@ -3,12 +3,47 @@ import { createDesktopNativeBundle, DESKTOP_NATIVE_ENGLISH, DESKTOP_NATIVE_KEYS, + DESKTOP_NATIVE_LABELS, + DESKTOP_NATIVE_LOCALES, DESKTOP_NATIVE_MAX_PAYLOAD_BYTES, formatDesktopNativeMessage, parseDesktopNativeBundle, } from "./desktop-native" describe("desktop native translations", () => { + test("uses native language names independent of the active locale", () => { + expect(DESKTOP_NATIVE_LOCALES.map((locale) => DESKTOP_NATIVE_LABELS[locale])).toEqual([ + "English", + "简体中文", + "繁體中文", + "한국어", + "Deutsch", + "Español", + "Français", + "Dansk", + "日本語", + "Polski", + "Русский", + "Українська", + "Bosanski", + "العربية", + "Norsk", + "Português (Brasil)", + "ไทย", + "Türkçe", + "हिन्दी", + "Nederlands", + "Bahasa Indonesia", + "Tiếng Việt", + "Italiano", + "اردو", + "پنجابی", + "Azərbaycanca", + "Suomi", + "Svenska", + ]) + }) + test("accepts the exact typed bundle", () => { const bundle = createDesktopNativeBundle("en", (key) => DESKTOP_NATIVE_ENGLISH[key]) expect(parseDesktopNativeBundle(bundle)).toEqual(bundle) diff --git a/packages/app/src/i18n/desktop-native.ts b/packages/app/src/i18n/desktop-native.ts index 3c181c1ad55..b214a14f2da 100644 --- a/packages/app/src/i18n/desktop-native.ts +++ b/packages/app/src/i18n/desktop-native.ts @@ -31,6 +31,37 @@ export const DESKTOP_NATIVE_LOCALES = [ export type DesktopNativeLocale = (typeof DESKTOP_NATIVE_LOCALES)[number] +export const DESKTOP_NATIVE_LABELS: Record = { + en: "English", + zh: "简体中文", + zht: "繁體中文", + ko: "한국어", + de: "Deutsch", + es: "Español", + fr: "Français", + da: "Dansk", + ja: "日本語", + pl: "Polski", + ru: "Русский", + uk: "Українська", + bs: "Bosanski", + ar: "العربية", + no: "Norsk", + br: "Português (Brasil)", + th: "ไทย", + tr: "Türkçe", + hi: "हिन्दी", + nl: "Nederlands", + id: "Bahasa Indonesia", + vi: "Tiếng Việt", + it: "Italiano", + ur: "اردو", + pa: "پنجابی", + az: "Azərbaycanca", + fi: "Suomi", + sv: "Svenska", +} + export const DESKTOP_NATIVE_ENGLISH = { "desktop.menu.app": "OpenCode", "desktop.menu.file": "File",