le-hoetel

Languages and RTL

English, French and Arabic, and how right to left works across the apps.

@le-hoetel/i18n owns the languages. en is the default, fr and ar are translated. Arabic is right to left.

Where the language comes from

AppSource
webthe url: / is English, /fr is French, /ar is Arabic. The proxy rewrites the prefix and sets x-locale
dashboardthe language switcher cookie, else the browser's Accept-Language
docsEnglish only for now. Fumadocs i18n needs a translated copy of every page, so it waits until the product copy is stable

Direction and metadata

Use the helpers from @le-hoetel/i18n (or @le-hoetel/i18n/config when you only need the pure functions, like in emails):

  • htmlAttributes(locale) returns { lang, dir } for <html> and email layouts
  • getDirection(locale) is "ltr" or "rtl"
  • LOCALE_META[locale] has dir, hreflang and ogLocale
  • alternateUrls(origin, pathname) is the hreflang map, with x-default. The web layout writes it into every page and the sitemap
  • The social card (apps/web/app/opengraph-image.tsx) is drawn per language; the Arabic card loads Cairo from apps/web/assets and lays words out one by one because satori reorders wrapped RTL text
  • robots.txt blocks /h/, /s/, /u/, /o/ and /api/, and everything on previews and localhost. /llms.txt on the web app lists the landing pages and the FAQ in English

Email layouts take a locale prop and set lang and dir from it. Guest pages must use the same helpers.

Missing keys

getMessages(locale) merges the locale over en, so a key that is not translated yet shows the English text instead of an error. English is the source of truth and its keys type t("...").

Writing RTL safe css

  • use logical classes: ms-, me-, ps-, pe-, start-, end-, text-start, border-s. Never ml-, pr-, left-, text-left
  • icons that point somewhere (arrows, chevrons) get rtl:rotate-180
  • the dashboard sidebar moves to the right in Arabic
  • translating a string: add the key to messages/en.json, then fr.json and ar.json

The Arabic font is part of the design tokens and fonts work, not of this module.

On this page