Translate a theme
Text that your theme writes itself, such as "Skip to content" or "Open menu", can be translated, so that it matches the language of each page. The text that Paligo writes, such as the content and the site title, is translated as usual. To translate your theme's own text:
Add an
i18nfolder to the theme.Add a JSON file for the theme's source language, named after its language code, such as
i18n/en.json. List each text with a key:{ "skipToContent": "Skip to content", "openMenu": "Open menu" }Add a file with the same keys for each other language, such as
i18n/de.json:{ "skipToContent": "Zum Inhalt springen", "openMenu": "Menü öffnen" }In
theme.json, set the source language:"i18n": { "sourceLanguage": "en" }In your templates, use
theme.strings.<key>wherever the text appears:<a class="skip-link" href="#main">{{ theme.strings.skipToContent }}</a>
Each page uses the file that matches its language. A key that is missing from that file is taken from the source language's file.
Note
The file name must match the page's language code exactly, as site.lang shows it. If site.lang is de-DE, the file must be de-DE.json: Paligo doesn't fall back from de-DE to de. Keep each file a flat list of keys and texts, because nested objects are ignored.
site.strings holds a few texts that Paligo translates for you, such as the search box placeholder. See Template variables.