Skip to content
New: Customize your theme with an AI assistant. Read the guide

Internationalization

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

In the Tina edition, edit each language’s content in /admin/, with its labels under Interface labels and its menus under Menus. In the Sanity edition, each language is its own entry under Content in the Studio, with Menus and Interface labels inside it. src/config/language.json stays in the project in every edition.

Kivo ships in English (the default, at /), French (at /fr/), and Arabic (at /ar/), with full right-to-left support. Every page, menu, and label exists in every language. The Arabic text is a machine translation, so have a native speaker review it before you publish. For how right-to-left works, see RTL & Arabic.

What Makes Up A Language

PartFiles
The language itselfan entry in src/config/language.json
Page and section texta folder per language in every content folder: src/content/sections/french/, src/content/blog/arabic/, …
Interface textsrc/i18n/fr.json (buttons, form messages, labels)
Menussrc/config/menu.fr.json

In src/config/language.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 }
]

languageName is shown in the language switch, languageCode is the URL prefix and the file suffix (fr.json, menu.fr.json), contentDir is the folder name inside each content folder, and dir sets the direction (ltr or rtl).

Language Settings

src/config/config.toml
[settings.multilingual]
enable = true
defaultLanguage = "en"
disableLanguages = [""] # for example ["fr"]
showDefaultLangInUrl = false # true gives /en/pricing/ instead of /pricing/

Restart npm run dev after any change here.

Remove A Language

Turn one language off and keep its files. Add its code to disableLanguages, for example disableLanguages = ["fr"]. You can turn it back on any time.

Keep only your default language. This is different in each edition:

  • Astro: set enable = false in [settings.multilingual], and run npm run dev once, so .astro/config.generated.json exists (the script reads your default language from it). Save a checkpoint (a git commit or a copy of the folder), then run npm run remove-multilingual. It deletes the other languages’ content folders, src/i18n/ files, and menu files, and removes them from language.json. This can’t be undone without your checkpoint.
  • Tina: the same, then run npm run tina:generate.
  • Sanity: run npm run remove-multilingual. Their documents stay in your project unless you add -- --delete-online, which deletes them and can’t be undone.

Add A Language

The language script adds the language to language.json, and makes copies of your default language to translate. German is the example.

  1. Run the script. In the Astro and Tina editions:

    Terminal window
    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:

    Terminal window
    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. Files that already exist are kept. In the Astro and Tina editions, --force overwrites them.

  2. In the Tina edition, run npm run tina:generate, and commit tina/tina-lock.json. In the Sanity edition, the script creates a copy of every default-language document in your project, and the language appears in the Studio by itself.

  3. Translate the copies: the new german/ content folders, src/i18n/de.json, and src/config/menu.de.json. In the Tina edition you can do this in the editor, and in the Sanity edition in the new documents. Keep every key as it is, and change internal links in Markdown text to /de/.

  4. On Netlify, add a /de/* block to netlify.toml, like the French one. The script doesn’t change this file.

  5. Restart npm run dev and open /de/.

Translating a whole site is a perfect job for an AI assistant: see the prompt at the end of this page. To replace a language, add the new one, then turn the old one off with disableLanguages.

  • Directorysrc/content/
    • Directorysections/
      • Directoryenglish/
        • …
      • Directoryfrench/
        • …
      • Directoryarabic/
        • …
      • Directorygerman/
        • …
    • Directoryblog/
      • Directoryenglish/
        • …
      • Directoryfrench/
        • …
      • Directoryarabic/
        • …
      • Directorygerman/
        • …
  • In menus and in url fields of buttons and links in content files, write the English path (/pricing/). Kivo adds the language prefix for you.
  • In Markdown text (the body of a post or page), write the full path for that language yourself: [see pricing](/fr/pricing/) in a French file.
  • If you use customSlug, give it the same value in every language so the language switch finds the matching page.

Translated 404 Pages

Each language has its own 404 page (/fr/404/, /ar/404/). On Netlify, the redirects in netlify.toml send a missing /fr/... or /ar/... address to it. Add one block per extra language by hand. On other hosts, check how your host serves 404 pages.

Do It With AI

Add [LANGUAGE] (code "[xx]", folder "[name]", locale "[xx-XX]", social locale "[xx_XX]"). Run
npm run generate-multilingual-content with those values, then translate every text value in the new
[name]/ folders, src/i18n/[xx].json, and src/config/menu.[xx].json. Add a /[xx]/* block to
netlify.toml. Keep all keys, option values, icon names, URLs, and code samples unchanged. In Markdown
text, change internal links to /[xx]/. Work folder by folder and tell me when each is done.
Type something to search...