Language

How to enable a new language on a multilingual site

Language is decided by the address and the primary language exclusively owns the bare address; bulk enabling can be replayed safely, missing translations fall back and are marked honestly, and switching the primary language is a change of address ownership.

From "checking the box" to "visitors can see it", a new language has only two things in between: what address it gets, and how the parts without translations answer honestly.

Language is decided by the address, not by the browser

The primary language exclusively owns the bare address. When Chinese is the primary language, the home page is / and English is at /en/; after switching the primary language to English, / is English and the former Chinese content moves to /cn/. Detail pages follow the same shape.

Switching the primary language is a change of address ownership, not a change of display. The same address now points at other content, and a redirect cannot fix that — so when it would really change hands, the backend requires you to tick a confirmation before it allows saving. If the system pretended / still pointed at the old content, search engines, your customers and you yourself would all be wrong.

After a new language is enabled, the frontend reads the row in the translation table. When there is no translation, the system falls back by convention and marks it honestly, never passing the source language off as the target language. Seeing the occasional Chinese sentence on a foreign-language page is an honest display, not broken translation.

Bulk enabling is a replayable operation

The backend can enable a batch of languages at once. It is one transaction, an idempotent write: it only raises "enabled", and does not change the display name or touch the primary language. So if an error occurs midway, clicking again will not hit a unique key or leave the site stuck halfway.

Display names are filled in from the language catalog bundled with the system. Codes the catalog recognizes go through the catalog; entering a code outside the catalog yourself is also allowed, in which case the external prefix takes the primary subtag, the writing direction is treated as left-to-right, and the backend shows it together with the reason "this is a fallback value" — guessing the direction would flip an entire left-to-right language around, and that kind of error just looks like a typography oddity.

Chinese's external prefix is cn

The internal language code is zh-CN, and the external address prefix is cn. The two layers are separate: the prefix is used for routing, navigation, canonical, hreflang, the sitemap and RSS, while the internal code is used to read and write translation rows. Change one and forget the other, and the symptom is "clicking the switcher 404s" or "hreflang points at an address that does not exist".

Disabling and renaming cannot lose the primary language

The primary language cannot be disabled; renaming a language does not incidentally clear its primary-language status. This invariant (exactly one language that is "enabled and primary") is judged inside the write transaction, before commit, so the rejected attempt writes nothing to disk.

What order to follow

Enable the language first, then check whether it is in the target-language list (if that list was explicitly saved, a newly enabled language must be added once more in the panel), then send for translation, and finally click through the frontend once per language: the switcher, the detail pages, the list pages, and the address shapes in the sitemap and RSS.