LightNet v4 is here! Learn how to upgrade your site
Add a site language
Follow these steps to add a new site language to your LightNet project:
- Identify the language code: Find the correct BCP-47 language code for your language, for example
enfor English ordefor German. Tools like r12a Language Subtag Lookup can help you find the right code. - Add the language to your config: Add the new language to the
languagesarray inastro.config.mjs.astro.config.mjs export default defineConfig({integrations: [lightnet({languages: [{code: "de",label: {en: "German",de: "Deutsch"},isSiteLanguage: true},],}),],}) - Create a translations file: Add a file in
src/translationsnamed after your language code, for examplesrc/translations/de.yml. - Check built-in LightNet translations: Inspect LightNet’s built-in translations on GitHub and look for a file named
[your-language-code].yml.- If no such file exists, LightNet does not yet provide built-in translations for that language.
- If the file exists, check the translation status to see whether any keys are still missing.
- Add missing built-in translations to your project: If your language is not built in yet, or if the built-in translation file is incomplete, copy the missing keys from the English translation file into your project translation file and translate those values.
- Add your custom translation keys: If your project already uses custom translation keys in other locale files, add translated values for those keys to the new file as well.
- Set the default language if needed: Your site must have exactly one default site language.
If the new language should become the default, add
isDefaultSiteLanguage: trueto that entry and removeisDefaultSiteLanguagefrom the current default language. - Validate the new locale: Run
npm run devand check that the new language appears in the language selector. Switch to the new locale and verify that built-in strings, your custom translations, and language labels display correctly. - Contribute upstream: If you translated missing LightNet built-in strings, consider sharing them through this translations update form.