···256256- `locales` object will be used to link the supported locales (country and single one)
257257- `buildLocales` function will build the target locales
258258259259-To register a new locale:
259259+To add a new locale:
260260261261-- for a single country, your JSON file should include the language and the country in the name (for example, `pl-PL.json`) and register the info at `locales` object
262262-- for multiple country variants, you need to add the default language JSON file (for example for Spanish, `es.json`) and one of the country variants (for example for Spanish for Spain, `es-ES.json`); register the language at `countryLocaleVariants` object adding the country variants with the JSON country file and register the language at `locales` object using the language JSON file (check how we register `es`, `es-ES` and `es-419` in [config/i18n.ts](./config/i18n.ts))
261261+1. Create a new JSON file in [`i18n/locales/`](./i18n/locales) with the locale code as the filename (e.g., `uk-UA.json`, `de-DE.json`)
262262+2. Copy [`en.json`](./i18n/locales/en.json) and translate the strings
263263+3. Add the locale to the `locales` array in [config/i18n.ts](./config/i18n.ts):
263264264264-The country file should contain will contain only the translations that differ from the language JSON file, Vue I18n will merge the messages for us.
265265+ ```typescript
266266+ {
267267+ code: 'uk-UA', // Must match the filename (without .json)
268268+ file: 'uk-UA.json',
269269+ name: 'Українська', // Native name of the language
270270+ },
271271+ ```
265272266266-To add a new locale:
273273+4. Copy your translation file to `lunaria/files/` for translation tracking:
274274+275275+ ```bash
276276+ cp i18n/locales/uk-UA.json lunaria/files/uk-UA.json
277277+ ```
267278268268-1. Add a new file at [locales](./i18n/locales) folder with the language code as the filename.
269269-2. Copy [en](./i18n/locales/en.json) and translate the strings
270270-3. Add the language to the `locales` array in [config/i18n.ts](./config/i18n.ts), below `en` and `ar`:
271271- - If your language has multiple country variants, add the generic one for language only (only if there are a lot of common entries, you can always add it as a new one)
272272- - Add all country variants in [country variants object](./config/i18n.ts)
273273- - Add all country variants files with empty `messages` object: `{}`
274274- - Translate the strings in the generic language file
275275- - Later, when anyone wants to add the corresponding translations for the country variant, just override any entry in the corresponding file: you can see an example with `es` variants.
276276- - If the generic language already exists:
277277- - If the translation doesn't differ from the generic language, then add the corresponding translations in the corresponding file
278278- - If the translation differs from the generic language, then add the corresponding translations in the corresponding file and remove it from the country variants entry
279279-4. If the language is `right-to-left`, add `dir` option with `rtl` value, for example, for [ar](./config/i18n.ts)
280280-5. If the language requires special pluralization rules, add `pluralRule` callback option, for example, for [ar](./config/i18n.ts)
279279+ > [!IMPORTANT]
280280+ > This file must be committed. Lunaria uses git history to track translation progress, so the build will fail if this file is missing.
281281+282282+5. If the language is `right-to-left`, add `dir: 'rtl'` (see `ar-EG` in config for example)
283283+6. If the language requires special pluralization rules, add a `pluralRule` callback (see `ar-EG` or `ru-RU` in config for examples)
281284282285Check [Pluralization rule callback](https://vue-i18n.intlify.dev/guide/essentials/pluralization.html#custom-pluralization) for more info.
286286+287287+#### Country variants (advanced)
288288+289289+Most languages only need a single locale file. Country variants are only needed when you want to support regional differences (e.g., `es-ES` for Spain vs `es-419` for Latin America).
290290+291291+If you need country variants:
292292+293293+1. Create a base language file (e.g., `es.json`) with all translations
294294+2. Create country variant files (e.g., `es-ES.json`, `es-419.json`) with only the differing translations
295295+3. Register the base language in `locales` and add variants to `countryLocaleVariants`
296296+297297+See how `es`, `es-ES`, and `es-419` are configured in [config/i18n.ts](./config/i18n.ts) for a complete example.
283298284299### Adding translations
285300