[i18n] Native localisation interface + external locales (en, zh-CN, zh-TW, ja, ko, fr-FR, ru-RU) #4913

Closed
github-bot wants to merge 24 commits from github-bot/gh-4912 into main AGit
Owner

@⁠WanderLinks on GitHub · 2026-12-01 13:35 UTC · original
WanderLinks:i18n → main · +7416 −903 · 50 files · 24 commits · closed without merging

Motivation
The F1 menu is hardcoded uppercase English (menu.rs, ITEMS,
46 entries) drawn with a 5x7 Latin-only glyph table
(font.rs). Non-English users cannot read the settings.
Third-party launchers already ship their own Chinese
translations, so the demand is real. This PR turns
language into an interface plus external files.

What this PR does

  • New zero-dependency crate victory-i18n: Localizer
    trait, PassthroughLocalizer (default, English unchanged),
    FileLocalizer (external TOML subset), offline
    Dictionary (glossary.toml) in place of online
    auto-translation (deliberately cut: no network, no keys).
  • External locales: 7 languages, the whole F1 menu
    (47 labels incl. the language row, 9 actions, 37 values,
    title, help, marks, notes, 174 explanation lines:
    288 keys per language). Explanations are fully
    translated in all 7 languages (drafts, not reviewed
    by native speakers; the file headers say so).
  • Language row first in the menu (VICTORY_MENU_LANGUAGE,
    live, saved at once): Auto follows the Windows display
    language (zh-Hant -> zh-TW, zh-Hans -> zh-CN), or pick
    one of the 7 languages; switching reloads the menu.
  • CJK column alignment by display width (wide chars count
    as 2 cells), so the < value > column lines up.
  • Text backend interface with a GDI implementation
    (font fallback chain, dot-glyph fallback on failure);
    DirectWrite is a follow-up, the interface is ready.
  • Menu scale raised (shared scale() helper, one step
    per 360 lines of back-buffer height: scale 3 at 1080p,
    the box covers 57% x 83% of the frame instead of
    38% x 50%); the panel scales with it. GDI text is now
    antialiased (ANTIALIASED_QUALITY, not ClearType).
  • Row pitch and value-column alignment: CELL.1 is 10 (was 9),
    so a row is 30px at scale 3 against a 24px GDI character
    (FONT_EM * scale, decoupled from the cell — a glyph as tall
    as its cell would leave only ~6px of leading), ~9px leading,
    the original launcher's 1.41 pitch-to-glyph ratio; glyphs
    are drawn with TextOutW, one grid cell per character (the
    rendering the user approved in the 16:44 screenshot; a
    GetGlyphOutlineW rasteriser with natural advances was
    tried and reverted at the user's decision — see DESIGN.md
    §9); the < value > column is still fixed (the value, the
    title's close text and a bindings row's value all start at
    their grid column); labels are cut to a 27-cell field before
    padding; the key-bindings screen uses the same width rule. The
    27-cell cap applies only to localised menus — the
    upstream English ASYNC SUBMIT (37 cells) is shown whole,
    as before. 8 over-long labels were shortened in the
    language files (zh-CN 2, ja 4, ru 2).
  • Switches: VICTORY_I18N (default 0), VICTORY_LOCALE,
    VICTORY_LOCALE_DIR, VICTORY_TEXT_BACKEND,
    VICTORY_DICTIONARY.

