Skip to content

fix(i18n): translate English placeholders, remove unused keys, validate keys on build - #6120

Merged
Tkaixiang merged 3 commits into
developfrom
fix/locale-untranslated-strings
Nov 23, 2026
Merged

Tkaixiang merged 3 commits into
developfrom
fix/locale-untranslated-strings

Conversation

@Tkaixiang

@Tkaixiang Tkaixiang commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

No linked issue. Found while reviewing #6111.

Summary

Recent feature PRs added English placeholder values to most locale files, and nobody translated them afterwards. The existing locale specs only check that every locale has the same keys, so they didn't catch it. This PR fixes the strings, deletes keys nothing uses, and adds a check that runs before every build. There are three commits:

  1. Translate strings left in English (264 values)

  2. Remove 18 unused keys from all 14 locale files. Nothing in packages/desktop/src references them, either directly or through a key built in code. For example, readingMode.skipped stopped being used in feat: enable durable startup, workspace and multi-window recovery (5/5) #5922, and sideBar.search.searchInFolder was replaced by searchInFolders. The full list is in the commit message.

    Size saved: 11,171 bytes (2.23%) across the shipped .min.json files, from 500,878 to 489,707. In the source JSON it is 13,061 bytes (2.11%), from 618,562 to 605,501. That works out to about 710–890 bytes per minified locale, or about 1,090 for ru, whose Cyrillic text takes 2 bytes per character in UTF-8.

  3. Validate locale keys in scripts/minify-locales.ts before writing the .min.json files. The script now exits 1 if:

    • a locale is missing a key from en.json, or has a key that en.json doesn't, or
    • an en.json key isn't referenced by any .ts or .vue file under packages/desktop/src.

    The usage check is a single ripgrep pass, about 2 seconds, that collects quoted dotted strings. Template literals (`menu.theme.${name}`) and concatenated prefixes ('sideBar.move.' + reason) match as patterns, so keys built in code still count as used. ripgrep comes from @vscode/ripgrep, resolved through packages/desktop, which already depends on it. No new dependency.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • No new unit tests. The validator is itself the check, and it runs in every build:* script. I confirmed it fails with exit 1 when I added a key missing from one locale, an extra key, and an unused key.
  • pnpm run minify-locales: 14 locales, 809 keys, all present and referenced. It also works from packages/desktop, which is how the build scripts call it.
  • Locale specs pass: locale-validation, language-registries, i18n, context-menu-locales, and Muya localeCompleteness.
  • Full desktop unit suite: 1716 passed. The only failures are 2 tests in sidebar-move.spec.ts, which fail with EPERM because creating symlinks on Windows needs Developer Mode. They're unrelated to this PR.
  • ESLint and Prettier are clean on scripts/minify-locales.ts.
  • Manually tested on: Windows

Notes for reviewers [optional]

  • Translations need native review. Each one follows its locale's existing tone (du / vous / tú, formal ru/tr), quote style („…“, « … », 「…」) and terms for "sidebar" and "folder". Native speakers should still check them.
  • Left in English on purpose: product and theme names, Front Matter (the locale specs require it), and words that are the same in that language, such as de "Format" and fr "Document". pt's Muya "Rich Text" also stays, because pt's desktop file already uses "Copiar como Rich Text".
  • Builds now fail on unused or mismatched keys. A PR that adds a key to en.json without using it, or without adding it to every locale, will fail the build until that's fixed.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Tkaixiang and others added 3 commits November 23, 2026 17:09
Several feature PRs added English placeholder values to most locales and
they were never translated:

- sideBar.move.* (13 keys, #5945): de, es, fr, ja, ko, nl, pt, ru, tr, zh-TW
- multi-folder sidebar strings (12 keys, #5835): de, es, fr, ja, ko, nl, pt,
  ru, tr
- preferences.editor.fileRepresentation.tabInputNotes (#5891): same 9 locales

Also fills one-off gaps: GitHub Alerts labels in pl (desktop and Muya) and
it (Muya), the Academic export theme in it, and the super/subscript
extension label in es and pt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
None of these keys is referenced anywhere in packages/desktop/src, either
as a literal or through a template/prefix key:

- menu.counter.document, documentSelection, charactersNoSpaces,
  allCharacters
- sideBar.tree.noFolders, overlappingFolder
- sideBar.search.searchInFolder (the UI uses searchInFolders)
- preferences.theme.modeThemes
- dialog.file, files, keepOpen, saveFailure
- error.report, unexpectedErrorWithMessage
- store.editor.anchorLinkCopied
- editor.sourceCode.cursorNullComment, imageStructureDeletedComment
- readingMode.skipped

Co-Authored-By: Claude Opus 5.5 <[email protected]>
minify-locales now fails, before writing any .min.json, when:

- a locale is missing a key from en.json or has a key en.json lacks
- an en.json key is not referenced by any .ts or .vue file under
  packages/desktop/src

The usage check is a single ripgrep pass that collects quoted dotted
strings. Template literals (`menu.theme.${name}`) and concatenation
prefixes ('sideBar.move.') match as patterns, so keys built from a
variable still count as used. ripgrep comes from @vscode/ripgrep,
resolved through packages/desktop, which already declares it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Tkaixiang
Tkaixiang requested a review from Jocs November 23, 2026 09:18
@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #6120:

Run: https://github.com/marktext/marktext/actions/runs/45145805811

Artifact Size Link
marktext-linux-x64 729.2 MB Download
marktext-windows-arm64 327.3 MB Download
marktext-windows-x64 335.4 MB Download
marktext-macos-x64 332.0 MB Download
marktext-macos-arm64 320.4 MB Download
marktext-linux-arm64 570.9 MB Download

@Tkaixiang
Tkaixiang merged commit 95a14e5 into develop Nov 23, 2026
19 checks passed
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.

2 participants