Languages
How the restaurant runs in English and Arabic, how to change any text, and what to change to add a language.
For the Full Stack package
The languages that ship
English and Arabic, in all three apps. Arabic lays the whole interface out right to left, with IBM Plex Sans Arabic on the website, and figures stay in Latin digits in both languages.
| App | English | Arabic |
|---|---|---|
| Ordering website | /en/… | /ar/… |
| Staff dashboard | /en/… | /ar/… |
| API | Accept-Language: en | Accept-Language: ar |
English is the default. Dishes, categories, the combo, kitchens and the homepage sections are stored with every text in both languages, entered side by side in the dashboard, and the seed fills in the Arabic for all of them.
How the language is chosen
- The language is the first part of the address. A path without one goes to
/en. - The language switcher swaps that part of the address and keeps the page.
- On the website, the direction is set before the first paint, so an Arabic page never flashes left to right.
- Both frontends send the page's language to the API, so its messages come back in the same language. An order remembers the language it was placed in.
Change a text
Every visible word lives in messages/<namespace>/en.json and ar.json, in each frontend's folder. Change the value, keep the key, and change it in both files.
| App | Namespaces |
|---|---|
| Ordering website | account, auth, cart, checkout, common, home, layouts, legal, locations, seo, store, support, tracking, wishlist |
| Staff dashboard | ai-assistant, auth, common, dashboard (with a folder per page), demo-credentials, layouts |
- A key missing from
ar.jsonshows as a missing message on the Arabic side, so keep the two files in step. - Text inside
{curly}braces is filled in by the app, such as{count}or{name}. Keep those words as they are in both languages. - The dashboard's sidebar labels are messages too, under
navinmessages/dashboard/en.jsonandar.json.
What the API translates
- Error messages and the
messageof a successful write come back in the language of theAccept-Languageheader.ar-SAcounts as Arabic; any language the API does not have falls back to English. - Errors a customer sees, such as a closed kitchen, go out as keys like
errors.kitchen_closed, and the website shows its own sentence for each. - Its own texts are JSON files in
back-end/src/i18n/translations/en/andar/, one per area:admin,auth,category,common,mail,order,product,roles,settings,users. The password-reset email is inmail. - Dishes and the other menu records come back with both languages, as
{ "en": "…", "ar": "…" }, and the frontend picks one.
Add a language to the website
The two languages are written into a few files, so adding a third touches each of them. Paths are inside storefront/.
- Add the code to
localesinsrc/config/i18n.ts, insrc/proxy.tsand insrc/app/[locale]/layout.tsx. - Copy every
messages/<namespace>/en.jsonto a file named after the new code, and translate the values. - If the language is written right to left, extend the direction check in
src/app/layout.tsx, which only knowsar. - Add the new code to
src/components/LanguageSwitcher.tsx, and its texts tosrc/config/brand.config.ts, which holds the names and the home page's title inenandar. - Components that pick a menu text by language, such as the search results, the category bar and the kitchen map, choose between
enandar. Searchsrc/for"ar"and handle the new code there too.
Add a language to the dashboard
- Add the code to
localesinsrc/config/i18n.ts,src/proxy.tsandsrc/app/[locale]/layout.tsx, and to the language lists insrc/components/LanguageSwitcher.tsx, the user menu and the Language setting. - Copy every
messages/**/en.jsonto a file named after the new code, and translate the values. - The forms enter each menu text in English and Arabic side by side (
src/components/ui/LanguageTabs.tsxand the two-language inputs). A third language there also needs the API to store it.
Add a language to the API
The API knows en and ar in back-end/src/i18n/i18n.service.ts and in the order and contact checks. Add the new code there, copy src/i18n/translations/en/ to a folder named after it, and translate the files. Menu records store an { en, ar } pair, so a third language in the data is a change to those records and the seed.