Skip to content

feat(settings): add in-app language switcher (#439)#1195

Merged
rolandgeider merged 4 commits into
wger-project:masterfrom
PawelHaracz:feat/language-switcher
May 18, 2026
Merged

feat(settings): add in-app language switcher (#439)#1195
rolandgeider merged 4 commits into
wger-project:masterfrom
PawelHaracz:feat/language-switcher

Conversation

@PawelHaracz
Copy link
Copy Markdown

@PawelHaracz PawelHaracz commented May 16, 2026

Summary

Adds an in-app language picker in Settings, addressing #439. The user can override the system locale per-app; selecting System default clears the override and the existing localeListResolutionCallback resumes.

Also declares CFBundleLocalizations in ios/Runner/Info.plist, which enables the native iOS 16+ per-app language picker (Settings → wger → Language) as an alternative entry point on Apple platforms.

Changes

  • lib/providers/user.dartLocale? userLocale field persisted via SharedPreferencesAsync (key PREFS_USER_LOCALE); mirrors the existing themeMode pattern. Stored value is matched back against AppLocalizations.supportedLocales on load to preserve script-bearing locales (e.g. zh_Hant, pt_BR).
  • lib/main.dart — passes locale: user.userLocale to MaterialApp. When null, behavior is unchanged.
  • lib/widgets/core/settings/language.dart (new)DropdownButton<Locale?> listing all supported locales by their native names (Polski, 中文, …) plus a System default entry, sorted alphabetically by display name.
  • lib/widgets/core/settings.dart — wires SettingsLanguage into the existing Settings list, next to SettingsTheme.
  • lib/l10n/app_en.arb, lib/l10n/app_pl.arb — adds appLanguage + appLanguageSystem strings. Other locales fall back to English via the standard delegate; happy to follow up if you'd prefer all 36 ARB files updated up front.
  • lib/helpers/consts.dart — new PREFS_USER_LOCALE key.
  • ios/Runner/Info.plist — declares CFBundleLocalizations for all 36 supported locales (enables iOS 16+ per-app language UI).

Notes

  • intl formatters already read Localizations.localeOf(context), so dates/numbers should follow the new locale without further changes.

Screenshots:

image image

Test plan

  • CI green (flutter test)
  • Manual: switch to a non-default language → strings update without restart
  • Manual: switch back to System default → app follows OS locale again
  • Manual (iOS 16+): Settings → wger → Language shows native picker
  • Persistence: relaunch the app, last choice is restored

Closes #439.

Adds a per-user language override in Settings that takes precedence over
the system locale, fixing wger-project#439. Selecting "System default" clears the
override and falls back to the existing localeListResolutionCallback.

Also declares CFBundleLocalizations in the iOS Info.plist so iOS 16+ users
get the native per-app language picker (Settings → wger → Language) as an
alternative entry point.

Implementation mirrors the existing themeMode flow on UserProvider, with
the selected locale persisted in SharedPreferences under PREFS_USER_LOCALE
and matched against AppLocalizations.supportedLocales on load to preserve
script-bearing locales (zh_Hant, pt_BR, ...).
@PawelHaracz PawelHaracz marked this pull request as ready for review May 16, 2026 13:33
@rolandgeider rolandgeider merged commit b1f3ffb into wger-project:master May 18, 2026
4 checks passed
@rolandgeider
Copy link
Copy Markdown
Member

merged, thanks!

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.

Feature request: Add an option to change language

3 participants