# Internationalization (i18n)

## Internationalization (i18n)

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

Finzo ships in English, French, and Arabic. Arabic is the right-to-left example, so see [RTL & Arabic](../../features/rtl-arabic/) for how direction works. The Arabic text and much of the French text are machine translations, so have a native speaker review them before you publish.

Everything reads the language list from `src/config/language.json`, so you never list languages anywhere else. Each language has its own content folder, menu file, and interface labels.

In the Tina edition, these files are the language folders, **Menus**, and **Interface labels** at `/admin/`. In the Sanity edition, content, menus, and interface labels are documents in the Studio, one set per language, and the language settings stay in `config.toml` and `language.json`.

### Language Settings
```toml
# src/config/config.toml
# Restart your server when you change these values
[settings.multilingual]
  enable               = true
  defaultLanguage      = "en"
  disableLanguages     = [] # Languages to turn off, such as ["fr", "ar"]
  showDefaultLangInUrl = false
```

| Setting                | What it does                                                 |
| ---------------------- | ------------------------------------------------------------ |
| `enable`               | Turns multiple languages on or off                           |
| `defaultLanguage`      | The primary language                                         |
| `disableLanguages`     | Languages to turn off. Their files stay in the project       |
| `showDefaultLangInUrl` | Adds the default language's code to its addresses, such as `/en/` |

### The Language List
Each language has an entry in `src/config/language.json`:

```json
{
  "languageName": "Français",
  "languageCode": "fr",
  "contentDir": "french",
  "dir": "ltr",
  "ogLocale": "fr_FR",
  "dateLocale": "fr-FR",
  "weight": 2
}
```

`dir` is `ltr` or `rtl`, and it sets the direction of the page. `ogLocale` is the language code for social previews, and `dateLocale` sets the format for dates.

### Add A Language
Run the language script. This example adds German. 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 setting is called `--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`.

It adds the language to `language.json`, and makes copies of your default language to translate. Then:

- **Astro:** translate the new `german/` content folders, `src/config/menu.de.json`, and `src/i18n/de.json`, then restart the dev server.
- **Tina:** run `npm run tina:generate`, restart `npm run dev`, and translate the `german` folders, the `menu.de` menu, and the `de` interface labels in `/admin/`.
- **Sanity:** with a project connected, it creates those copies in your project. Restart the dev server, and the language appears in the Studio. Until a document is translated, it shows the default language's text. Your other documents aren't touched.

<Aside type="note">
  In Finzo, the language scripts don't change `netlify.toml`. On Netlify, add a
  `/de/*` block by hand, in every edition, so a missing page gets that language's
  404 page. Copy the `/fr/*` block that is already there.
</Aside>

### Remove One Language
Add its code to `disableLanguages`, then restart the dev server. To remove Arabic:

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

On Netlify, also remove its block from `netlify.toml`.

In the Tina edition, its files stay in the folder and in the editor, but the site no longer builds them. In the Sanity edition, it stays in the Studio until you remove its entry from `language.json`.

### Keep Only Your Default Language
<Aside type="caution">
  `npm run remove-multilingual` removes every language except your default one.
  In the Astro and Tina editions it deletes their files, so save a git commit or
  a copy of the folder first.
</Aside>

- **Astro:** set `enable = false` in `[settings.multilingual]`, run `npm run toml:watch` once, then run `npm run remove-multilingual`.
- **Tina:** do the same, then run `npm run tina:generate`, and start `npm run dev` once so the editor knows.
- **Sanity:** run `npm run remove-multilingual`. It keeps the first language in `language.json`. The other languages' documents stay in your project unless you add `-- --delete-online`, which deletes them and can't be undone.

On Netlify, also remove the language blocks from `netlify.toml`.