feat(libSceSystemService): take the console language from the host with ANYPS5_LANGUAGE=auto #12752

Merged
MarcZX10 merged 39 commits from upstream-pr/12752 into main 2026-11-02 13:39:33 +00:00
MarcZX10 commented 2026-10-29 07:41:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:41:53Z.


What

ANYPS5_LANGUAGE=auto (any letter case) takes the console language from the host operating system's language. Unset, empty and every integer 0..30 behave exactly as before (read at each query); auto is the only new value, and any other text is still refused at the first language query with the error that names the variable, which now reads must be a console language number from 0 to 30 or auto, not "...".

How it works, in core/libs/prx/libSceSystemService/LanguageLocale.hpp (header only, table driven, pure apart from the host sources):

  • ParseTag reads BCP-47 tags (en-US, pt-BR, zh-Hant-TW, es-419), NormalizePosixLocale reads POSIX names (en_GB.UTF-8@euro, sr_RS@latin, C, POSIX), ParseLocale accepts either.
  • Row tables per language group (Latin-script European, Spanish and Portuguese, Chinese, Japanese and Korean, Slavic and Nordic, the rest) keep the regional variants the console has (en-GB/en-US, fr/fr-CA, es/es-419, pt-PT/pt-BR, zh Hant/TW/HK/MO vs Hans/CN/SG); script outranks region; a recognised language with no row for the region uses its main row. An unrecognised, empty, C or POSIX locale gives English (United States) and one stderr line naming the locale.
  • Host sources behind an injectable source: POSIX (LC_ALL, then LC_MESSAGES, then LANG, first non-empty; LANGUAGE entries first under a real locale), Windows (GetUserDefaultLocaleName), macOS (CFLocaleCopyPreferredLanguages, linked through an interface target).
  • SystemServiceConsoleLanguage resolves auto once per process (function-local static), so parameters 1 and 400, the trophy texts and, through parameter 1, the user service keyboard type and the IME keyboard type all see the same value. auto is case-insensitive; the integer form stays strict.
  • Docs: USAGE.md, ENVIRONMENT.md (env_reference --check passes) and three statements in docs/dev/debt/libSceSystemService.md (mapping is an unmeasured host-side convenience; the regional choices; sources run on Linux only). Language ids and names are the repo's own list (OpenOrbis sys_service.h at 06fcf7fd108fa080035cdd3259ed22eb07e0508c, cited in the debt doc).

Commits (39): parser, POSIX normaliser, either-form parse, lookup plus each mapping group, fallback rules, POSIX/Windows/macOS sources, CMake, resolver, auto parsing, error text, each followed by its test; consumer tests (user service, keycode, trophy tag round trip); docs one per file or statement.

Overlap with open PRs: #9345 (ANYPS5_USER_NAME) also edits docs/dev/ENVIRONMENT.md and docs/user/USAGE.md (different rows and paragraphs; the ANYPS5_LANGUAGE row and paragraph are only touched here). #9586 edits libSceSystemService CMakeLists.txt, Export.cpp, SystemService.hpp and docs/dev/debt/libSceSystemService.md: here CMakeLists.txt gets a new interface target and test blocks, SystemService.hpp the SystemServiceHostLanguage function, the auto line and the error text, and the debt doc three new entries after the language entry. Export.cpp and PendingExports.cpp are not changed. No open PR implements auto.

Tested

