Contents

Languages

src/i18n/locales.ts is the only list of the site's languages. Payload's localization, the site's routing, the language switcher, hreflang tags, the sitemap and the translation features all read it. As shipped, the kit has English (the default), Danish and German:

export const locales = [
  { code: 'en', label: 'English', hreflang: 'en', ogLocale: 'en_US', isDefault: true },
  { code: 'da', label: 'Dansk', hreflang: 'da', ogLocale: 'da_DK', region: 'DK' },
  { code: 'de', label: 'Deutsch', hreflang: 'de', ogLocale: 'de_DE', region: 'DE' },
] as const satisfies readonly LocaleDef[]
FieldWhat it is
codeWhat appears in addresses (/de/…), in the database and in the API. A language code (de), or a language and region where one language serves several markets (en-GB).
labelThe name in the admin's language picker and the site's language switcher. Write it in the language itself.
hreflangThe BCP 47 tag for <html lang> and hreflang. Dates and numbers are formatted with it.
ogLocaleThe og:locale value, such as da_DK.
isDefaultThe default language: no address prefix, the source of every translation, and the fallback for anything not translated. Exactly one.
regionOptional. The country the language mainly serves, as an ISO 3166 code, used for market defaults such as the dealer locator's starting country.

To add a language, see Add a language.

Addresses #

  • The default language has no prefix: /about. Other languages start with their code: /da/om-os.
  • Every page has a slug per language, made from that language's title the first time it is saved in it, and never changed by itself afterwards. A page's path is its parent's path plus its own slug, in the same language: about/team and om-os/holdet.
  • Collection addresses are localized too. The registry (src/registry/index.ts) gives each collection a segment per language, such as /news and /da/nyheder. A segment without a word for a language uses the default language's.
  • Wrong-language addresses redirect. A slug or segment from another language is sent permanently to this language's own address.
  • Moves redirect. When a published page gets a new slug or parent, its old address in each language keeps working with a permanent redirect.

Fallback #

The site never shows an empty page because a translation is missing:

  • An empty text field shows the default language's text.
  • A page's blocks are the default language's until the language has blocks of its own. From then on each language owns its layout, and editors keep the copies in step with the block sync panel (see Blocks in other languages).
  • Interface texts (buttons, messages, labels) come from src/messages/<code>.json. A language without its own file uses the default language's, and editors can override any text per language in Microcopy.

In the admin, each language shows only its own content: an empty field there is one that falls back on the site.

These guides ship with Tolk Starter 0.6.0: buyers get the same pages in their repository, next to the code they describe.