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
7 changes: 1 addition & 6 deletions services/site/src/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const dict = {
"legal.englishOnly": "هذا المستند متاح باللغة الإنجليزية فقط.",
"notFound.title": "الصفحة غير موجودة | OpenCode",
"notFound.heading": "404 - الصفحة غير موجودة",
"notFound.home": "الرئيسية",
"notFound.docs": "الوثائق",
"notFound.github": "GitHub",
"notFound.discord": "Discord",
Expand All @@ -48,7 +47,6 @@ export const dict = {
"home.title": "OpenCode | وكيل برمجة مفتوح المصدر لأي نموذج",
"temp.title": "OpenCode | وكيل برمجة صُمّم للطرفية",
"temp.hero.title": "وكيل برمجة صُمّم للطرفية",
"temp.zen": "OpenCode Models",
"temp.feature.models.beforeLink": "يدعم أكثر من 200 مزوّد لنماذج LLM عبر",
"home.banner.badge": "جديد",
"home.promo.title": "علامات التبويب تصل إلى Desktop",
Expand Down Expand Up @@ -189,7 +187,6 @@ export const dict = {
"go.faq.a4.p2.accountLink": "حسابك",
"go.faq.a4.p3": "ألغِ في أي وقت.",
"go.faq.q5": "ماذا عن البيانات والخصوصية؟",
"go.faq.a5.model": "النموذج",
"go.faq.a5.training": "تدريب النموذج",
"go.faq.a5.retention": "الاحتفاظ بالبيانات",
"go.faq.a5.retention30": "30 يومًا",
Expand All @@ -211,7 +208,6 @@ export const dict = {
"go.faq.q9": "ما الفرق بين النماذج المجانية وGo؟",
"go.faq.a9":
"تشمل النماذج المجانية Big Pickle والنماذج الترويجية المتاحة حينها. يقدّم Go نماذج مختارة بحصص طلبات أعلى على فترات متجدّدة: 20% من الحد الشهري لكل 5 ساعات، و50% لكل أسبوع، و100% لكل شهر. وقد يختلف الحد من نموذج إلى آخر، ويختلف العدد الفعلي للطلبات حسب النموذج والاستخدام.",
"workspace.nav.zen": "OpenCode Models",
"workspace.newUser.feature.lockin.body":
"استخدم OpenCode Models مع أي وكيل برمجة، وواصل استخدام مزوّدين آخرين مع OpenCode متى شئت.",
"download.hero.title": "نزّل OpenCode Desktop",
Expand Down Expand Up @@ -371,7 +367,7 @@ export const dict = {
"docs.codeExamples": "أمثلة الكود",
"docs.code.terminal": "الطرفية",
"docs.code.files": "الملفات",
"docs.code.diff": "Diff",
"docs.code.diff": "الفروق",
"docs.callout.note": "ملاحظة",
"docs.callout.tip": "نصيحة",
"docs.callout.caution": "تنبيه",
Expand Down Expand Up @@ -660,7 +656,6 @@ export const dict = {
"site.action.forOsBeta": "تنزيل لـ {{os}}، نسخة Apple TestFlight التجريبية",
"site.action.storeBeta": "{{os}}، نسخة Apple TestFlight التجريبية",
"home.companies.labelShort": "ثقة أكثر من 22 مليون مطوّر",
"nav.subscription": "الاشتراك",
"go.referral.ended.label": "تحذير",
"go.referral.ended": "انتهى برنامج الإحالة. لم تعد روابط الإحالة تمنح رصيدًا لك أو للشخص الذي شاركها.",
"legal.status.operational": "كل الأنظمة تعمل",
Expand Down
7 changes: 1 addition & 6 deletions services/site/src/i18n/br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const dict = {
"nav.context.copyLogo": "Copiar logo como SVG",
"nav.context.copyWordmark": "Copiar logotipo em SVG",
"nav.context.brandAssets": "Kit da marca",
"nav.subscription": "Assinatura",
"footer.github": "GitHub",
"footer.docs": "Docs",
"footer.changelog": "Changelog",
Expand All @@ -32,7 +31,6 @@ export const dict = {
"legal.englishOnly": "Este documento está disponível apenas em inglês.",
"notFound.title": "Página não encontrada | OpenCode",
"notFound.heading": "404 — Página não encontrada",
"notFound.home": "Início",
"notFound.docs": "Documentação",
"notFound.github": "GitHub",
"notFound.discord": "Discord",
Expand All @@ -43,13 +41,12 @@ export const dict = {
"common.create": "Criar",
"common.videoUnsupported": "Seu navegador não suporta a tag de vídeo.",
"common.figure": "Fig {{n}}.",
"common.faq": "FAQ",
"common.faq": "Perguntas frequentes",
"common.learnMore": "Saiba mais",
"app.meta.description": "OpenCode - O agente de codificação de código aberto.",
"home.title": "OpenCode | O agente de codificação de código aberto para qualquer modelo",
"temp.title": "OpenCode | Agente de codificação feito para o terminal",
"temp.hero.title": "O agente de codificação feito para o terminal",
"temp.zen": "OpenCode Models",
"temp.feature.models.beforeLink": "Compatível com mais de 200 provedores de LLM via",
"home.banner.badge": "Novo",
"home.promo.title": "Conheça as abas do Desktop",
Expand Down Expand Up @@ -204,7 +201,6 @@ export const dict = {
"go.faq.a4.p2.accountLink": "conta",
"go.faq.a4.p3": "Cancele a qualquer momento.",
"go.faq.q5": "E quanto aos dados e à privacidade?",
"go.faq.a5.model": "Modelo",
"go.faq.a5.training": "Treinamento de modelos",
"go.faq.a5.retention": "Retenção de dados",
"go.faq.a5.retention30": "30 dias",
Expand All @@ -228,7 +224,6 @@ export const dict = {
"go.faq.q9": "Qual a diferença entre os modelos grátis e o Go?",
"go.faq.a9":
"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.",
"workspace.nav.zen": "OpenCode Models",
"workspace.newUser.feature.lockin.body":
"Use OpenCode Models com qualquer agente de codificação e continue usando outros provedores com OpenCode quando quiser.",
"download.title": "OpenCode | Baixe para macOS, Windows, Linux e celular",
Expand Down
68 changes: 55 additions & 13 deletions services/site/src/i18n/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// the page copy (src/i18n/content/<locale>.ts). Run it from services/site:
//
// bun src/i18n/check.ts [locale ...] [--stamp]
// bun src/i18n/check.ts locale --stamp --keep-english=entry [--keep-english=entry ...]
//
// Errors (exit 1, and test/i18n.test.ts fails): a dictionary key the English doesn't have, and a
// translation whose {{params}}, [text](link) ids or `code` spans differ from the English.
// Warnings: entries still in English that were never reviewed, entries whose English changed since
// they were translated, and page copy the English no longer has (an item whose English title
// changed, for example), which no page shows. A stamp (src/i18n/stamps/<locale>.json) records a hash of the English
// each entry was translated from; --stamp records the current English for every translated entry,
// so run it once everything the check lists is translated.
// each entry was translated from; --stamp records the current English for every translated entry.
// Use --keep-english=entry for each reviewed entry that should stay as written.
import path from "node:path"
import { dict as en } from "~/i18n/en"
import { LOCALES, type Locale } from "~/lib/language"
Expand All @@ -24,32 +25,42 @@ type Report = {
stale: string[]
unused: string[]
stamps: Record<string, string>
review: Record<string, string>
}

const stampDir = path.join(import.meta.dir, "stamps")

type Entry = { id: string; english: string; value?: string; inherited?: boolean }

/** Every check for one locale. `stamps` is what --stamp would write. */
export async function checkLocale(locale: Exclude<Locale, "en">): Promise<Report> {
const dict: Record<string, string> = (await import(`./${locale}.ts`)).dict
const content: unknown = (await import(`./content/${locale}.ts`)).content
const file = Bun.file(path.join(stampDir, `${locale}.json`))
const stamps: Record<string, string> = (await file.exists()) ? await file.json() : {}
const report: Report = { locale, errors: [], untranslated: [], stale: [], unused: [], stamps: {} }
const report: Report = { locale, errors: [], untranslated: [], stale: [], unused: [], stamps: {}, review: {} }

const english = en as Record<string, string>
Object.keys(dict)
.filter((key) => !(key in english))
.forEach((key) => report.errors.push(`${key}: not in the English dictionary`))
const entries = [
const englishContent = contentSource((key, params) => interpolate(english[key], params))
const localizedContent = contentSource((key, params) => interpolate(dict[key] || english[key], params))
const entries: Entry[] = [
...Object.keys(english).map((key) => ({ id: key, english: english[key], value: dict[key] })),
...contentEntries(contentSource((key, params) => interpolate(english[key], params)), content, "", report.unused).map((entry) => ({ ...entry, id: `content:${entry.id}` })),
...contentEntries(englishContent, localizedContent, content, "", report.unused),
]
for (const entry of entries) {
// A translation inherited from the dictionary is already tracked under its dictionary key.
if (entry.inherited) continue
const hash = Bun.hash(entry.english).toString(36)
const translated = entry.value !== undefined && entry.value !== "" && entry.value !== entry.english
if (translated) report.errors.push(...mismatches(entry.id, entry.english, entry.value!))
if (translated || stamps[entry.id]) report.stamps[entry.id] = translated ? hash : stamps[entry.id]
if (!translated && !stamps[entry.id]) report.untranslated.push(entry.id)
if (!translated && !stamps[entry.id]) {
report.untranslated.push(entry.id)
report.review[entry.id] = hash
}
if (stamps[entry.id] && stamps[entry.id] !== hash) report.stale.push(entry.id)
}
return report
Expand Down Expand Up @@ -77,28 +88,42 @@ function mismatches(id: string, english: string, value: string) {
* path content/index.ts merges on (keyed list items by item id). Entries the English doesn't have go
* to `unused`.
*/
function contentEntries(base: unknown, overlay: unknown, at: string, unused: string[]): { id: string; english: string; value?: string }[] {
function contentEntries(base: unknown, localized: unknown, overlay: unknown, at: string, unused: string[]): Entry[] {
if (typeof base === "string") {
if (structuralPaths.some((pattern) => matches(pattern, at))) return []
return [{ id: at, english: base, value: typeof overlay === "string" ? overlay : undefined }]
const value = typeof overlay === "string" && overlay ? overlay : undefined
return [
{
id: `content:${at}`,
english: base,
value,
inherited: value === undefined && typeof localized === "string" && localized !== base,
},
]
}
const join = (key: string) => (at ? `${at}.${key}` : key)
if (Array.isArray(base)) {
const list: readonly unknown[] = base
const translated: readonly unknown[] = Array.isArray(localized) ? localized : []
if (keyedList(list)) {
const ids = itemIds(list)
const items = (isRecord(overlay) ? overlay : {}) as Record<string, unknown>
Object.keys(items)
.filter((id) => !ids.includes(id))
.forEach((id) => unused.push(`content:${join(id)}`))
return list.flatMap((item, index) => contentEntries(item, items[ids[index]], join(ids[index]), unused))
return list.flatMap((item, index) =>
contentEntries(item, translated[index], items[ids[index]], join(ids[index]), unused),
)
}
const items = Array.isArray(overlay) ? overlay : []
items.slice(list.length).forEach((_, index) => unused.push(`content:${join(String(list.length + index))}`))
return list.flatMap((item, index) => contentEntries(item, items[index], join(String(index)), unused))
return list.flatMap((item, index) =>
contentEntries(item, translated[index], items[index], join(String(index)), unused),
)
}
if (!isRecord(base)) return []
const values = (isRecord(overlay) ? overlay : {}) as Record<string, unknown>
const translated = isRecord(localized) ? localized : {}
const fields = Object.keys(base).filter(
(key) =>
!(structural as readonly string[]).includes(key) &&
Expand All @@ -107,7 +132,7 @@ function contentEntries(base: unknown, overlay: unknown, at: string, unused: str
Object.keys(values)
.filter((key) => !fields.includes(key))
.forEach((key) => unused.push(`content:${join(key)}`))
return fields.flatMap((key) => contentEntries(base[key], values[key], join(key), unused))
return fields.flatMap((key) => contentEntries(base[key], translated[key], values[key], join(key), unused))
}

function isRecord(value: unknown): value is Record<string, unknown> {
Expand All @@ -123,14 +148,26 @@ function matches(pattern: string, at: string) {
if (import.meta.main) {
const args = process.argv.slice(2)
const stamp = args.includes("--stamp")
const keepEnglish = args
.filter((arg) => arg.startsWith("--keep-english="))
.map((arg) => arg.slice("--keep-english=".length))
const asked = args.filter((arg) => !arg.startsWith("--"))
if (keepEnglish.length && (!stamp || asked.length !== 1)) {
console.error("--keep-english requires --stamp and exactly one locale")
process.exit(2)
}
const unknown = asked.filter((arg) => !(LOCALES as readonly string[]).includes(arg) || arg === "en")
if (unknown.length) {
console.error(`unknown locale ${unknown.join(", ")}; use one of ${LOCALES.slice(1).join(" ")}`)
process.exit(2)
}
const locales = (asked.length ? asked : LOCALES.slice(1)) as Exclude<Locale, "en">[]
const reports = await Promise.all(locales.map(checkLocale))
const invalid = keepEnglish.filter((id) => !Object.hasOwn(reports[0].review, id))
if (invalid.length) {
console.error(`not awaiting English review: ${invalid.join(", ")}`)
process.exit(2)
}
for (const report of reports) {
console.log(
`${report.locale}: ${report.errors.length} errors, ${report.untranslated.length} untranslated, ${report.stale.length} changed in English, ${report.unused.length} unused`,
Expand All @@ -141,8 +178,13 @@ if (import.meta.main) {
report.stale.forEach((id) => console.log(` todo ${id} (English changed)`))
report.unused.forEach((id) => console.log(` unused ${id} (no English to translate)`))
}
if (stamp && !report.errors.length)
await Bun.write(path.join(stampDir, `${report.locale}.json`), `${JSON.stringify(sortKeys(report.stamps), null, 2)}\n`)
if (stamp && !report.errors.length) {
keepEnglish.forEach((id) => (report.stamps[id] = report.review[id]))
await Bun.write(
path.join(stampDir, `${report.locale}.json`),
`${JSON.stringify(sortKeys(report.stamps), null, 2)}\n`,
)
}
}
if (reports.some((report) => report.errors.length)) process.exit(1)
}
Expand Down
9 changes: 2 additions & 7 deletions services/site/src/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const dict = {
"legal.englishOnly": "Dette dokument findes kun på engelsk.",
"notFound.title": "Siden blev ikke fundet | OpenCode",
"notFound.heading": "404 – Siden blev ikke fundet",
"notFound.home": "Hjem",
"notFound.docs": "Dokumentation",
"notFound.github": "GitHub",
"notFound.discord": "Discord",
Expand All @@ -48,7 +47,6 @@ export const dict = {
"home.title": "OpenCode | Open source-kodningsagenten til alle modeller",
"temp.title": "opencode | Kodningsagent bygget til terminalen",
"temp.hero.title": "Kodningsagenten til terminalen",
"temp.zen": "OpenCode Models",
"temp.feature.models.beforeLink": "Understøtter 200+ LLM-udbydere gennem",
"home.banner.badge": "Ny",
"home.promo.title": "Nye faner i Desktop",
Expand Down Expand Up @@ -202,7 +200,6 @@ export const dict = {
"go.faq.a4.p2.accountLink": "konto",
"go.faq.a4.p3": "Opsig når som helst.",
"go.faq.q5": "Hvad med data og privatliv?",
"go.faq.a5.model": "Model",
"go.faq.a5.training": "Modeltræning",
"go.faq.a5.retention": "Dataopbevaring",
"go.faq.a5.retention30": "30 dage",
Expand All @@ -225,7 +222,6 @@ export const dict = {
"go.faq.q9": "Hvad er forskellen på gratis modeller og Go?",
"go.faq.a9":
"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.",
"workspace.nav.zen": "OpenCode Models",
"workspace.newUser.feature.lockin.body":
"Brug OpenCode Models med din foretrukne kodningsagent, og brug stadig andre udbydere i OpenCode, når du vil.",
"download.title": "OpenCode | Download til macOS, Windows, Linux og mobil",
Expand Down Expand Up @@ -518,7 +514,7 @@ export const dict = {
"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.",
"home.faq.a5.body":
"Nej. OpenCode findes også som [desktopapp](desktop) og [mobilapp](mobile), og med [SDK'et](sdk) kan du styre det fra din egen kode.",
"brand.ui.downloadLabel": "Download {{label}}",
"brand.ui.downloadLabel": "Hent {{label}}",
"brand.ui.downloadItem": "Download {{label}} til {{detail}}",
"brand.ui.moreFormats": "Flere formater af {{detail}}",
"brand.ui.badgeSize": "Badgestørrelse",
Expand Down Expand Up @@ -718,7 +714,7 @@ export const dict = {
"enterprise.form.inferenceSpend.label": "Hvad bruger din virksomhed på inferens om måneden (USD)?",
"enterprise.form.inferenceSpend.placeholder": "Vælg et interval (valgfrit)",
"enterprise.form.inferenceSpend.none": "Intet forbrug endnu",
"enterprise.form.inferenceSpend.under1k": "Under $1K",
"enterprise.form.inferenceSpend.under1k": "Under 1.000 USD",
"enterprise.form.inferenceSpend.1kTo10k": "$1K–$10K",
"enterprise.form.inferenceSpend.10kTo50k": "$10K–$50K",
"enterprise.form.inferenceSpend.50kTo100k": "$50K–$100K",
Expand All @@ -728,5 +724,4 @@ export const dict = {
"home.openSource.avatarProfile": "{{login}} på GitHub",
"home.install.or": "eller",
"brand.ui.actionOf": "{{label}} af {{detail}}",
"nav.subscription": "Abonnement",
} satisfies Dict
Loading
Loading