Linux x86_64 (Debian 12, kernel 6.1), GCC 12, throwaway archive build, BUILD-EXIT 0.

  • New: system_service_language_locale (host-only, 200+ tags: every console language id 0..30 has a tag, regional pairs, scripts, case variants, POSIX codesets and modifiers, C, POSIX, empty, garbage, languages with no console entry, POSIX precedence with injected environments, resolver with injected sources and notices) and guest_system_service_language_auto_0..12 (end to end through sceSystemServiceParamGetInt parameters 1 and 400 and SystemServiceConsoleLanguage with 13 host environments: precedence, LANGUAGE, C, nothing set, unlisted language; later host change does not change the answer; integers, empty and unset still work after auto; near misses such as auto , autoo, -auto and the integers' malformed forms refused with the new text; exactly the expected number of notices). Consumers: guest_user_service and guest_convert_keycode gain an auto case (German keyboard / IME type), np_trophy2_package checks that all 31 trophy tags map back to their console language. All passed, each under 0.3 s.
  • Existing tests, baseline (upstream/main b433c40f2f) vs branch, per test: guest_convert_keycode, guest_convert_keycode_title_{oversized-id,oversized-title,cusa,ppsa,malformed-json,missing}, guest_nptrophy2, np_trophy2_package, guest_system_service_language, guest_user_service, guest_user_service_user_name, guest_user_service_lifecycle: 13/13 passed on both.
  • Negative controls (scratch copies, restored): each parser/normaliser/table/fallback/POSIX-precedence/resolver assertion group was broken once and failed at the intended case (e.g. removed en-AU, fr-CA, es-UY, pt-AO, zh-HK rows, swapped zh main row, changed script/region weight, dropped a Norwegian code, in, reversed LC_* order, LANGUAGE under C, empty entries, notice text and count). End to end: auto forced to 1 fails all 15 tests; resolving at each call (no once) fails 14 of 15 (case 8, a Japanese host, passes by construction); prefix match of auto fails the near-miss check. Not negative-controlled: the Windows and macOS branches (not built), the debt and doc text, the macOS CMake link.
  • Static: check_conventions.py --base upstream/main, git diff --check upstream/main, test_public_headers.py --audit-only --manifest /tmp/ph_langauto.json, env_reference.py --check all clean. Rebased on upstream/main 10bec5c322 (the last move touched none of these files).

NOT RUN: Windows (the GetUserDefaultLocaleName branch and the MinGW link of the host-only test, which uses configure_host_test_executable, are unbuilt), macOS (the CoreFoundation branch and framework link are unbuilt), a real non-English host (Linux tests only set environment variables), a console, any title. The resolver is inline, so a library with its own copy (a separate DLL on Windows) resolves again and could print its own fallback line; reasoned, not run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5064229861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12752). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T07:41:53Z. --- ### What `ANYPS5_LANGUAGE=auto` (any letter case) takes the console language from the host operating system's language. Unset, empty and every integer 0..30 behave exactly as before (read at each query); `auto` is the only new value, and any other text is still refused at the first language query with the error that names the variable, which now reads `must be a console language number from 0 to 30 or auto, not "..."`. How it works, in `core/libs/prx/libSceSystemService/LanguageLocale.hpp` (header only, table driven, pure apart from the host sources): - `ParseTag` reads BCP-47 tags (`en-US`, `pt-BR`, `zh-Hant-TW`, `es-419`), `NormalizePosixLocale` reads POSIX names (`en_GB.UTF-8@euro`, `sr_RS@latin`, `C`, `POSIX`), `ParseLocale` accepts either. - Row tables per language group (Latin-script European, Spanish and Portuguese, Chinese, Japanese and Korean, Slavic and Nordic, the rest) keep the regional variants the console has (en-GB/en-US, fr/fr-CA, es/es-419, pt-PT/pt-BR, zh Hant/TW/HK/MO vs Hans/CN/SG); script outranks region; a recognised language with no row for the region uses its main row. An unrecognised, empty, `C` or `POSIX` locale gives English (United States) and one stderr line naming the locale. - Host sources behind an injectable source: POSIX (`LC_ALL`, then `LC_MESSAGES`, then `LANG`, first non-empty; `LANGUAGE` entries first under a real locale), Windows (`GetUserDefaultLocaleName`), macOS (`CFLocaleCopyPreferredLanguages`, linked through an interface target). - `SystemServiceConsoleLanguage` resolves `auto` once per process (function-local static), so parameters 1 and 400, the trophy texts and, through parameter 1, the user service keyboard type and the IME keyboard type all see the same value. `auto` is case-insensitive; the integer form stays strict. - Docs: USAGE.md, ENVIRONMENT.md (`env_reference --check` passes) and three statements in docs/dev/debt/libSceSystemService.md (mapping is an unmeasured host-side convenience; the regional choices; sources run on Linux only). Language ids and names are the repo's own list (OpenOrbis sys_service.h at 06fcf7fd108fa080035cdd3259ed22eb07e0508c, cited in the debt doc). Commits (39): parser, POSIX normaliser, either-form parse, lookup plus each mapping group, fallback rules, POSIX/Windows/macOS sources, CMake, resolver, `auto` parsing, error text, each followed by its test; consumer tests (user service, keycode, trophy tag round trip); docs one per file or statement. Overlap with open PRs: #9345 (ANYPS5_USER_NAME) also edits docs/dev/ENVIRONMENT.md and docs/user/USAGE.md (different rows and paragraphs; the ANYPS5_LANGUAGE row and paragraph are only touched here). #9586 edits libSceSystemService CMakeLists.txt, Export.cpp, SystemService.hpp and docs/dev/debt/libSceSystemService.md: here CMakeLists.txt gets a new interface target and test blocks, SystemService.hpp the `SystemServiceHostLanguage` function, the `auto` line and the error text, and the debt doc three new entries after the language entry. Export.cpp and PendingExports.cpp are not changed. No open PR implements `auto`. ### Tested Linux x86_64 (Debian 12, kernel 6.1), GCC 12, throwaway archive build, `BUILD-EXIT 0`. - New: `system_service_language_locale` (host-only, 200+ tags: every console language id 0..30 has a tag, regional pairs, scripts, case variants, POSIX codesets and modifiers, `C`, `POSIX`, empty, garbage, languages with no console entry, POSIX precedence with injected environments, resolver with injected sources and notices) and `guest_system_service_language_auto_0..12` (end to end through `sceSystemServiceParamGetInt` parameters 1 and 400 and `SystemServiceConsoleLanguage` with 13 host environments: precedence, `LANGUAGE`, `C`, nothing set, unlisted language; later host change does not change the answer; integers, empty and unset still work after `auto`; near misses such as `auto `, `autoo`, `-auto` and the integers' malformed forms refused with the new text; exactly the expected number of notices). Consumers: `guest_user_service` and `guest_convert_keycode` gain an `auto` case (German keyboard / IME type), `np_trophy2_package` checks that all 31 trophy tags map back to their console language. All passed, each under 0.3 s. - Existing tests, baseline (upstream/main b433c40f2f) vs branch, per test: guest_convert_keycode, guest_convert_keycode_title_{oversized-id,oversized-title,cusa,ppsa,malformed-json,missing}, guest_nptrophy2, np_trophy2_package, guest_system_service_language, guest_user_service, guest_user_service_user_name, guest_user_service_lifecycle: 13/13 passed on both. - Negative controls (scratch copies, restored): each parser/normaliser/table/fallback/POSIX-precedence/resolver assertion group was broken once and failed at the intended case (e.g. removed en-AU, fr-CA, es-UY, pt-AO, zh-HK rows, swapped zh main row, changed script/region weight, dropped a Norwegian code, `in`, reversed LC_* order, LANGUAGE under C, empty entries, notice text and count). End to end: `auto` forced to 1 fails all 15 tests; resolving at each call (no once) fails 14 of 15 (case 8, a Japanese host, passes by construction); prefix match of `auto` fails the near-miss check. Not negative-controlled: the Windows and macOS branches (not built), the debt and doc text, the macOS CMake link. - Static: `check_conventions.py --base upstream/main`, `git diff --check upstream/main`, `test_public_headers.py --audit-only --manifest /tmp/ph_langauto.json`, `env_reference.py --check` all clean. Rebased on upstream/main 10bec5c322 (the last move touched none of these files). NOT RUN: Windows (the `GetUserDefaultLocaleName` branch and the MinGW link of the host-only test, which uses `configure_host_test_executable`, are unbuilt), macOS (the CoreFoundation branch and framework link are unbuilt), a real non-English host (Linux tests only set environment variables), a console, any title. The resolver is inline, so a library with its own copy (a separate DLL on Windows) resolves again and could print its own fallback line; reasoned, not run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 20:02:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:02:41Z.

