# Internationalization

## Internationalization

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

In the Tina edition, these are the language folders, **Menus**, and **Interface labels** at `/admin/`. In the Sanity edition, content, menus, and labels are documents in the Studio, one set per language, and `language.json` stays in the project.

Taxo ships in English, French, and Arabic. Arabic is the right-to-left example: see [RTL & Arabic](../../features/rtl-arabic/).

Taxo's multilingual behavior is controlled by three layers:

1. `src/config/language.json`
2. `[settings.multilingual]` in `src/config/config.toml`
3. the content folders: `english/`, `french/`, and `arabic/`

### Language Definitions
```json
[
  {
    "languageName": "English",
    "languageCode": "en",
    "contentDir": "english",
    "dir": "ltr",
    "ogLocale": "en_US",
    "dateLocale": "en-US",
    "weight": 1
  },
  {
    "languageName": "Français",
    "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
  }
]
```

`dir` sets the direction. The Arabic text is a machine translation, so have a native speaker review it before you publish.

### Main Multilingual Settings
```toml
[settings.multilingual]
  enable = true
  defaultLanguage = "en"
  disableLanguages = []
  showDefaultLangInUrl = false
```

### URL Behavior
When `showDefaultLangInUrl = false`:

- default language URLs look like `/about/`
- other languages look like `/fr/about/` and `/ar/about/`

When `showDefaultLangInUrl = true`:

- default language URLs look like `/en/about/`
- other languages look like `/fr/about/` and `/ar/about/`

### Content Folder Rule
Every localized collection follows the same pattern:

```text
src/content/blog/english/
src/content/blog/french/
src/content/blog/arabic/
src/content/services/english/
src/content/services/french/
src/content/services/arabic/
```

### Add A Language
Use German as the example. In the Astro and Tina editions:

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

In the Sanity edition, the last flag is `--og-locale`:

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

For a right-to-left language, add `--dir rtl`. Then:

- **Astro:** translate the new `german/` content folders, `src/config/menu.de.json`, and `src/i18n/de.json`, and restart the dev server.
- **Tina:** run `npm run tina:generate` and restart `npm run dev`, and the editor has forms for the new language. Translate there or in the files.
- **Sanity:** with a project connected, it creates a German copy of each sample English document in your project, to translate. The copies come from the sample content, not your own edits, and your other documents aren't touched. Restart the dev server, and the language appears in the Studio.

Links written inside text, such as `[text](/about/)`, need the language in front: `[text](/de/about/)`.

The script doesn't change `netlify.toml`. On Netlify, add a `/de/*` block to it yourself, as the other languages have, so a missing address shows that language's 404 page.

### Remove One Language
Add its code to `disableLanguages` in `[settings.multilingual]` in `config.toml`. It leaves your site. In the Tina edition, its forms stay in the editor. In the Sanity edition, its documents stay in the Studio.

### Keep Only Your Default Language
- **Astro:** set `enable = false` in `[settings.multilingual]`, run `npm run dev` once, then run `npm run remove-multilingual`.
- **Tina:** do the same, then run `npm run tina:generate` and `npm run dev` once more, so the editor matches.
- **Sanity:** run `npm run remove-multilingual`. Its documents stay in your project unless you add `-- --delete-online`, which deletes them and can't be undone.

### Shared Text Files
Update these in every language for translated UI labels:

- `src/i18n/en.json`
- `src/i18n/fr.json`
- `src/i18n/ar.json`

Update these in every language for translated menu labels:

- `src/config/menu.en.json`
- `src/config/menu.fr.json`
- `src/config/menu.ar.json`

### Important Restart Note
After changing multilingual settings, restart the dev server so routing and
theme settings stay aligned.