Languages
How the site runs in English and Arabic, how to change any text, and how to add a language.
The languages that ship
English and Arabic. English is the default. Arabic lays the whole page out right to left, in the Noto Sans Arabic font.
| Language | Address | Direction |
|---|---|---|
| English | /en | Left to right |
| Arabic | /ar | Right to left |
How the language is chosen
- The language is the first part of the address,
/enor/ar. - The address
/sends visitors to the language their browser prefers, English or Arabic, and to English otherwise. - The switcher in the header has one link for every other language. It swaps that part of the address and keeps the visitor on the same page.
- Each page sets its language and direction, and lists the other language for search engines.
Change a text
Every visible word lives in messages/en.json and messages/ar.json. Both files have the same keys: change the value in each, never the key. A key missing from one file shows as its name on that language's page.
Right to left
src/i18n/direction.ts lists the right-to-left languages, and the layout sets the page's direction from it. The components use logical Tailwind classes such as ms-*, pe-*, start-* and text-start, so spacing and alignment mirror by themselves. Arrows that point in the reading direction carry rtl:rotate-180.
In markup you add, use the same logical classes instead of ml-*, pr-*, left-* or text-left. Otherwise it looks right in English and wrong in Arabic.
Add a language
Add its code
Add the language's code to
localesinsrc/i18n/routing.ts, for examplefr.src/i18n/routing.tslocales: ["en", "ar", "fr"],Add its messages
Copy
messages/en.jsontomessages/fr.jsonand translate the values. Add the language's name underlocaleSwitcher.namesin every message file.Right to left?
If the language is written right to left, add its code to
RTL_LOCALESinsrc/i18n/direction.ts.Check the font
src/app/[locale]/layout.tsxuses Noto Sans Arabic forarand Inter, in Latin letters only, for every other language. A language in another script needs its own font there.Expected result: After a restart or a new build, the new language opens at its own address, such as
/fr, and the switcher in the header links to it.