Review: COMMENTED


Correction (2026-11-01): this review demanded a title for a PR where no title can supply one. CONTRIBUTING allows Unblocks: none. The technical points below are unaffected.

No title ID and no log line: the description names none and Unblocks is empty. The default (ANYPS5_LANGUAGE unset or an integer) is unchanged, so nothing on main is affected until a user opts in, which makes this a convenience feature rather than a fix for a title.

  1. Approximate fallbacks, logged. The description says "an unrecognised, empty, C or POSIX locale gives English (United States) and one stderr line", and that "a recognised language with no row for the region uses its main row". Those are fallbacks that return a plausible value instead of throwing, and upstream has been rejecting those even when logged. If the host locale cannot be mapped, the exact-or-throw choice is to throw naming ANYPS5_LANGUAGE, which is what the integer path already does for bad text.
  2. Mapping is invented host-side, not measured. The debt entry itself calls the mapping "an unmeasured host-side convenience", and the regional table (zh Hant/TW/HK/MO, es-419, pt-PT/pt-BR) is a judgement about which console language a host locale corresponds to. Please say which table in the firmware or SDK it comes from, or reduce it to the languages that have a one-to-one console id.
  3. Size and platform surface. 39 commits and a header with POSIX, Windows (GetUserDefaultLocaleName) and macOS (CFLocaleCopyPreferredLanguages, a new framework link) paths. The description says only the Linux sources are tested; the Windows and macOS branches and the CoreFoundation link are unbuilt. I would not take unbuilt platform code into libSceSystemService.

