stack88
Browse the documentation

Guides

Internationalization

Three languages from the start, one of them right to left, in every app and in the API.

Every app ships in English, French and Arabic. Arabic is written right to left, so a layout that works in it works in any language you add later.

One catalog for the API, web and mobile

packages/i18n holds JSON catalogs, one folder per locale and one file per namespace: common, auth, emails and errors. The API reads them through @nestjs/i18n, and the web and mobile apps through i18next. Both read the same single-brace {name} placeholders.

A test fails when a locale is missing a namespace or a key, so a new string cannot ship in English alone.

Plurals

Copy with a count carries the forms each language needs: two in English and French, six in Arabic. A counted string in an Arabic catalog looks like this:

JSON
{
  "items_zero": "لا عناصر",
  "items_one": "عنصر واحد",
  "items_two": "عنصران",
  "items_few": "{count} عناصر",
  "items_many": "{count} عنصرًا",
  "items_other": "{count} عنصر"
}

The catalog test checks every plural key against the language’s own plural rules, so a missing Arabic form fails it.

Error messages

The API writes its error messages in the language the client sent in Accept-Language, from the errors namespace. Every error code has a message there; a code without one fails the API’s typecheck. Clients branch on the stable errorCode and show the message as it arrives.

Right to left

The web app writes the locale’s direction to <html dir>, and every layout uses logical CSS: ps-4 rather than pl-4, ms-auto rather than ml-auto, text-start rather than text-left. Arabic then mirrors without a second stylesheet. Arrows that mean back or next flip with rtl:-scale-x-100.

The showcase

The Astro site compiles its own catalogs with Paraglide JS, so its pages ship no translation runtime. Its routes are translated as well: /fr/articles/… and /ar/مقالات/… are the French and Arabic paths of /posts/…. The showcase README covers both.