feat(i18n): UI language selector (Settings → Appearance → Language) (T-462)

Make the localization usable: an app.locale select (English / Nederlands) in
the Appearance category, applied live by root_shell — it parses app.locale and
calls i18n.setLocale on boot + on settings change (setLocale is a no-op when
unchanged). nl_NL registered in availableLocales. The ui-design skill now
documents the locale-dir config and the rule to design for string-length
variation (translations run ~20% longer; never hard-size to the English label).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 17:34:08 +02:00
co-authored by Claude Opus 4.8
parent bee7f98e45
commit 43c650de10
6 changed files with 68 additions and 4 deletions
+16 -2
View File
@@ -48,8 +48,9 @@ class RootShellState extends State<RootShell> {
super.initState();
_keyFocus = FocusNode()..requestFocus();
widget.services.textZoom.addListener(_onZoom);
// Re-apply the UI font when its setting changes (T-460).
// Re-apply the UI font + language when their settings change (T-460/T-462).
widget.services.settings.addListener(_onZoom);
_applyLocale(); // apply the persisted UI language at boot
_globalSeq = SequenceMatcher(
keymap: () => widget.services.keymap.keymap ?? Keymap(const []),
context: () => widget.services.keymap.scope,
@@ -69,7 +70,20 @@ class RootShellState extends State<RootShell> {
super.dispose();
}
void _onZoom() => setState(() {});
void _onZoom() {
_applyLocale();
setState(() {});
}
/// Apply the persisted UI language (app.locale) to the i18n service. setLocale
/// is a no-op when the locale is unchanged, so this is safe on every tick.
void _applyLocale() {
final raw = widget.services.settings.get<String>(kLocaleSettingKey);
if (raw == null || raw.isEmpty) return;
final parts = raw.split(RegExp('[_-]'));
final loc = parts.length >= 2 ? Locale(parts[0], parts[1]) : Locale(parts[0]);
widget.services.i18n.setLocale(loc);
}
@override
Widget build(BuildContext context) {