What would make this reviewable: a title that reads the language and misbehaves on main with the integer variable, with a log line, or a reason a user cannot just set ANYPS5_LANGUAGE=1 once.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729966131 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12752#pullrequestreview-5729966131). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:02:41Z. **Review:** COMMENTED --- **Correction (2026-11-01):** this review demanded a title for a PR where no title can supply one. CONTRIBUTING allows `Unblocks: none`. The technical points below are unaffected. No title ID and no log line: the description names none and `Unblocks` is empty. The default (`ANYPS5_LANGUAGE` unset or an integer) is unchanged, so nothing on `main` is affected until a user opts in, which makes this a convenience feature rather than a fix for a title. 1. **Approximate fallbacks, logged.** The description says "an unrecognised, empty, `C` or `POSIX` locale gives English (United States) and one stderr line", and that "a recognised language with no row for the region uses its main row". Those are fallbacks that return a plausible value instead of throwing, and upstream has been rejecting those even when logged. If the host locale cannot be mapped, the exact-or-throw choice is to throw naming `ANYPS5_LANGUAGE`, which is what the integer path already does for bad text. 2. **Mapping is invented host-side, not measured.** The debt entry itself calls the mapping "an unmeasured host-side convenience", and the regional table (zh Hant/TW/HK/MO, es-419, pt-PT/pt-BR) is a judgement about which console language a host locale corresponds to. Please say which table in the firmware or SDK it comes from, or reduce it to the languages that have a one-to-one console id. 3. **Size and platform surface.** 39 commits and a header with POSIX, Windows (`GetUserDefaultLocaleName`) and macOS (`CFLocaleCopyPreferredLanguages`, a new framework link) paths. The description says only the Linux sources are tested; the Windows and macOS branches and the CoreFoundation link are unbuilt. I would not take unbuilt platform code into `libSceSystemService`. What would make this reviewable: a title that reads the language and misbehaves on `main` with the integer variable, with a log line, or a reason a user cannot just set `ANYPS5_LANGUAGE=1` once.
MarcZX10 commented 2026-11-02 04:58:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:58:08Z.

Review: COMMENTED


Reviewed — three review points need an answer; the fallbacks are confirmed

CnRJay asks for exact-or-throw on unmapped host locales and for a source of the regional table; the head falls back to English (United States) with one notice line, and the table cites no source.

What I ran

Live head: 84fd495ba9 (OPEN, same as the batch file). Read the comments and reviews with gh api (repos/boykopovar/AnyPS5/issues|pulls/12752/...). Read files with git -C /marc/AnyPS5 show 84fd495b…:<path>: LanguageLocale.hpp, CMakeLists.txt, docs/dev/debt/libSceSystemService.md, CONTRIBUTING.md. Read the hosted check rollup with gh pr view. Nothing was built or run.

Results

Check Result Note
windows SUCCESS hosted, at this head
conventions SUCCESS hosted, at this head
linux, relinker SKIPPED hosted workflow skipped them

