Languages¶
rendimiento speaks English and Mexican Spanish (es-MX).
In the browser¶
The account's menu (your name, at the right of the top bar; on a phone, the sheet at the bottom) has a language switch (ES / EN). What you choose is remembered in that browser. Dates and numbers follow the language too.
Until you choose, the language is picked like this:
- the one chosen before with the switch, in this browser;
- else the first of the browser's languages (in its order of preference) that is Spanish or English;
- else, when the browser asks for neither, the one of the country you visit from, as Cloudflare tells it (the
CF-IPCountryheader): Spanish for Mexico, Spain and the other Spanish-speaking countries, English for the rest. The server puts onlyesorenin the page (<meta name="rendimiento-lang-pais">), never the country, and keeps nothing; without Cloudflare in front, this step is skipped; - else English.
The API answers in the same way (i18n.FromRequest). A request without Accept-Language at all, like a search engine's crawler or a script, is answered in English wherever it comes from.
The Spanish is formal (usted) and translates technical terms: despliegue, construcción (build), versión, reversión, complemento, confirmación (commit), envío (push), solicitud de incorporación (pull request), cubeta (bucket), balanceador de carga, entrada (ingress), demonio (daemon).
In this book¶
The book is in both languages too: the switch is in its header. A page's Spanish sits next to it (page.es.md beside page.md, with mkdocs-static-i18n); a page not translated yet shows in English in the Spanish book. Translated headings keep their English anchor (## Título {#english-title}), so links between pages work in both books.
In emails¶
NOTIFY_LANG sets the language of notification emails: en (the default) or es.
Messages from the platform¶
What the platform writes for people (environment checks, run and release results, problems, validation errors, emails) is written in English with i18n.M, which is fmt.Sprintf and also marks the format for translation. It is translated when it is shown, not when it is made:
- the API sees
Accept-Language: esand translates the JSON it answers with: sentences (message,summary,details,error…) through the catalog's patterns; short labels (name,title) word for word, or through a pattern only when it has enough fixed text of its own, so an app's own name never changes; - a finished English message is matched against the catalog's formats and the Spanish one is formatted with the same values, which may move (
%[2]s) and are translated themselves; lists (a; b) translate part by part.
So messages stored long ago translate too, and code that makes messages needs no language.
Adding text¶
- In the UI, write the phrase in English inside
t("…")(ortn(n, "one", "many")for a count) and add its Spanish toweb/src/i18n/es.ts.npm run typecheckfails if a phrase has no Spanish or its{placeholders}differ. - In Go, make the message with
M("format %s", value)and add the format's Spanish tointernal/i18n/es.go.TestCatalogfails if a format has no Spanish or a different number of values.