# RTL & Arabic

## RTL & Arabic

**Files:** `src/config/language.json`, `src/config/fonts.json`, `src/i18n/ar.json`, `src/config/menu.ar.json`, `src/content/**/arabic/` · **Skill level:** Beginner

Lotline supports right-to-left (RTL) languages throughout, and ships with Arabic as a full example at `/ar/`. Every page, listing, menu and label has an Arabic version. For how languages work in general, see [Internationalization](/lotline/customization/internationalization/).

<Aside type="caution">
  The Arabic text is machine translated, in Modern Standard Arabic. Have a
  native speaker review it before you launch an Arabic site.
</Aside>

### What Changes In RTL
Direction comes from one setting, so there is nothing to switch on page by page. On an Arabic page:

- `<html>` gets `lang="ar"` and `dir="rtl"`, and the layout mirrors.
- The menus, flyouts, phone menu and their arrow keys follow the direction.
- Arrows, chevrons and other direction icons flip. The listings carousel, the review carousel, the property gallery and the scrolling logo row run the other way, and the pinned listings row on Home 2 moves the other way too.
- Phone numbers, email addresses, web addresses and code stay left to right.
- Prices keep the form `$1,240`, written left to right inside the Arabic text, so the symbol and the digits never swap ends. Every language uses Western digits.
- Review quotes use Arabic quote marks (« »).
- Arabic text uses IBM Plex Sans Arabic, which loads only on Arabic pages. Latin words stay in the theme's Latin font.
- Dates use the Arabic format.
- The llms files work at `/ar/llms.txt` and `/ar/llms-full.txt`.

### The Language Entry
This is the Arabic entry in `src/config/language.json`:

```json
{
  "languageName": "العربية",
  "languageCode": "ar",
  "contentDir": "arabic",
  "dir": "rtl",
  "ogLocale": "ar_SA",
  "dateLocale": "ar",
  "weight": 3
}
```

| Key | What it does |
| --- | --- |
| `languageName` | The name shown in the language links |
| `languageCode` | The address prefix (`/ar/`) and the file suffix (`ar.json`, `menu.ar.json`) |
| `contentDir` | The folder name inside each content folder |
| `dir` | `rtl` or `ltr`. This one value sets the direction of the page |
| `ogLocale` | The language code for social previews |
| `dateLocale` | The format for dates |
| `weight` | The language's position in the language links |

The Arabic font is its own entry in `src/config/fonts.json`, with `"languages": ["ar"]` so it loads only on Arabic pages.

### Add Another RTL Language
These steps add Hebrew. Any RTL language works the same way.

<Steps>

1. Run the language script with `--dir rtl`:

   ```bash
   npm run generate-multilingual-content -- --lang he --name עברית --dir-name hebrew --locale he-IL --og he_IL --dir rtl
   ```

   It adds the language to `language.json` and copies your default language's content, menu and labels for you to translate.

2. Translate the new `hebrew/` content folders, `src/config/menu.he.json` and `src/i18n/he.json`.

3. If you host on Netlify, copy the `/ar/*` block in `netlify.toml` for `/he/*`, so a missing Hebrew page shows the Hebrew 404 page.

4. Add a font that covers the language to `src/config/fonts.json`, using the Arabic entry as your model, with `"languages": ["he"]`. The Arabic text rules in `src/styles/rtl.css` use `:lang(ar)`, so add the same rules for your language if it needs them.

5. Restart `npm run dev`, open `/he/`, and check the menu, a property page, a form and a blog post. Then run `npm run astro-check`.

</Steps>

### Remove Arabic
To turn Arabic off and keep the files, add it to `disableLanguages`:

```toml
# src/config/config.toml
[settings.multilingual]
  disableLanguages = ["ar"]
```

`npm run remove-multilingual` removes **every language except your default one**, and it deletes their files. Save a git commit or a copy of the folder first, and read [Internationalization](/lotline/customization/internationalization/) before you run it.

### If You Add Your Own Code
Use logical CSS, which follows the direction of the page, instead of left and right:

| Instead of | Use |
| --- | --- |
| `ml-*`, `mr-*` | `ms-*`, `me-*` |
| `pl-*`, `pr-*` | `ps-*`, `pe-*` |
| `left-*`, `right-*` | `start-*`, `end-*` |
| `text-left`, `text-right` | `text-start`, `text-end` |
| `rounded-l-*`, `rounded-r-*` | `rounded-s-*`, `rounded-e-*` |
| `border-l-*`, `border-r-*` | `border-s-*`, `border-e-*` |
| `space-x-*` | `gap-*` |
| `margin-left` in CSS | `margin-inline-start` |
| `padding-right` in CSS | `padding-inline-end` |
| `left: 0` in CSS | `inset-inline-start: 0` |
| `text-align: left` in CSS | `text-align: start` |

`translate-x-*`, `transform-origin` and gradient directions have no logical version, so handle them with the `rtl:` variant or `[dir="rtl"]`.

Other rules:

- Direction icons flip from one list in `src/lib/lucideIcons.ts`. Add new ones there, not where you use them.
- Wrap values that must stay left to right with `dir="ltr"` or `<bdi>`, such as a phone number or a code sample.
- Under `:lang(ar)`, don't add `letter-spacing` or `text-transform`, because they break Arabic script.

The RTL rules live in `src/styles/rtl.css`. `SKILLS.md` has a recipe, "Make something work in RTL", that AI assistants can follow.

### Do It With AI
```text
Add [LANGUAGE] as a right-to-left language. Use npm run generate-multilingual-content with
--dir rtl, then translate the new content, menu and interface label files. Keep every key and
frontmatter field, and every price, bedroom count and floor area unchanged. Add a font that covers
the language to src/config/fonts.json. Use logical CSS only. Don't run remove-multilingual. Then
run npm run astro-check and list the pages I should check by eye.
```