Internationalization ¶
Locales are keyed by route prefix. The longest matching prefix supplies page labels, title, description, nav, sidebar, footer, edit link, and outline overrides.
locales
locales: {
'/': { lang: 'en-US', label: 'English' },
'/de/': {
lang: 'de-DE',
label: 'Deutsch',
title: 'CarvePress',
description: 'Ein statischer Dokumentationsgenerator fuer Carve.',
themeConfig: {
labels: { search: 'Suchen' },
nav: [{ text: 'Start', link: '/de/' }],
},
},
}locales: {
'/': { lang: 'en-US', label: 'English' },
'/de/': {
lang: 'de-DE',
label: 'Deutsch',
title: 'CarvePress',
description: 'Ein statischer Dokumentationsgenerator fuer Carve.',
themeConfig: {
labels: { search: 'Suchen' },
nav: [{ text: 'Start', link: '/de/' }],
},
},
}Switcher ¶
When at least two locales are configured, the header shows a locale switcher. It preserves the current route if that localized route exists; otherwise it links to the locale root.
This dogfood site includes a small German landing page so the switcher has a concrete target.
What Else Follows The Locale ¶
Configuring locales changes more than the chrome:
- Search
- Every index record carries the locale of the page it came from, and the client filters to the locale of the page the reader is on. One index file still serves the whole site.
- Feeds
- One feed per locale, written to
<prefix>feed.xml, and each page links the feed for its own locale rather than the site-wide one. A locale with no pages of its own gets no feed. - Sitemap
- Pages that exist in more than one locale carry
xhtml:linkalternates with each locale’slang. Only translations that were actually written are advertised - claiming one that does not exist earns a crawl error rather than a ranking.
Last updated