Skip to content

0.4.9: where the user is (locale::region, locale::time_zone) - #30

Merged
Sunrisepeak merged 2 commits into
mainfrom
locale-0.4.9
Dec 5, 2026
Merged

Sunrisepeak merged 2 commits into
mainfrom
locale-0.4.9

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

A new module, mcpplibs.os.locale, exported by mcpplibs.os.

  • locale::region(): the region of the user's locale, ISO 3166-1 alpha-2 in capitals. The first of LC_ALL, LC_MESSAGES and LANG that names one; on Windows the user's geographic location (GetUserDefaultGeoName) before them.
  • locale::time_zone(): the system's time zone as the system names it. An IANA name from TZ, else from the zoneinfo file /etc/localtime links to, else /etc/timezone; on Windows the key of the dynamic time zone (China Standard Time).
  • locale::region_of, locale::zone_of: a locale's name (POSIX and BCP 47 spellings) and a TZ value or zoneinfo path.

Both are read without the network and without starting a program. Every target but Windows shares one implementation (src/locale/system.cpp, selected by cfg(not(windows))); Windows reaches kernel32 at run time, as machine does. An image and a wasm module read what they can of the same.

The consumer is mcpp's download mirror: its initial value is chosen by the time zone and the region, then checked against reachability (mcpp-community/mcpp design 2026-11-27 section 3.13).

Verification: tests/locale_test.cpp (the parsing of both readers, and this machine's answers against its environment and /etc/localtime); the full suite on Linux; a build for x86_64-windows-gnu.

The region of the user's locale, ISO 3166-1 alpha-2: the first of LC_ALL, LC_MESSAGES and LANG
that names one, and on Windows the user's geographic location (GetUserDefaultGeoName) before
them. The system's time zone as the system names it: an IANA name from TZ, else from the zoneinfo
file /etc/localtime links to, else /etc/timezone; on Windows the key of the dynamic time zone.
Both are read without the network or a started program; an image and a wasm module read what
they can of the same. region_of and zone_of read a locale's name and a TZ value or zoneinfo path.
mcpp chooses its download mirror's initial value by them (mcpp-community/mcpp design 2026-11-27
section 3.13).
@Sunrisepeak
Sunrisepeak merged commit 778aed9 into main Dec 5, 2026
23 checks passed
@Sunrisepeak
Sunrisepeak deleted the locale-0.4.9 branch December 5, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant