# Internationalization (Languages)

## Internationalization

**Files:** `src/config/language.json`, `src/config/config.toml`, `src/i18n/`, `src/config/menu.<language>.json`, `src/content/**/<language>/` · **Skill level:** Beginner

Lotline ships in **English** (the default, at `/`), **French** (at `/fr/`) and **Arabic** (at `/ar/`), with full right-to-left support on Arabic pages. Every page, listing, menu and label exists in all three. You can keep them, keep only your default language, or add another one. For how right-to-left works, see [RTL & Arabic](/lotline/features/rtl-arabic/).

<Aside type="caution">
  The French and Arabic text is a machine translation. Have a native speaker
  review it before you publish it.
</Aside>

### What Makes Up A Language
| Part | Files |
| --- | --- |
| The language itself | an entry in `src/config/language.json` |
| Page, listing and section text | a folder per language in every content folder, such as `src/content/properties/french/` and `src/content/sections/arabic/` |
| Interface text | `src/i18n/<language>.json`, such as `fr.json`: buttons, labels, filter names, form messages, units, and the tagline and description for search |
| Menus | `src/config/menu.<language>.json`, such as `menu.ar.json` |

```json
[
  {
    "languageName": "En",
    "languageCode": "en",
    "contentDir": "english",
    "dir": "ltr",
    "ogLocale": "en_US",
    "dateLocale": "en-US",
    "weight": 1
  },
  {
    "languageName": "Fr",
    "languageCode": "fr",
    "contentDir": "french",
    "dir": "ltr",
    "ogLocale": "fr_FR",
    "dateLocale": "fr-FR",
    "weight": 2
  },
  {
    "languageName": "العربية",
    "languageCode": "ar",
    "contentDir": "arabic",
    "dir": "rtl",
    "ogLocale": "ar_SA",
    "dateLocale": "ar",
    "weight": 3
  }
]
```

| Key | What it does |
| --- | --- |
| `languageName` | The label on the language links |
| `languageCode` | The URL prefix and the file suffix (`fr.json`, `menu.fr.json`) |
| `contentDir` | The folder name inside each content folder |
| `dir` | `ltr` or `rtl`. This one value sets the direction of the page |
| `ogLocale` | The language of social previews |
| `dateLocale` | The format of dates and numbers |
| `weight` | The order of the language links |

Visitors switch language with the links in the footer and in the phone menu. A link goes to the same page in the other language.

Your agency details stay in one place for every language: `[business]` in `config.toml` (name, phone, email, address, hours). Don't type them into translations.

### Language Settings
```toml
# src/config/config.toml
[settings.multilingual]
  enable               = true
  defaultLanguage      = "en"
  disableLanguages     = [""]   # for example ["fr"] to switch French off without deleting it
  showDefaultLangInUrl = false  # true: English at /en/ instead of /
```

Restart `npm run dev` after you change these values.

### Translate Or Edit Text
- **Page and listing text:** edit the file with the **same name** in the language's folder, for example `src/content/properties/french/elm-hill-modern-villa.md`. Keep the keys and structure the same as in English and translate the values only. Numbers such as `price`, `beds` and `area` stay the same in every language.
- **Interface text:** edit the same key in the language's file, for example `navigation.buttonLabel` ("Book a valuation") in `src/i18n/fr.json`.
- **Menus:** each `src/config/menu.<language>.json` keeps the same structure as `menu.en.json`: the same items, in the same order, with the same `url`. Translate the labels. The featured card in the Properties menu has its `title` and `price` typed out, so update them in every language.
- **Links inside text:** a Markdown link in a translated file carries its language, such as `[Contact](/fr/contact/)`. Menu and button URLs don't need it.
- **Search wording:** the tagline, description and keywords of each language are `seo.tagline`, `seo.siteDescription` and `seo.keywords` in its `src/i18n/<language>.json`. See [SEO & AI Visibility](/lotline/customization/seo-ai-visibility/).

### Check Your Translations
```bash
npm run check-i18n
```

It also runs as part of `npm run astro-check`, and it fails when:

- a key in the default language's `src/i18n/` file is missing from another language file, or the other way round,
- a key in that file is no longer read by any code,
- a menu file differs from the default language's menu in structure (item count, `url`, `source`),
- a content file in the default language's folder has no copy in another language folder, or the other way round.

It warns about empty strings and strings still equal to the English ones. Words that stay the same in every language on purpose (such as "villa" or "ChatGPT") are listed in `scripts/check-i18n.mjs`.

### Prices, Areas And Dates
You never write a formatted price in content. Each listing has a plain number, and the theme formats it for the page language: `$1,240` in English becomes `1 240 $US` in French. Arabic pages keep the `$1,240` form, written left to right, so the symbol and the digits never swap ends. Every language uses Western digits.

```toml
[listings]
  currency = "USD" # ISO 4217 code of every listing price, development "from" price and rent
  locale   = ""    # empty: each language's dateLocale from language.json
  areaUnit = "sq ft"

[settings.currency]
  code    = "USD"    # salaries on job pages and the currency in structured data
  display = "symbol" # how salaries show: symbol ($ / $US) | narrowSymbol ($ in every language) | code (USD)
```

Set both `currency` and `code` to your own currency (`"EUR"`, `"GBP"`, `"CAD"`). The area unit is translated too: `"sq ft"` shows as `pi²` in French and `قدم²` in Arabic, and `"m²"` stays `m²`. Those words are `listings.units` in each `src/i18n/<language>.json`. See [Listing Search & Filters](/lotline/customization/listing-search/).

### Remove A Language
**To turn one language off**, add its code to `disableLanguages` in `[settings.multilingual]`, for example `["fr"]`. Its files stay in the project, and you can turn it back on later. Restart `npm run dev`.

**To keep only your default language:**

<Steps>

1. Save a git commit or a copy of the folder, because the next steps delete files.
2. Set `enable = false` in `[settings.multilingual]` of `src/config/config.toml`.
3. Run `npm run dev` once, then stop it.
4. Run `npm run remove-multilingual`. It deletes the content folders, the menu file and the `src/i18n/` file of every language except the default one, French and Arabic included, and rewrites `language.json`.

</Steps>

### Add A Language
Example: German, code `de`, folder `german`.

<Steps>

1. Run the language script:

   ```bash
   npm run generate-multilingual-content -- --lang de --name Deutsch --dir-name german --locale de-DE --og de_DE
   ```

   For a right-to-left language, add `--dir rtl`. The script adds the language to `language.json` and copies your default language's content folders, menu file and `src/i18n/` file. It keeps files that already exist unless you add `--force`.

2. Translate the new `german/` content folders, `src/config/menu.de.json` and `src/i18n/de.json`. In the copied files, add the language to Markdown links, such as `[Contact](/de/contact/)`.

3. On Netlify, add a `/de/*` block to `netlify.toml`, copied from the `/fr/*` one, so a missing German page shows the German 404 page.

4. If the language's alphabet needs its own font, add one to `src/config/fonts.json`, using the Arabic font entry as your model.

5. Restart the dev server, then run `npm run check-i18n` and fix what it lists.

</Steps>

### Do It With AI
```text
Add [LANGUAGE] (code [CODE], folder [FOLDER]) to my Lotline site. Follow "Add or remove a language"
in SKILLS.md: run npm run generate-multilingual-content with the flags it lists, then translate the
new content folders, src/config/menu.[CODE].json and src/i18n/[CODE].json. Add the language prefix
to Markdown links in the new files. Keep every price, bedroom count and floor area unchanged.
Then run npm run check-i18n and fix what it lists.
```

```text
Translate my changes to every other language: for every file I changed in src/content/**/english/
today, update the file with the same name in each other language folder (same keys, translated
values, numbers unchanged), and add any new key from src/i18n/en.json to the other files in
src/i18n/. Then run npm run check-i18n.
```