Repository navigation
i18n: Russian support for user-facing surfaces via --lang / MTK_LANG (default: en) - #471
0-danielviktorovich-0 wants to merge 11 commits into
Conversation
|
Second pass over this PR with real execution checks (Python 3.13, venv); three minor holes found
The three holes, fixed in bc21e2e:
Notes for later (none blocking):
|
Add mtkclient/i18n.py, a minimal translation layer for user-facing strings: po-like dictionaries keyed by the English string, with t() passing unknown keys through unchanged so a missing translation can never break a call. Activation happens before argparse is built, with the following precedence: --lang CLI flag > MTK_LANG environment variable > default "en". An unknown language falls back to "en" with a warning on stderr. The default keeps every string unchanged, so upstream behavior is preserved unless the user explicitly opts in (--lang ru or MTK_LANG=ru); the change is a two-way door — removing the flag and the variable restores the previous behavior. The CLI help (mtk.py) is routed through the new layer in Russian; Library/ stays English to keep the PR minimal and mergeable.
Wrap the hardcoded user-visible strings of mtk_gui.py that bypassed
Qt-translate (serial-port selection dialog, View/Dark Mode menu,
Total/Current section progress labels, BROM/DA/preloader boot modes,
status prints) in t(), so the same language switch covers the GUI.
Strings already going through QCoreApplication.translate are left
alone: they are covered by the existing ru_RU.ts/.qm ("Done." was the
only gap and is now picked up via t()).
load_translations() now gives priority to the language selected by
the i18n layer (MTK_LANG), so Qt translations can be chosen without
changing the system locale; other locales (nl_NL etc.) behave as
before. Default remains English unless explicitly activated via
--lang ru / MTK_LANG=ru.
Cover the activation paths and failure behavior of the i18n layer: - unit tests: default "en", MTK_LANG=ru activation, unknown language falls back to "en", --lang overrides the environment, value normalization, pass-through of unknown keys; - an AST ratchet: every constant key passed to t() in mtk.py and mtk_gui.py must have a Russian translation, so a typo can no longer silently degrade into English; - subprocess smoke tests: Russian help renders, the "en" default is unchanged, MTK_LANG=zz yields English, and --lang ru works.
c847370 to
50975c2
Compare
Add a full Russian translation of the upstream README (README_ru.md) and a one-line language switcher at the top of README.md; no other content is touched.
|
Commit messages rewritten in English (initially authored in Russian by mistake); README translation added |
…lang case, extend AST ratchet Co-authored-by: i18n-review <adversarial-review>
|
Review findings applied in bc21e2e: seed/aeskey help translated, --lang case normalization added (both --lang and MTK_LANG), AST ratchet extended to non-constant dict keys (34/34). Also added README_ru.md (docs: Russian README translation) per project's zh-CN translation convention. Full i18n test suite green (14/14). |
Natural-language Russian translations of the installation, usage and Windows setup guides, following the zh-CN naming convention (README-*.ru-RU.md). Command names, flags, BROM/DA/preloader terms and code blocks are kept verbatim.
Add ru-RU editions of the DA info table and the preloader emulation traces (mmc_init, mmc_only_init). Register/command/constant names and trace lines are intentionally untranslated; each file carries a short Russian translator's note and the body stays byte-identical to the original.
Rename the Russian README via git mv, point the README.md language switcher to it, add the RU flag entry and link the Russian sub-docs from the Russian README, mirroring how README.zh-CN.md links its translations.
… UART traces These Tools/*.txt files are hwcode-table dumps and preloader-emulation log traces (READ/WRITE register lines + firmware UART output) with no explanatory prose — verified byte-identical after attempted translation. Russian versions would be noise; the English originals remain the reference.
…red by the Language flag block)
This adds a ru translation layer for the user-facing surfaces:
--lang ru/MTK_LANG=ruswitchesargparse help (~150 strings, 34 commands + 5 groups), the hardcoded GUI strings in
mtk_gui.py(serial-port dialog, View/Dark Mode menu, progress labels, boot modes), and the existing upstream
Qt translation (
ru_RU.qmshipped upstream, reused viaMTK_LANG, not duplicated). Docs getRussian
.ru-RU.mdsiblings following the repo's zh-CN convention. Defaulten: string rendering byte-identicalto upstream (help, GUI and docs strings; the only CLI change is the additive
--langflag).Design (minimal-invasive):
mtkclient/i18n.py: po-like en/ru dictionaries; activation priority--lang ru>MTK_LANG> defaulten.enstring rendering is byte-identical to upstream (verified: en smoke diff-empty); theonly CLI change is the additive
--langflag.Library/internals (263 print sites) intentionally stay EN. That keeps the diff reviewable;user-facing CLI/GUI surfaces only.
--lang RU==MTK_LANG=RU); unknown langs fallback to
en.project convention.
Verification
zzfallback, AST ratchet 34/34 guarding dict keys) + upstream suite green; GUI offscreen smoke
(ru_RU.qm engaged, en untouched); flake8 clean on new files.
--langnormalization, ratchet extended.
Documentation (Russian)
README.ru-RU.md(switcher in README.md) +README-INSTALL/USAGE/WINDOWS.ru-RU.md,learning_resources.ru-RU.md,src/stage1/build.ru-RU.md, following the repo's existing zh-CNconvention; commands/flags/BROM/DA/preloader terms untouched.
Tools/*.txtare byte-identical hwcode-table dumps and preloader-emulation UART traces with notranslatable prose (verified), so no ru copies needed.
Related
da ramtest/da dram-repair/da certCLI help strings areuser-facing surfaces; once both PRs land, the
rutable needs entries for them (the AST ratchetin this PR flags missing keys).
PR family.
2717:FF48from the live begonia probe.Update 2026-12-01
stagingbranch = main + Add SP Flash Tool feature port: scatter parser, memtest, auto-format, imagecheck, chksum, flash.xml loader + da ramtest/dram-repair/cert CLI #469/Surface USB EACCES instead of swallowing it (claim_interface / kamakiri2 exploit) #470/usb: detect Xiaomi preloader VCOM 2717:FF48 (Redmi Note 8 Pro / begonia) #472 + two new PRs(Port: guard vanished endpoints during BROM-window handshake; colorformatter: drop logger-name print #480/Port/preloader: SPFT-parity handshake (READY 0x52), status threshold <0x1000, DA checksum hard-fail + --force-continue #481) + this layer; 14/14 i18n tests green, AST ratchet green. One new key was added
for the Port/preloader: SPFT-parity handshake (READY 0x52), status threshold <0x1000, DA checksum hard-fail + --force-continue #481
--force-continuehelp string ("Continue after DA upload checksum mismatch…"),ru entry carried over from the verified rescue tree.
c847370referenced in an older comment is now
bc21e2e(same content).