Languages

How Arabic and English work, how to edit texts, and how to add a third language.

How it works

Every page lives under a language prefix: /ar/... (the default, right to left) and /en/.... The language switch keeps you on the same page. The <html> tag gets lang and dir from the prefix, and layouts use logical CSS (ms-, ps-, start, end), so the whole interface mirrors by itself. Directional icons (arrows, chevrons) flip; logos, numbers and video controls do not.

Numbers are Latin digits in both languages, as is usual for prices and dates in Oman. Prices use Intl.NumberFormat with the OMR currency (25.000 ر.ع. / OMR 25.000).

Interface texts

All interface texts are in messages/ar.json and messages/en.json, grouped by page (home, course, checkout, dashboard...). Edit them freely. Plurals use ICU syntax; Arabic has six plural forms:

"lessonsCount": "{count, plural, =0 {لا دروس} one {درس واحد} two {درسان} few {# دروس} many {# درسًا} other {# درس}}"

npm test checks that every key used in the code exists in both files and that the two files have the same keys.

Content

Courses, lessons, quizzes, categories, instructors, articles and settings have an Arabic and an English column for every text (titleAr, titleEn...). Fill both in the dashboard. A course also has a teaching language (ar or en): an English-taught course still has an Arabic title and description so Arabic visitors can find it, and the catalogue can filter by teaching language.

Adding a language

  1. Add the code to src/i18n/routing.ts (locales: ["ar", "en", "fr"]) and to the proxy pattern in src/proxy.ts.
  2. Copy messages/en.json to messages/fr.json and translate it.
  3. Content columns are Ar/En. For a third language either add ...Fr columns in prisma/schema.prisma and the forms, or show English content for the new language (search the code for ar ? and L( to see where the choice is made).
  4. Add the docs folder docs/fr/ if you ship the docs.