GhaylStackDocumentationv1.0.2
العربيةWebsite
Web and mobile

Web and mobile

Arabic, English and RTL

Follow language detection, load translation catalogs and verify a complete Arabic interface.

How the client selects a language

The web clients use i18next. In Dashboard, detection checks the culture query parameter, then the application's local-storage language, then the browser preference. The runtime defaultLanguage supplies a fallback. The canonical tags for this guide are ar-OM and en-US.

Open /login?culture=ar-OM to begin an Arabic session or /login?culture=en-US for English. Dashboard persists the choice under fsh.dashboard.lng; this is the real compatibility key in the current source. Replacing it with a guessed GhaylStack-prefixed key will not change the application's language.

Load text before displaying the route

The shell's English common, auth and notifications catalogs are available immediately. Route-specific English catalogs load on demand. lazyNamed waits for a page and its namespaces together. changeLanguage loads the requested language's bundles before asking i18next to switch, preventing a half-translated page during the transition.

For a new route namespace, create matching JSON files in src/locales/en-US and src/locales/ar-OM. Register the English import in lazyCatalogs in src/i18n.ts, and list the namespace in the route's lazyNamed call. The Arabic bundle in src/locales/ar-OM.ts discovers JSON catalogs automatically through import.meta.glob; adding the file to the directory is sufficient, without manually editing the bundle. The Catalogs type drives translation-key checks. Follow the existing structure rather than inserting standalone strings in JSX.

RTL applies to layout as well as text

The languageChanged listener sets the document's lang and dir from the language actually resolved by i18next. CSS should use logical spacing such as margin-inline-start, and icons that indicate direction need a contextual review. Keep technical values, paths and command examples readable from left to right.

Do not mirror a logo, image or chart merely because the surrounding text is Arabic. A screenshot contains its own language: a translated caption does not translate its pixels. Website galleries should select an actual Arabic capture for Arabic pages and keep the corresponding English capture for English pages.

Add and verify a translation

Use an existing namespace for a related feature. Add matching keys to both catalogs, render them with useTranslation, and specify that namespace in the route's lazy import. For an entirely new namespace, register it in lazyCatalogs before using the new key type. Test plural and interpolation paths, not just a single count.

sh
cd clients/dashboard
npx playwright test tests/i18n/ar-completeness.spec.ts tests/i18n/rtl-layout.spec.ts tests/i18n/route-namespaces.spec.ts

These commands select existing browser suites; see testing for prerequisites. Check a direct page load, language switching while already signed in, a hard refresh, dates, currency, long Arabic labels and empty/error states. Inspect the document direction as well as the visible text.

Diagnose partial English output

An English fallback can indicate a missing Arabic key, a namespace omitted from the route, or a language chunk that did not load. A visible raw key is a different failure: confirm the key spelling and the namespace. The development console warns about missing keys. Diagnose the catalog and loading path before trying a global replacement of text nodes.

Implementation references

View MarkdownBack to top

Search documentation

Use ↑ ↓ to move, Enter to open and Esc to close.