Skip to content

Build your personal knowledge base with Trilium Notes

docs(i18n): say a fallback Electron locale does not reach Chromium

Elian Doranddcfd54c99f8
diff --git a/.claude/skills/adding-a-display-language/SKILL.md b/.claude/skills/adding-a-display-language/SKILL.md
index b0c7874375..94abf67f91 100644
--- a/.claude/skills/adding-a-display-language/SKILL.md
+++ b/.claude/skills/adding-a-display-language/SKILL.md
@@ -67,10 +67,10 @@ node -e 'const f=require("./apps/desktop/electron-forge/electron-locales.json");
- **Found** (`da.pak`, `pt-BR.pak`): set `electronLocale` to that name with `_` for `-` (`da`, `pt_BR`;
`en-US.pak` is `"en"`). The `electronLocale` union on `Locale` mirrors this list, so the name is already
a member.
-- **Not found** — Chromium has no UI for the language. Point `electronLocale` at the closest locale
- Chromium does ship; the precedent is Irish, `{ id: "ga", electronLocale: "en" }`. Chromium's own strings
- (native menus, built-in dialogs) then show in that language, and Trilium's in the new one. Never add a
- name to the union that the JSON does not list: the type would accept it and the packaging would throw.
+- **Not found** — Chromium has no UI for the language. Point `electronLocale` at a locale Chromium does
+ ship, so the language is still offered for formatting; the precedent is Irish,
+ `{ id: "ga", electronLocale: "en" }`. Never add a name to the union that the JSON does not list: the
+ type would accept it and the packaging would throw.
Then prove it — the spec builds its fixtures from the real file lists, so a wrong name fails here
instead of in a release build:
@@ -85,9 +85,10 @@ pnpm --filter desktop test trim-locales
`pnpm chore:update-electron-locales` (network: a few hundred KB of range requests against the release
zips) and commit the JSON in its own commit.
-`getElectronLocale()` (`apps/desktop/src/main.ts`) passes the Trilium id, or the formatting locale's id,
-to Chromium's `--lang`, not the `electronLocale`. When Chromium's name and the Trilium id can match,
-prefer the id that matches.
+`electronLocale` does **not** choose Chromium's language. `getElectronLocale()`
+(`apps/desktop/src/main.ts`) passes the Trilium id of the display language, or of the formatting locale,
+to Chromium's `--lang`, so a fallback `electronLocale` never reaches Chromium. When Chromium's name and
+the Trilium id can match, prefer the id that matches.
## 4. Verify
diff --git a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
index dcf490c738..b90ff31502 100644
--- a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
+++ b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md
@@ -20,7 +20,9 @@ The `electronLocale` of the new entry names the Chromium locale the desktop appl
The locale files of the Electron version the desktop application pins are recorded in `apps/desktop/electron-forge/electron-locales.json`:
* If the language is listed there (for example `da.pak` or `pt-BR.pak`), set `electronLocale` to that name, with an underscore in place of the hyphen (`da`, `pt_BR`). `en-US.pak` is `"en"`.
-* If it is not listed, Chromium has no translation for the language. Set `electronLocale` to the closest locale it does ship, as Irish does with `"en"`; Chromium's own strings then appear in that language.
+* If it is not listed, Chromium has no translation for the language. Set `electronLocale` to a locale it does ship, as Irish does with `"en"`, so that the language is still offered as a formatting locale.
+
+`electronLocale` only decides which locale files the package keeps and which locales are offered for formatting. It does not choose Chromium's language: `getElectronLocale()` in `apps/desktop/src/main.ts` passes the id of the display language (or of the formatting locale) to Chromium's `--lang` switch.
`pnpm --filter desktop test trim-locales` runs the trim against those files and fails with "Locale … was not found in the packaged app" when the name is wrong. The same spec fails when the file records another Electron version than the one pinned in `apps/desktop/package.json`; after an Electron update, regenerate it with `pnpm chore:update-electron-locales` and commit the result.