docs(dev): document adding a new locale

This commit is contained in:
Elian Doran
2025-11-16 21:24:34 +02:00
parent cc0e30e3f5
commit 5281e8e5b4
9 changed files with 601 additions and 584 deletions

View File

@@ -15,7 +15,7 @@ One important aspect is the fact that we are using a key-based approach. This me
The key-based approach allows a hierarchical structure. For example, a key of `about.title` would be added in `translation.json` as follows:
```json
```
{
"about": {
"title": "About Trilium Notes"
@@ -27,11 +27,7 @@ Follow the <a class="reference-link" href="Internationalisation%20%20Translatio
### Adding a new locale
To add a new locale, go to `src/public/translations` with your favorite text editor and copy the `en` directory.
Rename the copy to the ISO code (e.g. `fr`, `ro`) of the language being translated.
Translations with a country-language combination, using their corresponding ISO code (e.g. `fr_FR`, `fr_BE`), has not been tested yet.
See <a class="reference-link" href="Internationalisation%20%20Translations/Adding%20a%20new%20locale.md">Adding a new locale</a>.
### Changing the language

View File

@@ -0,0 +1,11 @@
# Adding a new locale
Once the Weblate translations for a single language have reached ~50% in coverage, it's time to add it to the application.
To do so:
1. In `packages/commons` look for `i18n.ts` and add a new entry to `UNSORTED_LOCALES` for the language.
2. In `apps/server` look for `services/i18n.ts` and add a mapping for the new language in `DAYJS_LOADER`. Sort the entire list.
3. In `apps/client`, look for `collections/calendar/index.tsx` and modify `LOCALE_MAPPINGS` to add support to the new language.
4. In `apps/client`, look for `widgets/type_widgets/canvas/i18n.ts` and modify `LANGUAGE_MAPPINGS`. A unit test ensures that the language is actually loadable.
5. In `apps/client`, look for `widgets/type_widgets/MindMap.tsx` and modify `LOCALE_MAPPINGS`. The type definitions should already validate if the new value is supported by Mind Elixir.
6. In `packages/ckeditor5`, look for `i18n.ts` and modify `LOCALE_MAPPINGS`. The import validation should already check if the new value is supported by CKEditor, and there's also a test to ensure it.