Languages and RTL
Every storefront URL starts with a locale: /en/…, /de/…, /ar/…. Each locale maps one-to-one to a Magento store view, which decides the catalog language, prices, currency and content. Five ship out of the box: English, German, Spanish, French and Arabic.
Where locales come from
Section titled “Where locales come from”- At build,
npm run sync:storesasks Magento for its store views and writes a committed snapshot. If Magento can’t be reached, the committed snapshot is used. - In the config, each store view becomes a URL locale: the language of its Magento locale (
de_DEbecomes/de). The website’s default store view is the default locale.storeViewsinmagenx.config.tscan exclude a view, rename its locale (two views sharing a language), or pick the default. - At boot, the storefront compares the snapshot with the running Magento and logs
[store-drift]when a view changed after the build.STORE_DRIFT_CHECK=0turns this off.
Prices and dates use the URL locale for formatting and the store view’s display currency.
Which locale a visitor gets
Section titled “Which locale a visitor gets”/ has no locale. nginx redirects it, and any other locale-less path, to:
- the
NEXT_LOCALEcookie, set by the language switcher, when it names a known locale; - otherwise the first matching language in the browser’s
Accept-Language; - otherwise the default locale.
Payment return URLs always carry the locale; old locale-less /order/* links are redirected to the default one.
Translations
Section titled “Translations”UI text comes from apps/theme/src/i18n/messages/<locale>.json (next-intl). Catalog and CMS content comes from the store view in Magento.
Only the message namespaces that client components use are sent to the browser (CLIENT_MESSAGE_NAMESPACES in src/i18n/client-namespaces.ts). Server components read the full set. When a client component starts using a new namespace, add it to that list, or the browser shows a MISSING_MESSAGE error.
Right-to-left
Section titled “Right-to-left”Locales in RTL_LOCALES (ar, he, fa, ur) render with dir="rtl". The theme uses logical CSS properties (start/end instead of left/right), so the whole layout mirrors without separate styles. Icons that point a direction flip with rtl:-scale-x-100.
Add a language
Section titled “Add a language”- Create the store view in Magento, with its locale and display currency.
- Run
npm run sync:storesand commitapps/theme/src/generated/stores.json. - Add
apps/theme/src/i18n/messages/<locale>.json, translated fromen.json. - In magenxcommerce-docker, add the locale to the
$detected_localeand$preferred_localemaps innginx/templates/maps/headless.conf.template, and to the localelocationregex innginx/templates/locations/storefront_locale.conf.template. - Run
npm test.locale-surfaces.test.tsfails until every locale in the store snapshot has a messages file. The nginx lists are not tested here: keep them in sync by hand.