Languages

Arabic and English, how texts are organised, and how to add a language.

Sufra ships in Arabic (default, right to left) and English. Every page has its language in the address (/ar/menu, /en/menu) and a switch in the header and the dashboard menu. Visiting / opens Arabic.

Interface texts

Every button, label, message and error is in messages/ar.json and messages/en.json, with the same keys. For example:

"checkout": {
  "title": "Checkout",
  "place": "Place order · {total}"
}

Edit the text, keep the key and the {placeholders}. The two files must have the same keys: a missing key shows the key name on the page.

Restaurant content

Content entered in the dashboard is stored in both languages, in pairs of database columns: nameAr / nameEn, descAr / descEn for categories, dishes and options, and taglineAr / taglineEn, addressAr / addressEn in the settings. The dashboard forms show both fields side by side.

Orders keep a copy of the dish names in both languages, so changing the menu later never changes past orders.

Right to left

The page direction comes from the language (dir="rtl" for Arabic, in src/app/[locale]/layout.tsx). Components use logical spacing (ms-, me-, ps-, start-, end-), so layouts mirror automatically. Phone numbers, codes and prices are marked dir="ltr" so they read correctly inside Arabic text, and numbers use Latin digits in both languages.

Default language

Change defaultLocale in src/i18n/routing.ts:

export const routing = defineRouting({ locales: ["ar", "en"], defaultLocale: "en", localePrefix: "always" });

Adding a language

Adding a third language (for example Urdu or French) touches three places:

  1. src/i18n/routing.ts: add the code to locales.
  2. messages/<code>.json: copy en.json and translate it.
  3. The database: add columns for the new language (nameUr, descUr, ...) in prisma/schema.prisma, run npx prisma db push, then add the fields to the dashboard forms (src/components/dash/MenuManager.tsx, SettingsForm.tsx). Content is chosen per language by the pick() helper in src/components/shop/ShopProvider.tsx and, in server pages, by expressions like locale === "ar" ? d.nameAr : d.nameEn: search the project for === "ar" and extend each one.

For a right-to-left language, also update isRtl() in src/i18n/routing.ts.