Skip to content

Offer to apply archinstall language to target system locale and timezone#4495

Open
Softer wants to merge 2 commits intoarchlinux:masterfrom
Softer:lang-for-target-locale
Open

Offer to apply archinstall language to target system locale and timezone#4495
Softer wants to merge 2 commits intoarchlinux:masterfrom
Softer:lang-for-target-locale

Conversation

@Softer
Copy link
Copy Markdown
Contributor

@Softer Softer commented Apr 28, 2026

Summary

After picking an archinstall language that maps to a known system locale, prompt the user to apply that locale (and matching console font / timezone, where unambiguous) to the target system. Confirms with a single Yes/No dialog listing every field that will change.

Single confirmation dialog. Lists only the fields that would actually change; if all three already match the target, the prompt is skipped silently.

Builds on #4469 (console font in Locales menu): that PR added the console_font mapping and a manual selector; this PR wires the same data into the language picker so a user who picks Ukrainian once gets the locale, font, and timezone offered together rather than having to find each menu separately.

What changes

  • Locale prompt. When the chosen language has a sys_lang mapping (e.g. uk -> uk_UA.UTF-8), offer to set sys_lang / sys_enc on LocaleConfiguration.
  • Timezone suggestion. New default_timezone field on Language, populated for ~30 unambiguous single-zone country mappings (uk_UA -> Europe/Kyiv, de_DE -> Europe/Berlin, ja_JP -> Asia/Tokyo, ...). Multi-zone countries (en_US, es_ES, pt_BR, ...) are intentionally left without a default and fall through unchanged.
  • Reset on re-pick. Each language-derived field (sys_lang, console_font, timezone) is offered whenever its target value differs from the current setting, so picking English after Ukrainian resets console_font to default8x16 and timezone to UTC instead of leaving stale Ukrainian values behind.
  • Validation. Candidate timezones are validated against list_timezones() - the same source the timezone menu reads - so we never offer a value the user could not have selected manually.
  • Yes/No label refresh. MenuItem.yes() / .no() cache their translated text on the class. With the new prompt firing right after a language switch, the cached labels stayed in the previous language. Added MenuItem.invalidate_yes_no() and a call from TranslationHandler.activate() to drop the singletons on language change.

Test plan

  • Pick Ukrainian -> prompt offers uk_UA.UTF-8, Lat2-Terminus16, Europe/Kyiv. Accept -> all three applied.
  • Pick Ukrainian, accept; then re-open language menu and pick English -> prompt offers reset to en_US.UTF-8, default8x16, UTC.
  • Pick a multi-zone language (Spanish) -> prompt offers locale only, timezone row is absent.
  • Pick a language with no sys_lang mapping -> prompt does not appear.
  • Decline the prompt -> no fields change.
  • Yes/No buttons re-translate after language switch (verified the cache invalidation visually).

Softer added 2 commits April 28, 2026 17:54
After picking an installer language with a known locale mapping, prompt
the user to apply sys_lang, sys_enc, console_font, and (where the country
maps to a single IANA zone) timezone to the target system. Each row is
shown only when its target value differs from the current setting, so
re-picking a language with fewer mappings resets stale fields too.

default_timezone is set in languages.json only for unambiguous single
mainland zones; multi-zone countries (en_US, ru_RU, es_ES, pt_BR, ...)
and codes that span countries are left without a default. Timezone
candidates are validated against list_timezones().
MenuItem.yes() and .no() cached their first-call result on the class,
so labels stayed stuck in the language active at first call. With the
new locale-apply Confirmation firing right after a language switch this
became user-visible. Drop the cache and construct fresh items per call -
allocation cost is negligible and equality continues to work via the
dataclass __eq__.
@Softer Softer requested a review from Torxed as a code owner April 28, 2026 15:01
@Softer
Copy link
Copy Markdown
Contributor Author

Softer commented Apr 28, 2026

Up front: I understand this is a big PR, and Python isn't my strongest language yet. Any feedback is very welcome :)

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