Skip to content

Translating content

Every collection works the same way: files at the root of the collection are the default language, and a translation is a file with the same name in a language folder.

  • Directorysrc/content/
    • Directoryprojects/
      • halden-rail.json English
      • veld-cycling.json English only, no translation yet
      • Directoryde/
        • halden-rail.json German
      • Directoryid/
        • halden-rail.json Indonesian
    • Directoryjournal/
      • two-languages-one-sign.mdx
      • Directoryde/
        • two-languages-one-sign.mdx
    • roles/…
    • legal/…

The shared file name is the link between translations: it is the slug in the URL for every language (/case-study/halden-rail, /de/case-study/halden-rail), and it is how the language switcher finds the other versions.

  1. Copy the file into the language folder, keeping its name.
  2. Translate the text fields. Leave order, year, featured, layout, disciplines and industry as they are; they describe the project, not the language.
  3. Add one ../ to every image path, because the file now sits one folder deeper. Images are shared between languages; don’t copy them.
src/content/projects/de/halden-rail.json
{
"client": "Halden Rail",
"title": "Wegeleitung für eine Bahn, die eine Grenze überquert",
"cover": "../../../assets/projects/halden-rail/cover.jpg",
"coverAlt": "Leerer Bahnsteig bei Sonnenuntergang, die Sonne tief zwischen Dach und Gleis"
}

Or do the same in Keystatic, which handles the image paths for you.

Disciplines and industries stay in English in the file. The labels shown on the page come from the taxonomy section of the dictionary, so filters and tags are translated without touching content.

A page never goes missing because a translation doesn’t exist yet. Where there is no translation, the default-language version is shown:

  • The case study, article or role appears in the German list in English.
  • It carries lang="en", so screen readers and search engines know it is English.
  • Journal cards mark it with an “In English” label.
  • Its URL is still the German one, so the visitor stays in the German site.

A translation without an original (a file in de/ with no English file of the same name) is ignored.

  1. The dictionary. It covers every page, and it is the only thing that can’t fall back: it’s checked at build time.
  2. Legal pages, where a translation is often a legal requirement.
  3. Your featured case study and newest articles, which are the first things visitors see.
  4. Everything else as you go.

SwiftAgency is made byLessCodexLicence