# Internationalization

## Internationalization

**Files:** `src/config/language.json`, `src/config/config.toml`, `src/i18n/`, `src/config/menu.<lang>.json`, `english/`, `french/`, and `arabic/` content folders · **Skill level:** Beginner to intermediate

In the Tina edition, each language has its own folder or file under each entry at `/admin/`, including **Menus** and **Interface labels**. In the Sanity edition, each language is an entry under **Content** in the Studio, with its own **Menus** and **Interface labels**. `language.json` stays in the project in every edition.

Taskly ships in **English** (default, at `/`), **French** (at `/fr/`), and **Arabic** (at `/ar/`). Arabic is the right-to-left example: the whole layout, menus, icons, and marquees mirror on `/ar/` pages. See [RTL & Arabic](../../features/rtl-arabic/). The Arabic text is a machine translation, so have a native speaker review it before you publish.

Each language has:

- its own content folder inside every collection: `src/content/<collection>/english/`, `french/`, and `arabic/`
- its own interface text: `src/i18n/en.json`, `fr.json`, and `ar.json` (buttons, labels, form messages, the footer text, the tagline)
- its own menus: `src/config/menu.en.json`, `menu.fr.json`, and `menu.ar.json` (breadcrumb labels come from the menu names, so they are translated too)

The language links are in the footer (and at the top of the auth screens).

### Settings
```toml
[settings.multilingual]
  enable               = true
  defaultLanguage      = "en"
  disableLanguages     = [""]   # for example ["fr"] to stop building French
  showDefaultLangInUrl = false  # true puts English at /en/ too
```

Restart `npm run dev` after any change here. The languages themselves are listed in `src/config/language.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 }
]
```

`dir` sets the direction: `ltr` or `rtl`.

### Remove A Language
**One language:** add its code to `disableLanguages` in `[settings.multilingual]`, for example `["ar"]`. Its files stay on disk but are not built. This works the same in every edition.

**Keep only your default language, Astro and Tina editions:** set `enable = false` under `[settings.multilingual]`, run `npm run dev` once (so the setting is converted), then:

```bash
npm run remove-multilingual
```

It deletes the other languages' content folders, menu files, and i18n files, and rewrites `language.json`. Save a checkpoint first: this can't be undone without one.

**Keep only your default language, Sanity edition:** run `npm run remove-multilingual`. It updates `language.json` and the seed file. The other languages' documents stay in your Sanity project unless you add `-- --delete-online`, which deletes them and cannot be undone.

### Add A Language
This is the "Add or remove a language" recipe in `SKILLS.md`. Example: German, code `de`, folder `german`.

<Steps>

1. Run the command for your edition. For a right-to-left language, add `--dir rtl`.

   Astro and Tina editions:

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

   Sanity edition (the last flag is different):

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

2. Translate. In the Astro and Tina editions, the command copied the default language to the new `german/` content folders, `src/config/menu.de.json`, and `src/i18n/de.json`. It keeps files that already exist unless you add `--force`. In the Sanity edition, it created a copy of every default-language document in your project, and your other documents are not touched.
3. In the Tina edition, run `npm run tina:generate` so the editor offers the new language.
4. On Netlify, add a `/de/*` 404 block to `netlify.toml` (copy the French one). Restart the dev server.

</Steps>

An AI assistant translates well, one folder at a time.

### Replace French With Another Language
To ship another language instead of French, add it (above), check it, then add `"fr"` to `disableLanguages`, or delete the `french/` folders, `menu.fr.json`, `fr.json`, and its entry in `language.json`.

### What To Translate
- Every content file, including `src/content/sections/<language>/` and `src/content/widgets/<language>/` (the dashboard sample data, the announcement bar, the cookie banner).
- `src/i18n/<lang>.json`, including `site.tagline`, which is added to page titles.
- `src/config/menu.<lang>.json`.

Keep the **file names** the same in every language: the language links open the same URL in the other language.

### Things To Know
- Copy every file: a page whose content file is missing in a language folder can break or disappear in that language. Check each page in the new language after copying.
- Translated 404 pages: each language has one at `/<code>/404/`. `netlify.toml` ships blocks for `/fr/*` and `/ar/*`, and each new language needs its own. Other hosts show their own 404 or the default one.
- Arabic text uses IBM Plex Sans Arabic, which loads only on Arabic pages (`languages` in `src/config/fonts.json`). A new right-to-left language needs a font that covers it.
- Generated Open Graph cards skip right-to-left languages, which use the shared `[opengraph] image`.

### Do It With AI
```text
Follow the "Add or remove a language" skill in SKILLS.md to add Spanish (code "es", folder
"spanish"). Run npm run generate-multilingual-content with the flags in README.md, then translate
every file it created in spanish/, src/config/menu.es.json, and src/i18n/es.json. Keep keys, file
names, URLs, icon names, and layout values unchanged. Add the /es/* 404 block to netlify.toml. Do
one collection at a time and tell me when each is done.
```