Tests

  • cargo test -p victory-i18n: 15 unit tests + 1
    integration test pass (7 languages x 288 keys), on
    Linux (Rust 1.98.1) and Windows 11 (Rust 1.98.1,
    VS 2022 BuildTools MSVC 14.44).
  • cargo clippy -p victory-i18n --all-targets -- -D warnings: clean on both.
  • cargo check -p victory-gpu: pass.
  • cargo test -p victory-gpu menu: 39 tests pass,
    incl. language-row switching, value translation,
    CJK width, upstream-insert/rename fallback, the
    dictionary fallback for a deleted translation, and
    the 27-cell label cap for localised menus.
  • cargo test -p victory-gpu gdi_draws: 2 pixel tests
    pass — the value bracket < lands in the same column
    on a Latin-label row and a Chinese-label row; a bindings
    row's value lands in the same column although it has no
    < (checked by its ink's midpoint — W is wider than
    its 18px cell, so its ink overhangs the cell on both
    sides). A third pixel test (natural advances) was removed
    with the reverted rasteriser.
  • Full workspace CI (cargo clippy --workspace,
    cargo test --workspace): run 2026-12-01. Clippy
    fails on 3 pre-existing upstream issues and 3 tests
    fail, all verified identical on a clean v2026.11.30.03
    checkout (see DESIGN.md §9); none is caused by this PR.
    Latest full cargo test -p victory-gpu re-run after the
    rasteriser was reverted: 1143 pass / 3 fail (2
    deterministic upstream bugs + 1 timing-sensitive test
    that passes standalone).
  • Manual F1 screenshots (zh-CN vs en, VICTORY_I18N=1
    vs =0): the menu is verified on real hardware through
    several rounds (row pitch, value-column alignment,
    brackets, TOML switch all confirmed by user screenshots);
    after the rasteriser was reverted, the 2026-12-01 18:48
    user screenshot confirmed it again: no crash, menu as in
    the 16:44 image, 30 fps at the cap.
  • A crash seen once while running the game (2026-12-01
    17:52, with the rasteriser build) was investigated and is
    NOT caused by this PR: the fault is a stack buffer overrun
    inside the NVIDIA driver (nvwgf2umx.dll 32.0.16.1074)
    during D3D12 shader compilation at startup, with zero
    victory.exe frames on the faulting thread's stack; the game
    had crashed the same way before. Reverting the rasteriser
    does not fix it — it is a driver-side issue (see
    DESIGN.md §9).

Risks and rollback

  • Default off: zero behaviour change when VICTORY_I18N=0.
  • Broken locale files degrade to English, never fail start.
  • A missing translation falls back through language file
    -> dictionary -> English -> original text, never empty,
    never a panic. A new upstream menu item with no
    translation shows English until translated.
  • Rollback: VICTORY_I18N=0, or revert the commits.
  • Translations are drafts, not human-reviewed; native
    speakers welcome to correct them.

