compat-common: optional locale= in tombox.cfg sets the user language a title sees #151

Closed
github-bot wants to merge 1 commit from gh-pr/151/head into gh-pr/151/base
Owner

@⁠GDAgent on GitHub · 2026-11-22 16:18 UTC · original
GDAgent:port/compat-locale-override → main · +242 −3 · 5 files · 1 commits · closed without merging

Library / area: compat-common (new locale.rs; one-time install next to gdk_user::install in net_guard::ensure)

Exports changed (exports.txt rows): none (host kernelbase entry points are patched in-process)

Source of the behaviour: a console reports the language chosen in its system settings; on a PC the title sees the Windows user's language. Windows API contracts per the Win32 docs (buffer sizing, ERROR_INSUFFICIENT_BUFFER, MUI_LANGUAGE_ID / MUI_LANGUAGE_NAME). Ported from brcly/TomBox 31d8b03 (GDAgent) plus brcly's 64e7c2a (size queries), MIT OR Apache-2.0.

With locale=<name> in tombox.cfg these queries answer with that locale:

  • GetUserDefaultLocaleName
  • GetUserDefaultLCID
  • GetUserDefaultLangID
  • GetUserDefaultUILanguage
  • GetUserPreferredUILanguages

The emulated XPackageGetUserLocale (gdk::package::user_locale) reads GetUserDefaultLocaleName, so it follows too.

Without the line nothing changes. Behaviour details:

  • Validation. Windows validates and canonicalises the name: LocaleNameToLCID, then LCIDToLocaleName (en-us becomes en-US). An unknown name, or one without its own LCID, is logged and ignored.
  • Left alone on purpose: the geographic region, the system locale, and explicit per-thread UI languages.
  • Visibility change: net_guard::resolve_export / write_jump become pub(crate) so locale.rs can reuse them.

Tests:

  • cargo test -p compat-common --lib locale: 5 passed. They cover canonicalisation, buffer contract, MUI id form, the hooks reporting the configured locale, and that host exports can take the patch.

  • --test locale_override: 1 passed. It is process-wide, so it has its own test binary.

  • Whole compat-common --lib: 136 passed, 12 failed. The same 12 (online::trackmania::* and online::xdefiant::tests::parameters_match_real_service_layout) fail on plain main too: they need the unpublished backend_data/, which builds with empty stand-ins.

  • Native Windows 11; not run under Proton.

  • Not verified in a title with this repo's build; the checks above are unit tests against the real Windows locale APIs.

  • cargo test -p compat-common passes (locale tests pass; the 12 failures also occur on main)

  • No game or console files and no binaries included

  • No fake success; anything not possible is left missing with a note

**@⁠GDAgent** on GitHub · 2026-11-22 16:18 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/151) `GDAgent:port/compat-locale-override` → `main` · +242 −3 · 5 files · 1 commits · closed without merging **Library / area:** compat-common (new `locale.rs`; one-time install next to `gdk_user::install` in `net_guard::ensure`) **Exports changed (exports.txt rows):** none (host kernelbase entry points are patched in-process) **Source of the behaviour:** a console reports the language chosen in its system settings; on a PC the title sees the Windows user's language. Windows API contracts per the Win32 docs (buffer sizing, `ERROR_INSUFFICIENT_BUFFER`, `MUI_LANGUAGE_ID` / `MUI_LANGUAGE_NAME`). Ported from brcly/TomBox 31d8b03 (GDAgent) plus brcly's 64e7c2a (size queries), MIT OR Apache-2.0. With `locale=<name>` in `tombox.cfg` these queries answer with that locale: - `GetUserDefaultLocaleName` - `GetUserDefaultLCID` - `GetUserDefaultLangID` - `GetUserDefaultUILanguage` - `GetUserPreferredUILanguages` The emulated `XPackageGetUserLocale` (`gdk::package::user_locale`) reads `GetUserDefaultLocaleName`, so it follows too. Without the line nothing changes. Behaviour details: - **Validation.** Windows validates and canonicalises the name: `LocaleNameToLCID`, then `LCIDToLocaleName` (`en-us` becomes `en-US`). An unknown name, or one without its own LCID, is logged and ignored. - **Left alone on purpose:** the geographic region, the system locale, and explicit per-thread UI languages. - **Visibility change:** `net_guard::resolve_export` / `write_jump` become `pub(crate)` so `locale.rs` can reuse them. Tests: - `cargo test -p compat-common --lib locale`: 5 passed. They cover canonicalisation, buffer contract, MUI id form, the hooks reporting the configured locale, and that host exports can take the patch. - `--test locale_override`: 1 passed. It is process-wide, so it has its own test binary. - Whole `compat-common --lib`: 136 passed, 12 failed. The same 12 (`online::trackmania::*` and `online::xdefiant::tests::parameters_match_real_service_layout`) fail on plain `main` too: they need the unpublished `backend_data/`, which builds with empty stand-ins. - Native Windows 11; not run under Proton. - Not verified in a title with this repo's build; the checks above are unit tests against the real Windows locale APIs. - [x] `cargo test -p compat-common` passes (locale tests pass; the 12 failures also occur on `main`) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
A console reports the language chosen in its system settings; on a PC the
title sees the Windows user's language. With `locale=<name>` in tombox.cfg
the process-wide user-language queries answer with that locale:
GetUserDefaultLocaleName, GetUserDefaultLCID, GetUserDefaultLangID,
GetUserDefaultUILanguage and GetUserPreferredUILanguages (kernelbase entry
points, patched once when the network guard installs). The emulated
XPackageGetUserLocale reads GetUserDefaultLocaleName, so it follows too.

Without the line nothing changes. The name is validated and canonicalised
by Windows (LocaleNameToLCID, then LCIDToLocaleName: en-us -> en-US); an
unknown name, or one without its own LCID, is logged and ignored. The
geographic region, the system locale and explicit per-thread UI languages
are left alone. Size queries (NULL buffer, too small a buffer) follow the
Windows contract: required length, ERROR_INSUFFICIENT_BUFFER.

Ported from brcly/TomBox 31d8b03 (GDAgent) with brcly's 64e7c2a
(size queries), MIT OR Apache-2.0.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:11:53 +00:00
github-bot closed this pull request 2026-11-26 06:11:53 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 16:28 UTC · original

Applied in a689c70 (merged in 604b5a1) with your authorship kept, thanks! I removed one trailing // comment in locale.rs, because the repo allows no comment lines at all.

**@⁠omonkeyz** on GitHub · 2026-11-22 16:28 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/151#issuecomment-7082095233) Applied in a689c70 (merged in 604b5a1) with your authorship kept, thanks! I removed one trailing `//` comment in locale.rs, because the repo allows no comment lines at all.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.