Skip to content

feat(i18n): add Russian (ru) localization - #5496

Merged
Jocs merged 7 commits into
marktext:developfrom
blvcknwh1te:feat/russian-localization
Sep 22, 2026
Merged

Jocs merged 7 commits into
marktext:developfrom
blvcknwh1te:feat/russian-localization

Conversation

@blvcknwh1te

Copy link
Copy Markdown
Contributor

Closes #4444

Summary

Adds a native Russian (ru) localization for both translation layers, so users can pick Русский in Preferences → General → Language (no patcher / app.asar edits required).

  • packages/desktop/static/locales/ru.json — full desktop UI translation, key-for-key parity with en.json (placeholder and tech-term checks included)
  • packages/muya/src/locales/ru.ts — muya editor engine strings, parity with en.ts
  • Register ru in SUPPORTED_LANGUAGES, the Preferences language selector and the editor's MUYA_LOCALES
  • Add the Russian label to every locale's language list, which locale-validation.spec.ts enforces as key parity
  • Update the locale specs to cover the new locale (desktop i18n.spec.ts now uses pl-PL as its unsupported-locale example)

Type of change

  • New feature (non-breaking, adds functionality)

Test plan

  • New tests added (or explain why not needed) — locale parity / boot specs now cover ru
  • Manually tested on: Windows

Local gate (all green): pnpm lint, pnpm typecheck, pnpm test (866 passed); pnpm -C packages/muya lint, lint:types, test (1988 passed), test:spec (1347 passed), build, check-circular. Also built the Windows installer, installed it, and confirmed the app boots with the Russian UI selectable and applied.

Notes for reviewers [optional]

  • CONTRIBUTING.md still says "Translation (currently unavailable)". I opened this because Russian lang | Русский язык #4444 asks for Russian support and the locale data can be reused either way — happy to move it if translations are intentionally deferred.
  • No new i18n machinery: ru is wired exactly like the existing locales, and the translation covers every key in en.json / en.ts, so there are no English fallbacks at runtime.

blvcknwh1te and others added 7 commits September 21, 2026 23:35
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)
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]>
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]>
`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]>
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]>
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]>
…ation

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]>
@Jocs
Jocs merged commit 4ea10e3 into marktext:develop Sep 22, 2026
14 of 15 checks passed
Jocs added a commit that referenced this pull request Sep 22, 2026
Adding a UI language means editing lists in five places that nothing checks
against each other, and they have drifted twice under a green CI run: `nl`
never reached the engine locale map (#5499) and `ru` never reached
`electronLanguages` (#5496).

Assert that SUPPORTED_LANGUAGES, the locale JSON files on disk, the
Preferences dropdown, MUYA_LOCALES and electronLanguages all describe the
same set, and name the file to edit in each failure message. The
electronLanguages arm matches on the primary subtag, since Electron ships
pt-BR/pt-PT rather than a bare `pt`, and spells macOS bundles with an
underscore.

The yml block is hand-parsed: no YAML parser is a declared dependency here,
and reaching for the one electron-builder hoists into node_modules would be
the phantom dependency that broke #5159.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Jocs added a commit that referenced this pull request Sep 22, 2026
…#5504) (#5505)

`copies a 600-level nested list without exhausting the stack` failed
intermittently on CI with RangeError — twice on unrelated PRs (#5496, #5502),
passing on re-run with no code change.

The recursion was in the test, not in `deepClone`. Measured ceilings for the
fixture shape this spec builds:

  deepClone(nested(d)) alone     100000 levels, never threw
  the test body, verbatim        ok <= 900, RangeError @ 1000
  expect(a).not.toBe(b)          ok <= 900, RangeError @ 1000
  structuredClone (the #4747     ok <= 600, throws @ 700
    control)

`expect(copy).not.toBe(state)` hands the whole 600-level structure (~2400
nested containers) to Vitest, which recurses once per level inspecting the
argument. That left a margin of 600 -> ~900, and the ceiling moves with the
Node build and the worker thread's stack size, so CI landed on the wrong side
of it about half the time.

Compare identity outside the matcher so only booleans reach `expect`. With
the fixture raised to 10000 levels the spec now passes; restoring just those
two lines at the same depth reproduces the CI RangeError exactly.

The spec's own comment already warned that "a recursive equality check" would
overflow this input — `expect(deepObject)` is one.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Jocs added a commit that referenced this pull request Sep 22, 2026
Adding a UI language means editing lists in five places that nothing checks
against each other, and they have drifted twice under a green CI run: `nl`
never reached the engine locale map (#5499) and `ru` never reached
`electronLanguages` (#5496).

Assert that SUPPORTED_LANGUAGES, the locale JSON files on disk, the
Preferences dropdown, MUYA_LOCALES and electronLanguages all describe the
same set, and name the file to edit in each failure message. The
electronLanguages arm matches on the primary subtag, since Electron ships
pt-BR/pt-PT rather than a bare `pt`, and spells macOS bundles with an
underscore.

The yml block is hand-parsed: no YAML parser is a declared dependency here,
and reaching for the one electron-builder hoists into node_modules would be
the phantom dependency that broke #5159.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Jocs added a commit that referenced this pull request Sep 22, 2026
…e registries together (#5502)

* refactor(desktop): move the muya locale map out of editor.vue

The map from the desktop language preference to the engine's locale objects
lived inside a 2000-line SFC, where no unit test can reach it. Lift it to
`util/muyaLocale.ts` unchanged so the next commits can fix and then guard it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(i18n): give Dutch users the Dutch editor UI (#5499)

`nl.ts` has been complete since #5137 and `locales/index.ts` exports it, but
`nl` never reached the three lists the desktop reads: the `@muyajs/core`
export hub, the desktop's type surface for it, and MUYA_LOCALES. Picking
Nederlands therefore hit the `?? en` fallback, leaving the inline format
toolbar, quick-insert menu, emoji picker, image selector and preview-block
strings in English while the rest of the app was Dutch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(desktop): hold the language registries to each other (#5500)

Adding a UI language means editing lists in five places that nothing checks
against each other, and they have drifted twice under a green CI run: `nl`
never reached the engine locale map (#5499) and `ru` never reached
`electronLanguages` (#5496).

Assert that SUPPORTED_LANGUAGES, the locale JSON files on disk, the
Preferences dropdown, MUYA_LOCALES and electronLanguages all describe the
same set, and name the file to edit in each failure message. The
electronLanguages arm matches on the primary subtag, since Electron ships
pt-BR/pt-PT rather than a bare `pt`, and spells macOS bundles with an
underscore.

The yml block is hand-parsed: no YAML parser is a declared dependency here,
and reaching for the one electron-builder hoists into node_modules would be
the phantom dependency that broke #5159.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Russian lang | Русский язык

2 participants