Prior art (checked 2026-12-01, see REFERENCES.md)

  • #1977 (open, unmerged, conflicts with main): F1 menu and
    key-bindings screen in Chinese, hardcoded tr("EN", "ZH")
    pairs, no external files, VICTORY_MENU_LANGUAGE. Its saved
    language choice was lost at launch (the child-process env
    skipped VICTORY_MENU_* items); this PR keeps the choice in
    the settings file and the game process env, verified by a
    restart round-trip (see REFERENCES.md §10). #1997 grew out
    of #1977's comment thread (different author).
  • #1997 (open, unmerged, conflicts with main): 7 languages
    hardcoded in Rust, language row first, VICTORY_UI_LANGUAGE.
    This PR keeps the same row position and Auto behaviour,
    but the translations live in external files, so adding a
    language needs no code change and no rebuild.
  • #2445 (closed, unmerged): Chinese only, hardcoded table,
    GDI drawing. This PR reuses the GDI approach with a
    longer font fallback chain and covers 7 languages.
  • Naming: VICTORY_LOCALE / VICTORY_MENU_LANGUAGE here vs
    VICTORY_UI_LANGUAGE (#1997) / VICTORY_MENU_LANG (#2445).
    VICTORY_LOCALE is the general switch; the row writes
    VICTORY_MENU_LANGUAGE into the settings file (the same
    variable name #1977 used).

Maintenance

  • The patches are a snapshot of v2026.11.30.03. The
    recommended way to follow upstream is a branch on top
    of upstream main, rebased as main moves; see DESIGN.md
    §12 for what merges cleanly and what needs a human.
  • check-upstream.ps1 (in this folder) checks whether
    the patches still apply to a clean checkout, no git
    needed: check-upstream.ps1 -Patch integration.patch -Checkout <clean v2026.11.30.03 tree>.
**@⁠WanderLinks** on GitHub · 2026-12-01 13:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4912) `WanderLinks:i18n` → `main` · +7416 −903 · 50 files · 24 commits · closed without merging Motivation The F1 menu is hardcoded uppercase English (menu.rs, ITEMS, 46 entries) drawn with a 5x7 Latin-only glyph table (font.rs). Non-English users cannot read the settings. Third-party launchers already ship their own Chinese translations, so the demand is real. This PR turns language into an interface plus external files. What this PR does - New zero-dependency crate `victory-i18n`: `Localizer` trait, `PassthroughLocalizer` (default, English unchanged), `FileLocalizer` (external TOML subset), offline `Dictionary` (glossary.toml) in place of online auto-translation (deliberately cut: no network, no keys). - External locales: 7 languages, the whole F1 menu (47 labels incl. the language row, 9 actions, 37 values, title, help, marks, notes, 174 explanation lines: 288 keys per language). Explanations are fully translated in all 7 languages (drafts, not reviewed by native speakers; the file headers say so). - Language row first in the menu (VICTORY_MENU_LANGUAGE, live, saved at once): Auto follows the Windows display language (zh-Hant -> zh-TW, zh-Hans -> zh-CN), or pick one of the 7 languages; switching reloads the menu. - CJK column alignment by display width (wide chars count as 2 cells), so the `< value >` column lines up. - Text backend interface with a GDI implementation (font fallback chain, dot-glyph fallback on failure); DirectWrite is a follow-up, the interface is ready. - Menu scale raised (shared `scale()` helper, one step per 360 lines of back-buffer height: scale 3 at 1080p, the box covers 57% x 83% of the frame instead of 38% x 50%); the panel scales with it. GDI text is now antialiased (`ANTIALIASED_QUALITY`, not ClearType). - Row pitch and value-column alignment: `CELL.1` is 10 (was 9), so a row is 30px at scale 3 against a 24px GDI character (`FONT_EM * scale`, decoupled from the cell — a glyph as tall as its cell would leave only ~6px of leading), ~9px leading, the original launcher's 1.41 pitch-to-glyph ratio; glyphs are drawn with `TextOutW`, one grid cell per character (the rendering the user approved in the 16:44 screenshot; a `GetGlyphOutlineW` rasteriser with natural advances was tried and reverted at the user's decision — see DESIGN.md §9); the `< value >` column is still fixed (the value, the title's close text and a bindings row's value all start at their grid column); labels are cut to a 27-cell field before padding; the key-bindings screen uses the same width rule. The 27-cell cap applies only to localised menus — the upstream English ASYNC SUBMIT (37 cells) is shown whole, as before. 8 over-long labels were shortened in the language files (zh-CN 2, ja 4, ru 2). - Switches: VICTORY_I18N (default 0), VICTORY_LOCALE, VICTORY_LOCALE_DIR, VICTORY_TEXT_BACKEND, VICTORY_DICTIONARY. Tests - `cargo test -p victory-i18n`: 15 unit tests + 1 integration test pass (7 languages x 288 keys), on Linux (Rust 1.98.1) and Windows 11 (Rust 1.98.1, VS 2022 BuildTools MSVC 14.44). - `cargo clippy -p victory-i18n --all-targets -- -D warnings`: clean on both. - `cargo check -p victory-gpu`: pass. - `cargo test -p victory-gpu menu`: 39 tests pass, incl. language-row switching, value translation, CJK width, upstream-insert/rename fallback, the dictionary fallback for a deleted translation, and the 27-cell label cap for localised menus. - `cargo test -p victory-gpu gdi_draws`: 2 pixel tests pass — the value bracket `<` lands in the same column on a Latin-label row and a Chinese-label row; a bindings row's value lands in the same column although it has no `<` (checked by its ink's midpoint — `W` is wider than its 18px cell, so its ink overhangs the cell on both sides). A third pixel test (natural advances) was removed with the reverted rasteriser. - Full workspace CI (`cargo clippy --workspace`, `cargo test --workspace`): run 2026-12-01. Clippy fails on 3 pre-existing upstream issues and 3 tests fail, all verified identical on a clean v2026.11.30.03 checkout (see DESIGN.md §9); none is caused by this PR. Latest full `cargo test -p victory-gpu` re-run after the rasteriser was reverted: 1143 pass / 3 fail (2 deterministic upstream bugs + 1 timing-sensitive test that passes standalone). - Manual F1 screenshots (zh-CN vs en, VICTORY_I18N=1 vs =0): the menu is verified on real hardware through several rounds (row pitch, value-column alignment, brackets, TOML switch all confirmed by user screenshots); after the rasteriser was reverted, the 2026-12-01 18:48 user screenshot confirmed it again: no crash, menu as in the 16:44 image, 30 fps at the cap. - A crash seen once while running the game (2026-12-01 17:52, with the rasteriser build) was investigated and is NOT caused by this PR: the fault is a stack buffer overrun inside the NVIDIA driver (nvwgf2umx.dll 32.0.16.1074) during D3D12 shader compilation at startup, with zero victory.exe frames on the faulting thread's stack; the game had crashed the same way before. Reverting the rasteriser does not fix it — it is a driver-side issue (see DESIGN.md §9). Risks and rollback - Default off: zero behaviour change when VICTORY_I18N=0. - Broken locale files degrade to English, never fail start. - A missing translation falls back through language file -> dictionary -> English -> original text, never empty, never a panic. A new upstream menu item with no translation shows English until translated. - Rollback: VICTORY_I18N=0, or revert the commits. - Translations are drafts, not human-reviewed; native speakers welcome to correct them. Prior art (checked 2026-12-01, see REFERENCES.md) - #1977 (open, unmerged, conflicts with main): F1 menu and key-bindings screen in Chinese, hardcoded tr("EN", "ZH") pairs, no external files, VICTORY_MENU_LANGUAGE. Its saved language choice was lost at launch (the child-process env skipped VICTORY_MENU_* items); this PR keeps the choice in the settings file and the game process env, verified by a restart round-trip (see REFERENCES.md §10). #1997 grew out of #1977's comment thread (different author). - #1997 (open, unmerged, conflicts with main): 7 languages hardcoded in Rust, language row first, VICTORY_UI_LANGUAGE. This PR keeps the same row position and Auto behaviour, but the translations live in external files, so adding a language needs no code change and no rebuild. - #2445 (closed, unmerged): Chinese only, hardcoded table, GDI drawing. This PR reuses the GDI approach with a longer font fallback chain and covers 7 languages. - Naming: VICTORY_LOCALE / VICTORY_MENU_LANGUAGE here vs VICTORY_UI_LANGUAGE (#1997) / VICTORY_MENU_LANG (#2445). VICTORY_LOCALE is the general switch; the row writes VICTORY_MENU_LANGUAGE into the settings file (the same variable name #1977 used). Maintenance - The patches are a snapshot of v2026.11.30.03. The recommended way to follow upstream is a branch on top of upstream main, rebased as main moves; see DESIGN.md §12 for what merges cleanly and what needs a human. - `check-upstream.ps1` (in this folder) checks whether the patches still apply to a clean checkout, no git needed: `check-upstream.ps1 -Patch integration.patch -Checkout <clean v2026.11.30.03 tree>`.
`slots_showing` took the slot's `Made` key with `?`, but `Made` has keys
for the title's `count` slots only while `kept` also has the dynamic
ones: a host texture shown by a dynamic slot was no longer reported, so
it was no longer blocked and could be chosen (freeing nothing, as the
dynamic slot holds a reference, while the title made a second copy).
Those slots are reported again with key 0, as before the key was carried;
they are never put back to waiting, only counted as blocking. Test:
`a_dynamic_slot_showing_a_texture_still_blocks_its_eviction`.

`SLOT_LOOKING` is now cleared by a drop guard, so a look that panics does
not stop every later look.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b23c0c4038)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 13:38:09 +00:00
github-bot closed this pull request 2026-12-01 18:30:35 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:28 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4912#issuecomment-7321007509) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4913
No description provided.