Skip to content

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.

npm run sync:stores(before every build)at boot: compare

Magento store views
(availableStores)

src/generated/stores.json
(committed)

magenx.config.ts
stores

URL locales
/en /de /ar …

[store-drift] log

  • At build, npm run sync:stores asks 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_DE becomes /de). The website’s default store view is the default locale. storeViews in magenx.config.ts can 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=0 turns this off.

Prices and dates use the URL locale for formatting and the store view’s display currency.

/ has no locale. nginx redirects it, and any other locale-less path, to:

  1. the NEXT_LOCALE cookie, set by the language switcher, when it names a known locale;
  2. otherwise the first matching language in the browser’s Accept-Language;
  3. otherwise the default locale.

Payment return URLs always carry the locale; old locale-less /order/* links are redirected to the default one.

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.

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.

  1. Create the store view in Magento, with its locale and display currency.
  2. Run npm run sync:stores and commit apps/theme/src/generated/stores.json.
  3. Add apps/theme/src/i18n/messages/<locale>.json, translated from en.json.
  4. In magenxcommerce-docker, add the locale to the $detected_locale and $preferred_locale maps in nginx/templates/maps/headless.conf.template, and to the locale location regex in nginx/templates/locations/storefront_locale.conf.template.
  5. Run npm test. locale-surfaces.test.ts fails until every locale in the store snapshot has a messages file. The nginx lists are not tested here: keep them in sync by hand.