Repository navigation
fix: #5130 keep Electron locale resources for all supported UI languages - #5132
Conversation
|
Since a new localization language has been added, please verify that this PR includes all supported languages. |
da5c7e5 to
28b6a3d
Compare
|
Thanks for the review! Yes — the list now covers all 11 UI languages MarkText ships, including the Dutch locale added in #5137 (nl entry, just pushed). One note: locale codes appear in both spellings on purpose — macOS bundle folders use underscores (zh_CN.lproj, nl.lproj) while Windows/Linux .pak files use hyphens (zh-CN.pak), and app-builder-lib matches on-disk names literally, so both are needed to keep the resources on every platform. Verified by building the mac target: marktext.app/Contents/Resources retains all 12 relevant .lproj folders instead of just en. |
|
Please rebase |
electronLanguages pruned the packaged app down to en-US. On macOS this also removes the .lproj localization declarations from the app bundle, so the OS treats the app as English-only and system-provided UI stays in English even when the system — and MarkText's own UI — is not. Most visibly, the macOS Sequoia Window management items (Fill, Center, Enter Full Screen, Move & Resize, Full Screen Tile, Remove Window from Set) appear in English on a e.g. zh-CN system. Keep the Chromium/AppKit locales matching the languages MarkText ships translations for. macOS bundle folders are spelled with underscores (zh_CN.lproj) while Windows/Linux .pak files use hyphens (zh-CN.pak), so both spellings are listed. The extra cost is a few empty .lproj folders on macOS and ~16 small .pak files elsewhere.
28b6a3d to
4f6d4b1
Compare
|
Done — rebased onto latest develop and force-pushed. No conflicts. |
electronLanguages is a whitelist: anything not listed is pruned from the packaged app. marktext#5132 set the invariant that it must track the languages MarkText ships translations for, but the new `ru` translation was added without it, so a packaged build drops `ru.lproj` / `ru.pak`. That reintroduces exactly what marktext#5132 fixed for the other locales: on macOS AppKit stops treating the bundle as Russian-capable, so the Sequoia Window management items (Fill, Center, Enter Full Screen, Move & Resize, …) stay English while the whole MarkText UI is Russian; on Windows and Linux the Chromium-provided strings do the same. Russian has no regional variants here, so unlike pt/zh a single entry covers both the `ru.pak` and `ru.lproj` spellings. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* feat(i18n): add Russian (ru) localization Add a Russian translation for the desktop UI and the muya editor engine and register ru so it can be selected in Preferences > Language. - packages/desktop/static/locales/ru.json: full UI translation (769 keys) - packages/muya/src/locales/ru.ts: editor engine strings (85 keys) - register ru in SUPPORTED_LANGUAGES, the language selector and MUYA_LOCALES - list the new language in every locale's language selector (key parity) - extend the locale parity and boot specs to cover ru (11 locales) * fix(build): keep the Russian Electron locale resources electronLanguages is a whitelist: anything not listed is pruned from the packaged app. #5132 set the invariant that it must track the languages MarkText ships translations for, but the new `ru` translation was added without it, so a packaged build drops `ru.lproj` / `ru.pak`. That reintroduces exactly what #5132 fixed for the other locales: on macOS AppKit stops treating the bundle as Russian-capable, so the Sequoia Window management items (Fill, Center, Enter Full Screen, Move & Resize, …) stay English while the whole MarkText UI is Russian; on Windows and Linux the Chromium-provided strings do the same. Russian has no regional variants here, so unlike pt/zh a single entry covers both the `ru.pak` and `ru.lproj` spellings. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(muya): name the right action in three Russian toolbar labels The inline format toolbar keys are named after the tooltip text rather than the action, and the Russian translations followed the English word instead of the command behind it (inlineFormatToolbar/config.ts): - `Emphasize` is `type: 'strong'` + Ctrl+B, i.e. Bold. "Выделить" reads as "select/single out"; every other locale says Bold (Fett, Negrita, Gras, Vet, Negrito, Kalın, 加粗) and the desktop Format menu already calls the same command "Полужирный". - `Highlight` is `type: 'mark'`. "Подсветка" reads as syntax highlighting, which MarkText also has, and it disagreed with the desktop menu/command palette, where the same feature is "Выделение". - `Eliminate` is `type: 'clear'`, i.e. clear inline formatting. Bare "Убрать" names no object and collided with the "Удалить" this file already uses for Delete / Remove Row / Remove Image. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(muya): cover the Turkish locale and lock the list to the exports `nonEnLocales` never contained `tr`, so Turkish had no key-parity, name-tag or non-empty-value coverage: dropping a key from tr.ts or blanking a value kept the suite green. The hand-maintained count test did not catch it — it asserted the length of the very list that was short, so it only ever restated it, and adding `ru` meant editing the number by hand again. Replace the count with an assertion that the list covers exactly the locales `../locales` exports, and add the missing `tr` entry. The list stays spelled out so the name-tag suite still checks `name` against an independent expectation rather than against itself. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test: guard the untranslated product names in Russian too The gate for "product names stay English" was keyed on a list named LATIN_SCRIPT_LOCALES, which left the new Russian locale out of a check it already passes: ru.json and ru.ts spell Front Matter, Mermaid and PlantUML the English way, exactly like de/es/fr/nl/pt. Nothing stopped a later edit from localizing them. Script was never the real criterion — it is a per-locale convention — so rename the list to TERM_PRESERVING_LOCALES and add `ru`. The muya note claiming Russian translates these terms described the opposite of what ru.ts does; restate it in terms of the list, and name Turkish as the locale that genuinely does translate them ("Ön Bilgi"). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(muya): boot the heading crash guard under every shipped locale The comment promised "typing `#` must not crash under ANY shipped locale — exercise the real conversion path for every one of them", but the array was hand-maintained and had fallen two short: `nl` and `tr` were never booted. Enumerate the locale module's exports instead, so the guard covers what it claims and a new locale is picked up without editing this file. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(desktop): assert Russian system locales resolve to the ru translation Adding `ru` moved `ru-RU` from the "no supported translation" list to the supported set, but the assertion was only swapped out for `pl-PL` — so nothing covered the new behaviour. Dropping or misspelling `'ru'` in SUPPORTED_LANGUAGES would make matchSupportedLanguage return null, silently starting Russian systems in English, with the suite still green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Jocs <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Fixes #5130
Problem
electron-builder.ymlprunes the packaged app toelectronLanguages: [en-US]. On macOS this also removes the per-language.lprojdeclarations from the app bundle, so macOS treats MarkText as an English-only app and renders system-provided UI in English even when both the OS language and MarkText's own UI language are not English. Most visibly, the macOS Sequoia Window-management items injected into the Window menu (Fill,Center,Enter Full Screen,Move & Resize,Full Screen Tile,Remove Window from Set) stay in English. Dev builds are unaffected because they run inside the unprunedElectron.app.Change
Keep the Chromium/AppKit locales matching the ten languages MarkText ships translations for. Details:
zh_CN.lproj) while Windows/Linux.pakfiles use hyphens (zh-CN.pak); app-builder-lib matches them literally, so both spellings are listed for region-specific locales..lprojfolders on macOS and ~16 small.pakfiles on Windows/Linux — the original goal of the pruning (not shipping all ~50 Chromium locales) is preserved.Demonstration
Same machine, macOS system language and app language both 简体中文.
Before (v0.19.1 DMG,
electronLanguages: [en-US]) — MarkText's own items are Chinese, but the macOS-injected Window-management section is English (Fill ⌃⌥F,Center ⌃⌥C,Enter Full Screen ⌥F,Move & Resize ▸,Full Screen Tile ▸,Remove Window from Set):After (local build of develop with this change, fresh profile) — the injected section follows the system language as well (填充 / 居中 / 进入全屏幕 / 移动和调整大小 / 全屏幕平铺 / 从组合中移掉窗口):
Testing
marktext.app/Contents/Resourcesretains all 11 relevant.lprojfolders (en, de, es, fr, ja, ko, pt_BR, pt_PT, tr, zh_CN, zh_TW) instead of justen— the after screenshot above is from that build.zh_CN.lproj) while Windows/Linux use hyphens (zh-CN.pak), so region-specific locales need both spellings to take effect on every platform.