mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-24 10:09:01 -06:00
default_language() — what the Auto setting resolves to — only read LIGHTCRAFT_LANGUAGE, which does not exist in a browser, so the web build always started in English. ui-egui gains an installable default (set_default_language + a pure locale_from_tags that picks the first shippable language from BCP-47 tags via Locale::parse_tag), and the web app installs it at startup from navigator.languages (falling back to navigator.language), read fallibly through js_sys::Reflect so it also works from a worker. Desktop never installs the override and is unchanged; a language stored in ui.json still wins, which is exactly Auto semantics. Tests: locale_from_tags takes the first shippable language (it-IT -> Italiano, unsupported-first skips ahead, zh-TW -> zh-hant, ja_JP.UTF-8 -> Japanese, pt-BR region variant), empty/unsupported -> En fallback.