Findings

  • CnRJay, point 1: unmapped locales return a plausible value. Confirmed: MatchLocale returns EnglishUs for an unrecognised tag (LanguageLocale.hpp:292), C and POSIX give no locale (L248), and ResolveHostLanguage logs one notice and returns English (United States) (L365-L373).
  • Point 2: the regional table cites no source. The debt entry (docs/dev/debt/libSceSystemService.md L31) calls it "a host-side convenience" and says nothing was measured on a console. Rows are at LanguageLocale.hpp L101-L105 and L150-L155.
  • Point 3: Windows (GetUserDefaultLocaleName, L322-L334) and macOS (CFLocaleCopyPreferredLanguages, L336-L350) branches exist, and the CMake target links CoreFoundation (CMakeLists.txt L3). The hosted Windows job passed; it does not build the macOS branch.
  • The "Unblocks" item in the same review is withdrawn in its header. CONTRIBUTING.md L66 allows none.

Sources

Not verified

  • The "main row" lookup (ConsoleLanguageForTag) was not read.
  • The table's source: none is named in the head; I did not search outside the repo.
  • Nothing was built or run here.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732253113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12752#pullrequestreview-5732253113). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:58:08Z. **Review:** COMMENTED --- # Reviewed — three review points need an answer; the fallbacks are confirmed CnRJay asks for exact-or-throw on unmapped host locales and for a source of the regional table; the head falls back to English (United States) with one notice line, and the table cites no source. ## What I ran Live head: 84fd495ba9cc260af93dbd78b0ee1650b4240c76 (OPEN, same as the batch file). Read the comments and reviews with `gh api` (repos/boykopovar/AnyPS5/issues|pulls/12752/...). Read files with `git -C /marc/AnyPS5 show 84fd495b…:<path>`: LanguageLocale.hpp, CMakeLists.txt, docs/dev/debt/libSceSystemService.md, CONTRIBUTING.md. Read the hosted check rollup with `gh pr view`. Nothing was built or run. ## Results | Check | Result | Note | |---|---|---| | windows | SUCCESS | hosted, at this head | | conventions | SUCCESS | hosted, at this head | | linux, relinker | SKIPPED | hosted workflow skipped them | ## Findings - CnRJay, point 1: unmapped locales return a plausible value. Confirmed: `MatchLocale` returns `EnglishUs` for an unrecognised tag (LanguageLocale.hpp:292), `C` and `POSIX` give no locale (L248), and `ResolveHostLanguage` logs one notice and returns English (United States) (L365-L373). - Point 2: the regional table cites no source. The debt entry (docs/dev/debt/libSceSystemService.md L31) calls it "a host-side convenience" and says nothing was measured on a console. Rows are at LanguageLocale.hpp L101-L105 and L150-L155. - Point 3: Windows (`GetUserDefaultLocaleName`, L322-L334) and macOS (`CFLocaleCopyPreferredLanguages`, L336-L350) branches exist, and the CMake target links CoreFoundation (CMakeLists.txt L3). The hosted Windows job passed; it does not build the macOS branch. - The "Unblocks" item in the same review is withdrawn in its header. CONTRIBUTING.md L66 allows `none`. ## Sources - https://github.com/boykopovar/AnyPS5/blob/84fd495ba9cc260af93dbd78b0ee1650b4240c76/core/libs/prx/libSceSystemService/LanguageLocale.hpp#L292-L292 - https://github.com/boykopovar/AnyPS5/blob/84fd495ba9cc260af93dbd78b0ee1650b4240c76/core/libs/prx/libSceSystemService/LanguageLocale.hpp#L365-L373 - https://github.com/boykopovar/AnyPS5/blob/84fd495ba9cc260af93dbd78b0ee1650b4240c76/core/libs/prx/libSceSystemService/LanguageLocale.hpp#L322-L350 - https://github.com/boykopovar/AnyPS5/blob/84fd495ba9cc260af93dbd78b0ee1650b4240c76/docs/dev/debt/libSceSystemService.md#L31-L31 - https://github.com/boykopovar/AnyPS5/blob/84fd495ba9cc260af93dbd78b0ee1650b4240c76/CONTRIBUTING.md#L66-L66 ## Not verified - The "main row" lookup (`ConsoleLanguageForTag`) was not read. - The table's source: none is named in the head; I did not search outside the repo. - Nothing was built or run here.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!12752
No description provided.