Commit Graph
15 Commits
Author SHA1 Message Date
MarcZX10 59d0159e3b feat(libSceSystemService): resolve the host language from an injectable locale source
ResolveHostLanguage takes the host locales in order of preference from a source
and the console language of the first one that is recognised. When none is
(or the source returns none), it reports one notice line that names the
detected locale and the English (United States) fallback and returns it, so
auto never fails. Source and notice are injectable so tests do not depend on
the host.
2026-10-29 08:51:17 +00:00
MarcZX10 0c4be5ba0e feat(libSceSystemService): choose the host locale source of the platform
HostLocales calls the Windows source on Windows, the macOS source on macOS and
the POSIX environment source elsewhere.
2026-10-29 08:51:17 +00:00
MarcZX10 ab43fe1e8c feat(libSceSystemService): read the host locales of a macOS system
MacHostLocales returns the user's preferred languages in order from
CFLocaleCopyPreferredLanguages, BCP-47 tags such as en-US, zh-Hans-CN or
pt-BR, which the process environment of a macOS desktop session does not
carry. Only built on macOS.
2026-10-29 08:51:17 +00:00
MarcZX10 403ca71698 feat(libSceSystemService): read the host locale of a Windows system
WindowsHostLocales returns the user default locale name from
GetUserDefaultLocaleName, a BCP-47 tag such as en-US, zh-Hans-CN or pt-BR. It
reads the regional-format locale of the user, not the list of preferred
display languages, because that is one documented call with a fixed buffer.
A name with a non-ASCII character is treated as no locale. Only built on
Windows.
2026-10-29 08:51:17 +00:00
MarcZX10 c3fa50327c feat(libSceSystemService): read the host locales of a POSIX system
PosixHostLocales takes an injectable environment reader and returns the locales
in order of preference: LC_ALL, then LC_MESSAGES, then LANG, the first one that
is set and not empty, as the C library chooses the locale of the messages
category. When that locale is a real one (not C, POSIX or unset) the entries of
LANGUAGE, the GNU preference list, come before it, as gettext ignores LANGUAGE
under the C locale.
2026-10-29 08:51:17 +00:00
MarcZX10 26f2879f05 feat(libSceSystemService): fall back to English (United States) for a locale with no console language
MatchLocale returns the console language of a locale and whether the locale was
recognised. An empty, C, POSIX, malformed or unlisted locale is not
recognised and gives English (United States), the language the console answers
when ANYPS5_LANGUAGE is unset, so resolving a host locale cannot fail. A
recognised language with no row for its region already takes the language's
main row.
2026-10-29 08:51:17 +00:00
MarcZX10 7538dd65df feat(libSceSystemService): map Arabic, Thai, Vietnamese, Indonesian, Turkish, Greek and Hungarian locales
Each has a single console language, so every region maps to it. The legacy
code in for Indonesian, still used by some POSIX and Java hosts, is accepted
as well as id.
2026-10-29 08:51:17 +00:00
MarcZX10 e439a2afe1 feat(libSceSystemService): map Slavic and Nordic locales
Russian, Ukrainian, Polish, Czech, Finnish, Swedish and Danish map to their
console language. Norwegian is the console's one Norwegian language, so no,
nb (Bokmal) and nn (Nynorsk) all map to it. Lithuanian, Latvian, Estonian and
the other Slavic languages the console has no entry for stay unrecognised.
2026-10-29 08:51:17 +00:00
MarcZX10 6db6ef40d4 feat(libSceSystemService): map Japanese and Korean locales
Japanese and Korean each have one console language, so every region of ja and
ko maps to it.
2026-10-29 08:51:17 +00:00
MarcZX10 b9f716124d feat(libSceSystemService): map Chinese locales to Traditional or Simplified
A script decides first (zh-Hant is Traditional, zh-Hans Simplified, also
against a contradicting region such as zh-Hans-TW), then the region (TW, HK and
MO are Traditional), and a bare zh is Simplified. Mandarin (cmn) follows the
same rules and Cantonese (yue) is Traditional unless it names Hans.
2026-10-29 08:51:16 +00:00
MarcZX10 348ac5df09 feat(libSceSystemService): map Spanish and Portuguese locales to their regional console languages
The console has Spanish (Spain) and Spanish (Latin America), and Portuguese
(Portugal) and Portuguese (Brazil). A bare es is Spain, and the Latin American
countries, the es-419 region and es-US are Latin America. A bare pt is Brazil,
the language's larger variant, and Portugal and the African and Asian
territories that follow the European standard (AO, MZ, CV, GW, ST, TL, MO) are
Portugal.
2026-10-29 08:51:16 +00:00
MarcZX10 48e165218d feat(libSceSystemService): look up the console language of a locale in a row table
ConsoleLanguageForTag picks, among the rows of the tag's language whose script
and region are empty or equal to the tag's, the one that names the most
(script outranks region), so a regional row wins over the language's main row
and a language with no row for the tag's region falls back to its main row.
The first group of rows covers the Latin-script European languages that have
no regional split but a few: English (United Kingdom for GB, IE, AU and NZ,
English (United States) otherwise), French and French (Canada), German,
Italian, Dutch and Romanian.
2026-10-29 08:51:16 +00:00
MarcZX10 f2fbb65aaa feat(libSceSystemService): parse a locale given as a BCP-47 tag or a POSIX name
ParseLocale normalises the text as a POSIX name first, which leaves a BCP-47
tag unchanged except for underscores, and then parses the result, so the
caller handles en-US and en_US.UTF-8 alike. C, POSIX and an empty text report
no locale and leave the output tag as it was.
2026-10-29 08:51:16 +00:00
MarcZX10 4d814c6a8c feat(libSceSystemService): normalise POSIX locale names to BCP-47 form
POSIX hosts name their locale language[_territory][.codeset][@modifier], such
as en_GB.UTF-8@euro, and use C and POSIX for no locale at all. NormalizePosixLocale
drops the codeset and the modifier, turns underscores into hyphens, maps the
@latin and @cyrillic modifiers to the Latn and Cyrl scripts where the name has
no script, and returns an empty string for C, POSIX and an empty name so the
caller sees "no locale" instead of a language called C.
2026-10-29 08:51:16 +00:00
MarcZX10 30b912fea4 feat(libSceSystemService): parse BCP-47 locale tags
ANYPS5_LANGUAGE can only name a console language number. Taking the language
from the host needs the host's locale, which arrives as a BCP-47 tag such as
en-US, pt-BR or zh-Hant-TW. ParseTag reads the language, script and region
subtags, normalises their case, ignores variants and extensions, and rejects
empty subtags, subtags over 8 characters and languages that are not 2 or 3
letters.
2026-10-29 08:51:16 +00:00