Skip to content

Key Concepts › Localization

Overview

Every Tjjar storefront speaks Arabic and English, and Arabic is the default. This page is how the storefront decides which one a page is in, and what that means for your theme.

How the language is chosen

In order:

  1. ?locale=ar or ?locale=en in the address. An explicit choice always wins.
  2. The browser's languages, in the order it lists them — the first that is Arabic or English.
  3. Arabic.

Your theme does not choose. It reads the result:

ValueExample
request.localear
request.directionrtl
request.other_localeen
request.other_locale_url/?locale=en — for a switch

Addresses

The Arabic page has no parameter: https://elite.tjjar.shop/ is the Arabic homepage, and https://elite.tjjar.shop/?locale=en the English one. {% wajha_head %} tells search engines the two are the same page in two languages, and names the Arabic one as the default.

A language switch should always name the language it switches to. That is what request.other_locale_url does — a link to / alone would send an English-speaking browser straight back to English:

<a href="{{ request.other_locale_url }}" lang="{{ request.other_locale }}"
   hreflang="{{ request.other_locale }}">{{ t.nav.other_language }}</a>

Three things to get right

  • Direction — lay out with logical CSS properties so the page mirrors. See RTL & Arabic.
  • Numbers and money — Latin digits in Arabic, and never compute with an amount. See Money, Dates & Numerals.
  • Your strings — in locales/ar.json and locales/en.json, with the same keys. See Translation Files.