GeezerVison is showing github.com — fix(site): finish the docs UI labels and stamp intentional English (#… · erickwill/opencode@2204311
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: services/site/src/i18n/ar.ts +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,7 +31,6 @@ export const dict = { | 31 | 31 | "legal.englishOnly": "هذا المستند متاح باللغة الإنجليزية فقط.", | 32 | 32 | "notFound.title": "الصفحة غير موجودة | OpenCode", | 33 | 33 | "notFound.heading": "404 - الصفحة غير موجودة", | 34 | | - "notFound.home": "الرئيسية", | 35 | 34 | "notFound.docs": "الوثائق", | 36 | 35 | "notFound.github": "GitHub", | 37 | 36 | "notFound.discord": "Discord", | @@ -48,7 +47,6 @@ export const dict = { | 48 | 47 | "home.title": "OpenCode | وكيل برمجة مفتوح المصدر لأي نموذج", | 49 | 48 | "temp.title": "OpenCode | وكيل برمجة صُمّم للطرفية", | 50 | 49 | "temp.hero.title": "وكيل برمجة صُمّم للطرفية", | 51 | | - "temp.zen": "OpenCode Models", | 52 | 50 | "temp.feature.models.beforeLink": "يدعم أكثر من 200 مزوّد لنماذج LLM عبر", | 53 | 51 | "home.banner.badge": "جديد", | 54 | 52 | "home.promo.title": "علامات التبويب تصل إلى Desktop", | @@ -189,7 +187,6 @@ export const dict = { | 189 | 187 | "go.faq.a4.p2.accountLink": "حسابك", | 190 | 188 | "go.faq.a4.p3": "ألغِ في أي وقت.", | 191 | 189 | "go.faq.q5": "ماذا عن البيانات والخصوصية؟", | 192 | | - "go.faq.a5.model": "النموذج", | 193 | 190 | "go.faq.a5.training": "تدريب النموذج", | 194 | 191 | "go.faq.a5.retention": "الاحتفاظ بالبيانات", | 195 | 192 | "go.faq.a5.retention30": "30 يومًا", | @@ -211,7 +208,6 @@ export const dict = { | 211 | 208 | "go.faq.q9": "ما الفرق بين النماذج المجانية وGo؟", | 212 | 209 | "go.faq.a9": | 213 | 210 | "تشمل النماذج المجانية Big Pickle والنماذج الترويجية المتاحة حينها. يقدّم Go نماذج مختارة بحصص طلبات أعلى على فترات متجدّدة: 20% من الحد الشهري لكل 5 ساعات، و50% لكل أسبوع، و100% لكل شهر. وقد يختلف الحد من نموذج إلى آخر، ويختلف العدد الفعلي للطلبات حسب النموذج والاستخدام.", | 214 | | - "workspace.nav.zen": "OpenCode Models", | 215 | 211 | "workspace.newUser.feature.lockin.body": | 216 | 212 | "استخدم OpenCode Models مع أي وكيل برمجة، وواصل استخدام مزوّدين آخرين مع OpenCode متى شئت.", | 217 | 213 | "download.hero.title": "نزّل OpenCode Desktop", | @@ -371,7 +367,7 @@ export const dict = { | 371 | 367 | "docs.codeExamples": "أمثلة الكود", | 372 | 368 | "docs.code.terminal": "الطرفية", | 373 | 369 | "docs.code.files": "الملفات", | 374 | | - "docs.code.diff": "Diff", | | 370 | + "docs.code.diff": "الفروق", | 375 | 371 | "docs.callout.note": "ملاحظة", | 376 | 372 | "docs.callout.tip": "نصيحة", | 377 | 373 | "docs.callout.caution": "تنبيه", | @@ -660,7 +656,6 @@ export const dict = { | 660 | 656 | "site.action.forOsBeta": "تنزيل لـ {{os}}، نسخة Apple TestFlight التجريبية", | 661 | 657 | "site.action.storeBeta": "{{os}}، نسخة Apple TestFlight التجريبية", | 662 | 658 | "home.companies.labelShort": "ثقة أكثر من 22 مليون مطوّر", | 663 | | - "nav.subscription": "الاشتراك", | 664 | 659 | "go.referral.ended.label": "تحذير", | 665 | 660 | "go.referral.ended": "انتهى برنامج الإحالة. لم تعد روابط الإحالة تمنح رصيدًا لك أو للشخص الذي شاركها.", | 666 | 661 | "legal.status.operational": "كل الأنظمة تعمل", | |
Collapse file Copy file name to clipboardExpand all lines: services/site/src/i18n/br.ts +1-6Lines changed: 1 addition & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,6 @@ export const dict = { | 20 | 20 | "nav.context.copyLogo": "Copiar logo como SVG", | 21 | 21 | "nav.context.copyWordmark": "Copiar logotipo em SVG", | 22 | 22 | "nav.context.brandAssets": "Kit da marca", | 23 | | - "nav.subscription": "Assinatura", | 24 | 23 | "footer.github": "GitHub", | 25 | 24 | "footer.docs": "Docs", | 26 | 25 | "footer.changelog": "Changelog", | @@ -32,7 +31,6 @@ export const dict = { | 32 | 31 | "legal.englishOnly": "Este documento está disponível apenas em inglês.", | 33 | 32 | "notFound.title": "Página não encontrada | OpenCode", | 34 | 33 | "notFound.heading": "404 — Página não encontrada", | 35 | | - "notFound.home": "Início", | 36 | 34 | "notFound.docs": "Documentação", | 37 | 35 | "notFound.github": "GitHub", | 38 | 36 | "notFound.discord": "Discord", | @@ -43,13 +41,12 @@ export const dict = { | 43 | 41 | "common.create": "Criar", | 44 | 42 | "common.videoUnsupported": "Seu navegador não suporta a tag de vídeo.", | 45 | 43 | "common.figure": "Fig {{n}}.", | 46 | | - "common.faq": "FAQ", | | 44 | + "common.faq": "Perguntas frequentes", | 47 | 45 | "common.learnMore": "Saiba mais", | 48 | 46 | "app.meta.description": "OpenCode - O agente de codificação de código aberto.", | 49 | 47 | "home.title": "OpenCode | O agente de codificação de código aberto para qualquer modelo", | 50 | 48 | "temp.title": "OpenCode | Agente de codificação feito para o terminal", | 51 | 49 | "temp.hero.title": "O agente de codificação feito para o terminal", | 52 | | - "temp.zen": "OpenCode Models", | 53 | 50 | "temp.feature.models.beforeLink": "Compatível com mais de 200 provedores de LLM via", | 54 | 51 | "home.banner.badge": "Novo", | 55 | 52 | "home.promo.title": "Conheça as abas do Desktop", | @@ -204,7 +201,6 @@ export const dict = { | 204 | 201 | "go.faq.a4.p2.accountLink": "conta", | 205 | 202 | "go.faq.a4.p3": "Cancele a qualquer momento.", | 206 | 203 | "go.faq.q5": "E quanto aos dados e à privacidade?", | 207 | | - "go.faq.a5.model": "Modelo", | 208 | 204 | "go.faq.a5.training": "Treinamento de modelos", | 209 | 205 | "go.faq.a5.retention": "Retenção de dados", | 210 | 206 | "go.faq.a5.retention30": "30 dias", | @@ -228,7 +224,6 @@ export const dict = { | 228 | 224 | "go.faq.q9": "Qual a diferença entre os modelos grátis e o Go?", | 229 | 225 | "go.faq.a9": | 230 | 226 | "Os modelos grátis incluem Big Pickle e os modelos em promoção no momento. O Go oferece uma seleção de modelos com cotas de requisições mais altas em janelas móveis de 5 horas, uma semana e um mês, limitadas a 20%, 50% e 100% da cota mensal, respectivamente. A cota de uso pode variar por modelo. O número efetivo de requisições depende do modelo e do uso.", | 231 | | - "workspace.nav.zen": "OpenCode Models", | 232 | 227 | "workspace.newUser.feature.lockin.body": | 233 | 228 | "Use OpenCode Models com qualquer agente de codificação e continue usando outros provedores com OpenCode quando quiser.", | 234 | 229 | "download.title": "OpenCode | Baixe para macOS, Windows, Linux e celular", | |
Collapse file Copy file name to clipboardExpand all lines: services/site/src/i18n/check.ts +55-13Lines changed: 55 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | // the page copy (src/i18n/content/<locale>.ts). Run it from services/site: | 3 | 3 | // | 4 | 4 | // bun src/i18n/check.ts [locale ...] [--stamp] | | 5 | +// bun src/i18n/check.ts locale --stamp --keep-english=entry [--keep-english=entry ...] | 5 | 6 | // | 6 | 7 | // Errors (exit 1, and test/i18n.test.ts fails): a dictionary key the English doesn't have, and a | 7 | 8 | // translation whose {{params}}, [text](link) ids or `code` spans differ from the English. | 8 | 9 | // Warnings: entries still in English that were never reviewed, entries whose English changed since | 9 | 10 | // they were translated, and page copy the English no longer has (an item whose English title | 10 | 11 | // changed, for example), which no page shows. A stamp (src/i18n/stamps/<locale>.json) records a hash of the English | 11 | | -// each entry was translated from; --stamp records the current English for every translated entry, | 12 | | -// so run it once everything the check lists is translated. | | 12 | +// each entry was translated from; --stamp records the current English for every translated entry. | | 13 | +// Use --keep-english=entry for each reviewed entry that should stay as written. | 13 | 14 | import path from "node:path" | 14 | 15 | import { dict as en } from "~/i18n/en" | 15 | 16 | import { LOCALES, type Locale } from "~/lib/language" | @@ -24,32 +25,42 @@ type Report = { | 24 | 25 | stale: string[] | 25 | 26 | unused: string[] | 26 | 27 | stamps: Record<string, string> | | 28 | + review: Record<string, string> | 27 | 29 | } | 28 | 30 |
| 29 | 31 | const stampDir = path.join(import.meta.dir, "stamps") | 30 | 32 |
| | 33 | +type Entry = { id: string; english: string; value?: string; inherited?: boolean } | | 34 | + | 31 | 35 | /** Every check for one locale. `stamps` is what --stamp would write. */ | 32 | 36 | export async function checkLocale(locale: Exclude<Locale, "en">): Promise<Report> { | 33 | 37 | const dict: Record<string, string> = (await import(`./${locale}.ts`)).dict | 34 | 38 | const content: unknown = (await import(`./content/${locale}.ts`)).content | 35 | 39 | const file = Bun.file(path.join(stampDir, `${locale}.json`)) | 36 | 40 | const stamps: Record<string, string> = (await file.exists()) ? await file.json() : {} | 37 | | - const report: Report = { locale, errors: [], untranslated: [], stale: [], unused: [], stamps: {} } | | 41 | + const report: Report = { locale, errors: [], untranslated: [], stale: [], unused: [], stamps: {}, review: {} } | 38 | 42 |
| 39 | 43 | const english = en as Record<string, string> | 40 | 44 | Object.keys(dict) | 41 | 45 | .filter((key) => !(key in english)) | 42 | 46 | .forEach((key) => report.errors.push(`${key}: not in the English dictionary`)) | 43 | | - const entries = [ | | 47 | + const englishContent = contentSource((key, params) => interpolate(english[key], params)) | | 48 | + const localizedContent = contentSource((key, params) => interpolate(dict[key] || english[key], params)) | | 49 | + const entries: Entry[] = [ | 44 | 50 | ...Object.keys(english).map((key) => ({ id: key, english: english[key], value: dict[key] })), | 45 | | - ...contentEntries(contentSource((key, params) => interpolate(english[key], params)), content, "", report.unused).map((entry) => ({ ...entry, id: `content:${entry.id}` })), | | 51 | + ...contentEntries(englishContent, localizedContent, content, "", report.unused), | 46 | 52 | ] | 47 | 53 | for (const entry of entries) { | | 54 | + // A translation inherited from the dictionary is already tracked under its dictionary key. | | 55 | + if (entry.inherited) continue | 48 | 56 | const hash = Bun.hash(entry.english).toString(36) | 49 | 57 | const translated = entry.value !== undefined && entry.value !== "" && entry.value !== entry.english | 50 | 58 | if (translated) report.errors.push(...mismatches(entry.id, entry.english, entry.value!)) | 51 | 59 | if (translated || stamps[entry.id]) report.stamps[entry.id] = translated ? hash : stamps[entry.id] | 52 | | - if (!translated && !stamps[entry.id]) report.untranslated.push(entry.id) | | 60 | + if (!translated && !stamps[entry.id]) { | | 61 | + report.untranslated.push(entry.id) | | 62 | + report.review[entry.id] = hash | | 63 | + } | 53 | 64 | if (stamps[entry.id] && stamps[entry.id] !== hash) report.stale.push(entry.id) | 54 | 65 | } | 55 | 66 | return report | @@ -77,28 +88,42 @@ function mismatches(id: string, english: string, value: string) { | 77 | 88 | * path content/index.ts merges on (keyed list items by item id). Entries the English doesn't have go | 78 | 89 | * to `unused`. | 79 | 90 | */ | 80 | | -function contentEntries(base: unknown, overlay: unknown, at: string, unused: string[]): { id: string; english: string; value?: string }[] { | | 91 | +function contentEntries(base: unknown, localized: unknown, overlay: unknown, at: string, unused: string[]): Entry[] { | 81 | 92 | if (typeof base === "string") { | 82 | 93 | if (structuralPaths.some((pattern) => matches(pattern, at))) return [] | 83 | | - return [{ id: at, english: base, value: typeof overlay === "string" ? overlay : undefined }] | | 94 | + const value = typeof overlay === "string" && overlay ? overlay : undefined | | 95 | + return [ | | 96 | + { | | 97 | + id: `content:${at}`, | | 98 | + english: base, | | 99 | + value, | | 100 | + inherited: value === undefined && typeof localized === "string" && localized !== base, | | 101 | + }, | | 102 | + ] | 84 | 103 | } | 85 | 104 | const join = (key: string) => (at ? `${at}.${key}` : key) | 86 | 105 | if (Array.isArray(base)) { | 87 | 106 | const list: readonly unknown[] = base | | 107 | + const translated: readonly unknown[] = Array.isArray(localized) ? localized : [] | 88 | 108 | if (keyedList(list)) { | 89 | 109 | const ids = itemIds(list) | 90 | 110 | const items = (isRecord(overlay) ? overlay : {}) as Record<string, unknown> | 91 | 111 | Object.keys(items) | 92 | 112 | .filter((id) => !ids.includes(id)) | 93 | 113 | .forEach((id) => unused.push(`content:${join(id)}`)) | 94 | | - return list.flatMap((item, index) => contentEntries(item, items[ids[index]], join(ids[index]), unused)) | | 114 | + return list.flatMap((item, index) => | | 115 | + contentEntries(item, translated[index], items[ids[index]], join(ids[index]), unused), | | 116 | + ) | 95 | 117 | } | 96 | 118 | const items = Array.isArray(overlay) ? overlay : [] | 97 | 119 | items.slice(list.length).forEach((_, index) => unused.push(`content:${join(String(list.length + index))}`)) | 98 | | - return list.flatMap((item, index) => contentEntries(item, items[index], join(String(index)), unused)) | | 120 | + return list.flatMap((item, index) => | | 121 | + contentEntries(item, translated[index], items[index], join(String(index)), unused), | | 122 | + ) | 99 | 123 | } | 100 | 124 | if (!isRecord(base)) return [] | 101 | 125 | const values = (isRecord(overlay) ? overlay : {}) as Record<string, unknown> | | 126 | + const translated = isRecord(localized) ? localized : {} | 102 | 127 | const fields = Object.keys(base).filter( | 103 | 128 | (key) => | 104 | 129 | !(structural as readonly string[]).includes(key) && | @@ -107,7 +132,7 @@ function contentEntries(base: unknown, overlay: unknown, at: string, unused: str | 107 | 132 | Object.keys(values) | 108 | 133 | .filter((key) => !fields.includes(key)) | 109 | 134 | .forEach((key) => unused.push(`content:${join(key)}`)) | 110 | | - return fields.flatMap((key) => contentEntries(base[key], values[key], join(key), unused)) | | 135 | + return fields.flatMap((key) => contentEntries(base[key], translated[key], values[key], join(key), unused)) | 111 | 136 | } | 112 | 137 |
| 113 | 138 | function isRecord(value: unknown): value is Record<string, unknown> { | @@ -123,14 +148,26 @@ function matches(pattern: string, at: string) { | 123 | 148 | if (import.meta.main) { | 124 | 149 | const args = process.argv.slice(2) | 125 | 150 | const stamp = args.includes("--stamp") | | 151 | + const keepEnglish = args | | 152 | + .filter((arg) => arg.startsWith("--keep-english=")) | | 153 | + .map((arg) => arg.slice("--keep-english=".length)) | 126 | 154 | const asked = args.filter((arg) => !arg.startsWith("--")) | | 155 | + if (keepEnglish.length && (!stamp || asked.length !== 1)) { | | 156 | + console.error("--keep-english requires --stamp and exactly one locale") | | 157 | + process.exit(2) | | 158 | + } | 127 | 159 | const unknown = asked.filter((arg) => !(LOCALES as readonly string[]).includes(arg) || arg === "en") | 128 | 160 | if (unknown.length) { | 129 | 161 | console.error(`unknown locale ${unknown.join(", ")}; use one of ${LOCALES.slice(1).join(" ")}`) | 130 | 162 | process.exit(2) | 131 | 163 | } | 132 | 164 | const locales = (asked.length ? asked : LOCALES.slice(1)) as Exclude<Locale, "en">[] | 133 | 165 | const reports = await Promise.all(locales.map(checkLocale)) | | 166 | + const invalid = keepEnglish.filter((id) => !Object.hasOwn(reports[0].review, id)) | | 167 | + if (invalid.length) { | | 168 | + console.error(`not awaiting English review: ${invalid.join(", ")}`) | | 169 | + process.exit(2) | | 170 | + } | 134 | 171 | for (const report of reports) { | 135 | 172 | console.log( | 136 | 173 | `${report.locale}: ${report.errors.length} errors, ${report.untranslated.length} untranslated, ${report.stale.length} changed in English, ${report.unused.length} unused`, | @@ -141,8 +178,13 @@ if (import.meta.main) { | 141 | 178 | report.stale.forEach((id) => console.log(` todo ${id} (English changed)`)) | 142 | 179 | report.unused.forEach((id) => console.log(` unused ${id} (no English to translate)`)) | 143 | 180 | } | 144 | | - if (stamp && !report.errors.length) | 145 | | - await Bun.write(path.join(stampDir, `${report.locale}.json`), `${JSON.stringify(sortKeys(report.stamps), null, 2)}\n`) | | 181 | + if (stamp && !report.errors.length) { | | 182 | + keepEnglish.forEach((id) => (report.stamps[id] = report.review[id])) | | 183 | + await Bun.write( | | 184 | + path.join(stampDir, `${report.locale}.json`), | | 185 | + `${JSON.stringify(sortKeys(report.stamps), null, 2)}\n`, | | 186 | + ) | | 187 | + } | 146 | 188 | } | 147 | 189 | if (reports.some((report) => report.errors.length)) process.exit(1) | 148 | 190 | } | |
Collapse file Copy file name to clipboardExpand all lines: services/site/src/i18n/da.ts +2-7Lines changed: 2 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,7 +31,6 @@ export const dict = { | 31 | 31 | "legal.englishOnly": "Dette dokument findes kun på engelsk.", | 32 | 32 | "notFound.title": "Siden blev ikke fundet | OpenCode", | 33 | 33 | "notFound.heading": "404 – Siden blev ikke fundet", | 34 | | - "notFound.home": "Hjem", | 35 | 34 | "notFound.docs": "Dokumentation", | 36 | 35 | "notFound.github": "GitHub", | 37 | 36 | "notFound.discord": "Discord", | @@ -48,7 +47,6 @@ export const dict = { | 48 | 47 | "home.title": "OpenCode | Open source-kodningsagenten til alle modeller", | 49 | 48 | "temp.title": "opencode | Kodningsagent bygget til terminalen", | 50 | 49 | "temp.hero.title": "Kodningsagenten til terminalen", | 51 | | - "temp.zen": "OpenCode Models", | 52 | 50 | "temp.feature.models.beforeLink": "Understøtter 200+ LLM-udbydere gennem", | 53 | 51 | "home.banner.badge": "Ny", | 54 | 52 | "home.promo.title": "Nye faner i Desktop", | @@ -202,7 +200,6 @@ export const dict = { | 202 | 200 | "go.faq.a4.p2.accountLink": "konto", | 203 | 201 | "go.faq.a4.p3": "Opsig når som helst.", | 204 | 202 | "go.faq.q5": "Hvad med data og privatliv?", | 205 | | - "go.faq.a5.model": "Model", | 206 | 203 | "go.faq.a5.training": "Modeltræning", | 207 | 204 | "go.faq.a5.retention": "Dataopbevaring", | 208 | 205 | "go.faq.a5.retention30": "30 dage", | @@ -225,7 +222,6 @@ export const dict = { | 225 | 222 | "go.faq.q9": "Hvad er forskellen på gratis modeller og Go?", | 226 | 223 | "go.faq.a9": | 227 | 224 | "De gratis modeller omfatter Big Pickle og de kampagnemodeller, der er tilgængelige lige nu. Go tilbyder udvalgte modeller med højere anmodningskvoter i rullende perioder: 20 % af månedskvoten pr. 5 timer, 50 % pr. uge og 100 % pr. måned. Kvoterne kan variere fra model til model. Det faktiske antal anmodninger afhænger af model og forbrug.", | 228 | | - "workspace.nav.zen": "OpenCode Models", | 229 | 225 | "workspace.newUser.feature.lockin.body": | 230 | 226 | "Brug OpenCode Models med din foretrukne kodningsagent, og brug stadig andre udbydere i OpenCode, når du vil.", | 231 | 227 | "download.title": "OpenCode | Download til macOS, Windows, Linux og mobil", | @@ -518,7 +514,7 @@ export const dict = { | 518 | 514 | "OpenCode er en open source-agent, der hjælper dig med at skrive og køre kode med enhver AI-model. Den findes som desktopapp, terminalbrugerflade, mobilapp og SDK.", | 519 | 515 | "home.faq.a5.body": | 520 | 516 | "Nej. OpenCode findes også som [desktopapp](desktop) og [mobilapp](mobile), og med [SDK'et](sdk) kan du styre det fra din egen kode.", | 521 | | - "brand.ui.downloadLabel": "Download {{label}}", | | 517 | + "brand.ui.downloadLabel": "Hent {{label}}", | 522 | 518 | "brand.ui.downloadItem": "Download {{label}} til {{detail}}", | 523 | 519 | "brand.ui.moreFormats": "Flere formater af {{detail}}", | 524 | 520 | "brand.ui.badgeSize": "Badgestørrelse", | @@ -718,7 +714,7 @@ export const dict = { | 718 | 714 | "enterprise.form.inferenceSpend.label": "Hvad bruger din virksomhed på inferens om måneden (USD)?", | 719 | 715 | "enterprise.form.inferenceSpend.placeholder": "Vælg et interval (valgfrit)", | 720 | 716 | "enterprise.form.inferenceSpend.none": "Intet forbrug endnu", | 721 | | - "enterprise.form.inferenceSpend.under1k": "Under $1K", | | 717 | + "enterprise.form.inferenceSpend.under1k": "Under 1.000 USD", | 722 | 718 | "enterprise.form.inferenceSpend.1kTo10k": "$1K–$10K", | 723 | 719 | "enterprise.form.inferenceSpend.10kTo50k": "$10K–$50K", | 724 | 720 | "enterprise.form.inferenceSpend.50kTo100k": "$50K–$100K", | @@ -728,5 +724,4 @@ export const dict = { | 728 | 724 | "home.openSource.avatarProfile": "{{login}} på GitHub", | 729 | 725 | "home.install.or": "eller", | 730 | 726 | "brand.ui.actionOf": "{{label}} af {{detail}}", | 731 | | - "nav.subscription": "Abonnement", | 732 | 727 | } satisfies Dict |
|