Skip to content
MagiCMS

Multi-language

Configuring languages

site.config.json languages is an array of BCP-47 language codes. The first entry is the default language. The default language is never included in the URL.

{ "languages": ["en", "nb", "de"] }

The translation model

Two patterns, mutually exclusive:

  1. Per-language root — set translatable: true on a list field. The full array lives in .<lang>.json. Use when items differ per language (e.g. localized FAQs).
  2. Shared list with translated sub-fields — leave translatable: false on the list, mark sub-fields as translatable: true. The base file has the full structure; the per-language overlay is { "<itemId>": { "<field>": "<value>" } }. Use when structure is shared but copy differs (e.g. team grid).

loadPage(), loadCollectionEntry(), loadGlobal() all merge the overlay automatically — block .astro files do not need to know about translations.

Anti-patterns

  • Don't mark both the list and its sub-fields as translatable. The list flag wins, and the sub-field flags become dead code.
  • Don't read .<lang>.json directly from blocks. Use loadXxx() helpers.
  • Don't hardcode language. Always use Astro.currentLocale ?? siteConfig.languages[0].
Vi bruker cookies for å forbedre din opplevelse.