Add native interface localization with external TOML locales #4914
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4914
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4913"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@WanderLinks on GitHub · 2026-12-01 13:39 UTC · original
WanderLinks:feature/native-i18n→main· +3359 −170 · 16 files · 1 commits · closed without mergingWhat it changes
Adds a native, data-driven interface localization layer so the launcher's
own menus can run in languages other than English.
victory-i18ncrate: aLocalizerwith key-based lookup, a TOMLcatalog with
{placeholder}rendering, locale discovery across searchroots, a fallback chain (locale -> bare language -> English), and runtime
switching behind a process-wide lock.
through it. English is kept as an in-code fallback, so a missing key or
locale file is never fatal.
immediately and the choice is persisted for the next launch.
locales/en.toml,locales/zh-CN.toml,494 keys each). Dropping a new
.tomlinto a locale directory makes itappear in the selector without code changes or rebuilding. The build
script copies the repository locales next to the executable.
canvas (
host/font.rs) already renders non-Latin scripts through systemfont fallback. This change is language data plus lookup only.
Pre-existing Clippy failure on main (not introduced here)
mainitself does not pass the Clippy gate under the pinned toolchain. Thefive findings in
font.rs(twotoo_many_arguments),menu.rs(
manual_is_multiple_of) andpanel.rs(twocollapsible_if) reproduce ona clean checkout of
5fabb46, and the5fabb46push run fails at theClippy step. They are unrelated to this change and are fixed separately in
#4708 (also #4680). This branch therefore shows the same Clippy red until
that lands; none of the new
victory-i18ncode produces a Clippy warning.How it was tested
Windows with the pinned 1.98.1 toolchain.
behaviour changes.
changes).
cargo testpassed for the crates it touches: yes.cargo test -p victory-i18n(21 passed) and the whole workspace builds with--locked.The full
cargo test --workspaceis gated only by the pre-existingClippy failure described above; the heavy GPU end-to-end tests are memory
sensitive on this 16 GB host and pass when run individually, unrelated to
this change.
cargo xtask policypasses (472 files), and the buildscript copies both locales next to the debug and release executables.
Commit tested: see the branch head.
Checked for overlap
this touches. No open PR adds interface localization. The separate Clippy
fix #4708 / #4680 is what this needs for a green check. The UI rework #4712
has a different goal (categorized F1 menu, live scale, compact F3) but also
edits
menu.rs/panel.rs, so it may need a rebase if it lands first; thechanges are otherwise independent.
Introduces a new victory-i18n crate that owns the language layer only: a Localizer trait with a key-based lookup, a TOML message catalog with {placeholder} rendering, locale discovery across search roots, a fallback chain (locale -> bare language -> English), and runtime switching behind a process-wide lock. Every user-facing string in the F1 menu and the F3 stats panel now resolves through it, with English kept as an in-code fallback so a missing locale file is never fatal. Text rendering is unchanged: the existing GDI Unicode canvas already covers non-Latin scripts through system font fallback, so this adds no font rasterizer and no translation engine. The locales shipped in the repository (en, zh-CN) are plain TOML; dropping a new .toml into a locale directory makes it selectable from the interface-language row without touching code or rebuilding. The build script copies the repository locales next to the executable.@ -36,0 +60,4 @@let target = out_dir.join("..").join("..").join("..").join("locales");// Start from a clean destination so a deleted source file does not linger.let _ = std::fs::remove_dir_all(&target);@gut0to on GitHub · 2026-12-01 13:54 UTC · original · edited 2026-12-01 14:14 UTC
Could this avoid deleting the entire locale directory beside the executable?
I18n::locale_roots()searches there, and the PR describes external.tomlcatalogs as user-provided files;remove_dir_alltherefore erases those catalogs on every rebuild. Cleaning only filenames shipped by this build, or copying without removing unrelated files, would remove stale bundled catalogs without deleting user additions. AI-assisted review: I used an AI assistant to inspect this diff.@ -0,0 +144,4 @@if let Some(builtin) = Builtin::ALL.iter().find(|b| b.code() == normalized) {return Ok(Locale::Builtin(*builtin));}Ok(Locale::Custom(normalized))@gut0to on GitHub · 2026-12-01 13:54 UTC · original · edited 2026-12-01 14:14 UTC
Could
Locale::from_strreject path separators and invalid subtags before constructingLocale::Custom?../outsidecurrently survivesnormalize,file_name()becomes../outside.toml, andload_from_rootsjoins it to each configured root before reading, so that lookup can escape the locale directory. A validation test for/,\, and..would protect the root boundary. AI-assisted review: I used an AI assistant to inspect this diff.@ -0,0 +160,4 @@let mut subtags = raw.trim().split('-');let language = subtags.next().unwrap_or("").to_lowercase();let mut out = language;if let Some(region) = subtags.next() {@gut0to on GitHub · 2026-12-01 13:54 UTC · original · edited 2026-12-01 14:14 UTC
Could normalization preserve every valid BCP-47 subtag and apply casing per subtag? It only consumes the language and next subtag, so a custom tag such as
zh-Hant-TWbecomeszh-HANTand no longer matcheszh-Hant-TW.tomlas described for external BCP-47 catalogs. A round-trip test for a language-script-region tag would cover this. AI-assisted review: I used an AI assistant to inspect this diff.@gut0to on GitHub · 2026-12-01 13:54 UTC · original · reviewed
AI-assisted review: I used an AI assistant to inspect these changes; I checked each point against the implementation and tests.
392a59f511to580a11dc81@WanderLinks on GitHub · 2026-12-01 14:16 UTC · original
Thanks for the careful review, @gut0to. All three points are addressed in the updated commit (force-pushed, still a single commit):
build.rs — user locale files are no longer wiped. Removed
remove_dir_all;copy_dirnow only overwrites the bundled catalogs and leaves unrelated user-provided.tomlfiles untouched. Verified by dropping a user file next to the executable and rebuilding — it survives.locale.rs— path traversal is rejected.Locale::from_strnow rejects any code whose subtags are not ASCII-alphanumeric tokens joined by-, which rejects/,\,.,.., and empty subtags before aCustomis constructed. Addedpath_separators_and_invalid_subtags_are_rejected, covering../outside,..,a/b,a\b,zh.CN, andzh--CN.locale.rs— full BCP-47 normalization. Normalization now walks every subtag and applies casing by position (lowercase language, title-case four-letter script, uppercase two-letter / three-digit region), retaining all subtags.zh-Hant-TWnow round-trips (includingzh-hant-twinput) andes-419keeps its numeric region. Addedlanguage_script_region_round_trips_with_bcp47_casing.Verification: 23
victory-i18ntests pass, rustfmt is clean, and clippy reports no warnings on the new code.@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.
Pull request closed