GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(app): add global locale coverage (#40992) · BlueBlock/opencode@741244b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • app
      • AGENTS.md
      • src
        • context
          • language.tsx
        • entry.tsx
        • i18n
          • am.ts
          • bg.ts
          • bn.ts
          • ca.ts
          • cs.ts
          • desktop-native.test.ts
          • desktop-native.ts
          • dv.ts
          • dz.ts
          • el.ts
          • et.ts
          • fa.ts
          • fo.ts
          • hr.ts
          • hu.ts
          • hy.ts
          • is.ts
          • ka.ts
          • km.ts
          • lo.ts
          • lt.ts
          • lv.ts
          • mk.ts
          • mn.ts
          • ms.ts
          • my.ts
          • ne.ts
          • parity.test.ts
          • ro.ts
          • si.ts
          • sk.ts
          • sl.ts
          • sq.ts
          • sr.ts
          • tg.ts
          • tk.ts
          • uz.ts
    • desktop
      • AGENTS.md
      • src/renderer
        • i18n
          • am.ts
          • ar.ts
          • az.ts
          • bg.ts
          • bn.ts
          • br.ts
          • bs.ts
          • ca.ts
          • cs.ts
          • da.ts
          • de.ts
          • dv.ts
          • dz.ts
          • el.ts
          • en.ts
          • es.ts
          • et.ts
          • fa.ts
          • fi.ts
          • fo.ts
          • fr.ts
          • hi.ts
          • hr.ts
          • hu.ts
          • hy.ts
          • id.ts
          • index.ts
          • is.ts
          • it.ts
          • ja.ts
          • ka.ts
          • km.ts
          • ko.ts
          • lo.ts
          • lt.ts
          • lv.ts
          • mk.ts
          • mn.ts
          • ms.ts
          • my.ts
          • ne.ts
          • nl.ts
          • no.ts
          • pa.ts
          • pl.ts
          • ro.ts
          • ru.ts
          • si.ts
          • sk.ts
          • sl.ts
          • sq.ts
          • sr.ts
          • sv.ts
          • tg.ts
          • th.ts
          • tk.ts
          • tr.ts
          • uk.ts
          • ur.ts
          • uz.ts
          • vi.ts
          • zh.ts
          • zht.ts
        • index.tsx
    • ui
      • AGENTS.md
      • src/i18n
        • am.ts
        • bg.ts
        • bn.ts
        • ca.ts
        • cs.ts
        • dv.ts
        • dz.ts
        • el.ts
        • et.ts
        • fa.ts
        • fo.ts
        • hr.ts
        • hu.ts
        • hy.ts
        • is.ts
        • ka.ts
        • km.ts
        • lo.ts
        • lt.ts
        • lv.ts
        • mk.ts
        • mn.ts
        • ms.ts
        • my.ts
        • ne.ts
        • ro.ts
        • si.ts
        • sk.ts
        • sl.ts
        • sq.ts
        • sr.ts
        • tg.ts
        • tk.ts
        • uz.ts
  • script
    • translate-app.md
    • translate-app.test.ts
    • translate-app.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/app/AGENTS.md‎

Copy file name to clipboardExpand all lines: packages/app/AGENTS.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
- Prefer complete translated phrases. Do not concatenate grammatical fragments or make call sites assemble sentences. Keep placeholders to irreducible dynamic values such as names, paths, and counts.
2929
- If a translation cannot be expressed by the current API, deepen the shared language/UI i18n module so one typed call owns locale selection, plural resolution, fallback, and interpolation. Do not leak that machinery into product code.
3030
- Do not translate from model knowledge alone. Verify terminology and grammar with Unicode CLDR locale/plural data, Microsoft Localization Style Guides and terminology, Apple localization/style guidance and localized platform UI, Mozilla localization style guides, Mozilla Pontoon, and the Firefox localization corpus at `github.com/mozilla-l10n/firefox-l10n`.
31+
- For developer-facing terminology, prefer the words already used by the target language's developer community over literal dictionary translations. Cross-check maintained localized developer products such as Firefox, KDE, and VS Code; use at least two independent corpora when they are available. If established practice keeps an English loanword or acronym, keep it rather than inventing a translation.
32+
- Translate complete UI phrases in context. A glossary hit is evidence, not permission to translate word-by-word. Check terse labels such as session, prompt, agent, model, fork, shell, terminal, workspace, and worktree in the same grammatical role before choosing a term.
33+
- Before a locale is ready, audit recurring concepts for one consistent translation and review every value that still equals English. Classify retained English as a product name, provider/tool name, URL, code token, keyboard legend, acronym, asset name, or established borrowing; translate unexplained leftovers.
34+
- In translation review notes, name the corpora used and call out uncertain or region-specific terminology so native speakers can focus review where it matters.
3135
- Also use the relevant language authority or official dictionary for the locale (for example RAE/Fundéu, FranceTerme, Duden, TDK, Kotus/Kielitoimiston sanakirja, Språkrådet/Bokmålsordboka, Rada Języka Polskiego/PWN, the Russian and Arabic language academies, the Ukrainian Orthography, Taiwan MOE dictionaries, or the Royal Society of Thailand). Treat the English dictionary as the semantic source of truth and preserve placeholders, code identifiers, product names, and keyboard labels.
3236

3337
## Tool Calling
Collapse file

‎packages/app/src/context/language.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/context/language.tsx
+51-88Lines changed: 51 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ import { dict as en } from "@/i18n/en"
88
import { dict as uiEn } from "@opencode-ai/ui/i18n/en"
99
import {
1010
createDesktopNativeBundle,
11+
detectDesktopNativeLocale,
1112
DESKTOP_NATIVE_ENGLISH,
1213
DESKTOP_NATIVE_LABELS,
1314
DESKTOP_NATIVE_LOCALES,
15+
DESKTOP_NATIVE_LOCALE_TAGS,
1416
type DesktopNativeBundle,
1517
type DesktopNativeLocale,
1618
} from "@/i18n/desktop-native"
1719

1820
export type Locale = DesktopNativeLocale
1921
export type Direction = "ltr" | "rtl"
2022

21-
const RTL_LOCALES: ReadonlySet<Locale> = new Set(["ar", "ur", "pa"])
23+
const RTL_LOCALES: ReadonlySet<Locale> = new Set(["ar", "ur", "pa", "fa", "dv"])
2224

2325
function localeDirection(locale: Locale): Direction {
2426
return RTL_LOCALES.has(locale) ? "rtl" : "ltr"
@@ -39,36 +41,7 @@ function cookie(locale: Locale) {
3941

4042
const LOCALES: readonly Locale[] = DESKTOP_NATIVE_LOCALES
4143

42-
const INTL: Record<Locale, string> = {
43-
en: "en",
44-
zh: "zh-Hans",
45-
zht: "zh-Hant",
46-
ko: "ko",
47-
de: "de",
48-
es: "es",
49-
fr: "fr",
50-
da: "da",
51-
ja: "ja",
52-
pl: "pl",
53-
ru: "ru",
54-
uk: "uk",
55-
ar: "ar",
56-
no: "nb-NO",
57-
br: "pt-BR",
58-
th: "th",
59-
bs: "bs",
60-
tr: "tr",
61-
hi: "hi-IN",
62-
nl: "nl-NL",
63-
id: "id-ID",
64-
vi: "vi-VN",
65-
it: "it-IT",
66-
ur: "ur-PK",
67-
pa: "pa-Arab-PK",
68-
az: "az-Latn-AZ",
69-
fi: "fi-FI",
70-
sv: "sv-SE",
71-
}
44+
const INTL = DESKTOP_NATIVE_LOCALE_TAGS
7245

7346
const base = i18n.flatten({ ...en, ...uiEn })
7447
const dicts = new Map<Locale, Dictionary>([["en", base]])
@@ -104,6 +77,40 @@ const loaders: Record<Exclude<Locale, "en">, () => Promise<Dictionary>> = {
10477
az: () => merge(import("@/i18n/az"), import("@opencode-ai/ui/i18n/az")),
10578
fi: () => merge(import("@/i18n/fi"), import("@opencode-ai/ui/i18n/fi")),
10679
sv: () => merge(import("@/i18n/sv"), import("@opencode-ai/ui/i18n/sv")),
80+
am: () => merge(import("@/i18n/am"), import("@opencode-ai/ui/i18n/am")),
81+
bg: () => merge(import("@/i18n/bg"), import("@opencode-ai/ui/i18n/bg")),
82+
bn: () => merge(import("@/i18n/bn"), import("@opencode-ai/ui/i18n/bn")),
83+
ca: () => merge(import("@/i18n/ca"), import("@opencode-ai/ui/i18n/ca")),
84+
cs: () => merge(import("@/i18n/cs"), import("@opencode-ai/ui/i18n/cs")),
85+
dv: () => merge(import("@/i18n/dv"), import("@opencode-ai/ui/i18n/dv")),
86+
dz: () => merge(import("@/i18n/dz"), import("@opencode-ai/ui/i18n/dz")),
87+
el: () => merge(import("@/i18n/el"), import("@opencode-ai/ui/i18n/el")),
88+
et: () => merge(import("@/i18n/et"), import("@opencode-ai/ui/i18n/et")),
89+
fa: () => merge(import("@/i18n/fa"), import("@opencode-ai/ui/i18n/fa")),
90+
fo: () => merge(import("@/i18n/fo"), import("@opencode-ai/ui/i18n/fo")),
91+
hr: () => merge(import("@/i18n/hr"), import("@opencode-ai/ui/i18n/hr")),
92+
hu: () => merge(import("@/i18n/hu"), import("@opencode-ai/ui/i18n/hu")),
93+
hy: () => merge(import("@/i18n/hy"), import("@opencode-ai/ui/i18n/hy")),
94+
is: () => merge(import("@/i18n/is"), import("@opencode-ai/ui/i18n/is")),
95+
ka: () => merge(import("@/i18n/ka"), import("@opencode-ai/ui/i18n/ka")),
96+
km: () => merge(import("@/i18n/km"), import("@opencode-ai/ui/i18n/km")),
97+
lo: () => merge(import("@/i18n/lo"), import("@opencode-ai/ui/i18n/lo")),
98+
lt: () => merge(import("@/i18n/lt"), import("@opencode-ai/ui/i18n/lt")),
99+
lv: () => merge(import("@/i18n/lv"), import("@opencode-ai/ui/i18n/lv")),
100+
mk: () => merge(import("@/i18n/mk"), import("@opencode-ai/ui/i18n/mk")),
101+
mn: () => merge(import("@/i18n/mn"), import("@opencode-ai/ui/i18n/mn")),
102+
ms: () => merge(import("@/i18n/ms"), import("@opencode-ai/ui/i18n/ms")),
103+
my: () => merge(import("@/i18n/my"), import("@opencode-ai/ui/i18n/my")),
104+
ne: () => merge(import("@/i18n/ne"), import("@opencode-ai/ui/i18n/ne")),
105+
ro: () => merge(import("@/i18n/ro"), import("@opencode-ai/ui/i18n/ro")),
106+
si: () => merge(import("@/i18n/si"), import("@opencode-ai/ui/i18n/si")),
107+
sk: () => merge(import("@/i18n/sk"), import("@opencode-ai/ui/i18n/sk")),
108+
sl: () => merge(import("@/i18n/sl"), import("@opencode-ai/ui/i18n/sl")),
109+
sq: () => merge(import("@/i18n/sq"), import("@opencode-ai/ui/i18n/sq")),
110+
sr: () => merge(import("@/i18n/sr"), import("@opencode-ai/ui/i18n/sr")),
111+
tg: () => merge(import("@/i18n/tg"), import("@opencode-ai/ui/i18n/tg")),
112+
tk: () => merge(import("@/i18n/tk"), import("@opencode-ai/ui/i18n/tk")),
113+
uz: () => merge(import("@/i18n/uz"), import("@opencode-ai/ui/i18n/uz")),
107114
}
108115

109116
function loadDict(locale: Locale) {
@@ -121,63 +128,9 @@ export function loadLocaleDict(locale: Locale) {
121128
return loadDict(locale).then(() => undefined)
122129
}
123130

124-
const localeMatchers: Array<{ locale: Locale; match: (language: string) => boolean }> = [
125-
{ locale: "en", match: (language) => language.startsWith("en") },
126-
{
127-
locale: "zht",
128-
match: (language) =>
129-
language.startsWith("zh") &&
130-
(language.includes("hant") || language.includes("-tw") || language.includes("-hk") || language.includes("-mo")),
131-
},
132-
{ locale: "zh", match: (language) => language.startsWith("zh") },
133-
{ locale: "ko", match: (language) => language.startsWith("ko") },
134-
{ locale: "de", match: (language) => language.startsWith("de") },
135-
{ locale: "es", match: (language) => language.startsWith("es") },
136-
{ locale: "fr", match: (language) => language.startsWith("fr") },
137-
{ locale: "da", match: (language) => language.startsWith("da") },
138-
{ locale: "ja", match: (language) => language.startsWith("ja") },
139-
{ locale: "pl", match: (language) => language.startsWith("pl") },
140-
{ locale: "ru", match: (language) => language.startsWith("ru") },
141-
{ locale: "uk", match: (language) => language.startsWith("uk") },
142-
{ locale: "ar", match: (language) => language.startsWith("ar") },
143-
{
144-
locale: "no",
145-
match: (language) => language.startsWith("no") || language.startsWith("nb") || language.startsWith("nn"),
146-
},
147-
{ locale: "br", match: (language) => language.startsWith("pt") },
148-
{ locale: "th", match: (language) => language.startsWith("th") },
149-
{ locale: "bs", match: (language) => language.startsWith("bs") },
150-
{ locale: "tr", match: (language) => language.startsWith("tr") },
151-
{ locale: "hi", match: (language) => language.startsWith("hi") },
152-
{ locale: "nl", match: (language) => language.startsWith("nl") },
153-
{ locale: "id", match: (language) => language.startsWith("id") },
154-
{ locale: "vi", match: (language) => language.startsWith("vi") },
155-
{ locale: "it", match: (language) => language.startsWith("it") },
156-
{ locale: "ur", match: (language) => language.startsWith("ur") },
157-
{
158-
locale: "pa",
159-
match: (language) => language.startsWith("pa") && (language.includes("arab") || language.includes("-pk")),
160-
},
161-
{
162-
locale: "az",
163-
match: (language) => language.startsWith("az") && !language.includes("arab") && !language.includes("cyrl"),
164-
},
165-
{ locale: "fi", match: (language) => language.startsWith("fi") },
166-
{ locale: "sv", match: (language) => language.startsWith("sv") },
167-
]
168-
169131
function detectLocale(): Locale {
170132
if (typeof navigator !== "object") return "en"
171-
172-
const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
173-
for (const language of languages) {
174-
if (!language) continue
175-
const normalized = language.toLowerCase()
176-
const match = localeMatchers.find((entry) => entry.match(normalized))
177-
if (match) return match.locale
178-
}
179-
180-
return "en"
133+
return detectDesktopNativeLocale(navigator.languages?.length ? navigator.languages : [navigator.language])
181134
}
182135

183136
export function normalizeLocale(value: string): Locale {
@@ -198,7 +151,17 @@ function readStoredLocale() {
198151
}
199152

200153
const warm = readStoredLocale() ?? detectLocale()
201-
if (warm !== "en") void loadDict(warm)
154+
const initialLocale =
155+
warm === "en"
156+
? Promise.resolve(warm)
157+
: loadDict(warm).then(
158+
() => warm,
159+
() => "en" as const,
160+
)
161+
162+
export function loadInitialLocale() {
163+
return initialLocale
164+
}
202165

203166
export const { use: useLanguage, provider: LanguageProvider } = createSimpleContext({
204167
name: "Language",
@@ -244,7 +207,7 @@ export const { use: useLanguage, provider: LanguageProvider } = createSimpleCont
244207
createEffect(() => {
245208
if (typeof document !== "object") return
246209
const value = locale()
247-
document.documentElement.lang = value
210+
document.documentElement.lang = intl()
248211
document.documentElement.dir = direction()
249212
document.cookie = cookie(value)
250213
})
Collapse file

‎packages/app/src/entry.tsx‎

Copy file name to clipboardExpand all lines: packages/app/src/entry.tsx
+28-25Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as Sentry from "@sentry/solid"
44
import { render } from "solid-js/web"
55
import { AppBaseProviders, AppInterface } from "@/app"
6+
import { loadInitialLocale } from "@/context/language"
67
import { type Platform, PlatformProvider } from "@/context/platform"
78
import { createBrowserDraftStore } from "@/utils/draft-store"
89
import { dict as en } from "@/i18n/en"
@@ -149,29 +150,31 @@ if (import.meta.env.VITE_SENTRY_DSN) {
149150
}
150151

151152
if (root instanceof HTMLElement) {
152-
const auth = authFromToken(new URLSearchParams(location.search).get("auth_token"))
153-
clearAuthToken()
154-
const server: ServerConnection.Http = {
155-
type: "http",
156-
authToken: !!auth,
157-
http: {
158-
url: getCurrentUrl(),
159-
...auth,
160-
},
161-
}
162-
render(
163-
() => (
164-
<PlatformProvider value={platform}>
165-
<AppBaseProviders>
166-
<AppInterface
167-
defaultServer={ServerConnection.Key.make(getDefaultUrl())}
168-
canonicalLocalServer={ServerConnection.key(server)}
169-
servers={[server]}
170-
disableHealthCheck
171-
/>
172-
</AppBaseProviders>
173-
</PlatformProvider>
174-
),
175-
root,
176-
)
153+
void loadInitialLocale().then((locale) => {
154+
const auth = authFromToken(new URLSearchParams(location.search).get("auth_token"))
155+
clearAuthToken()
156+
const server: ServerConnection.Http = {
157+
type: "http",
158+
authToken: !!auth,
159+
http: {
160+
url: getCurrentUrl(),
161+
...auth,
162+
},
163+
}
164+
render(
165+
() => (
166+
<PlatformProvider value={platform}>
167+
<AppBaseProviders locale={locale}>
168+
<AppInterface
169+
defaultServer={ServerConnection.Key.make(getDefaultUrl())}
170+
canonicalLocalServer={ServerConnection.key(server)}
171+
servers={[server]}
172+
disableHealthCheck
173+
/>
174+
</AppBaseProviders>
175+
</PlatformProvider>
176+
),
177+
root,
178+
)
179+
})
177180
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.