feat(settings): add in-app language switcher (#439)#1195
Merged
rolandgeider merged 4 commits intoMay 18, 2026
Conversation
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, ...).
This is also run on commits, so we get alerted when we forget to add new locales
Member
|
merged, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
localeListResolutionCallbackresumes.Also declares
CFBundleLocalizationsinios/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.dart—Locale? userLocalefield persisted viaSharedPreferencesAsync(keyPREFS_USER_LOCALE); mirrors the existingthemeModepattern. Stored value is matched back againstAppLocalizations.supportedLocaleson load to preserve script-bearing locales (e.g.zh_Hant,pt_BR).lib/main.dart— passeslocale: user.userLocaletoMaterialApp. Whennull, 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— wiresSettingsLanguageinto the existing Settings list, next toSettingsTheme.lib/l10n/app_en.arb,lib/l10n/app_pl.arb— addsappLanguage+appLanguageSystemstrings. 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— newPREFS_USER_LOCALEkey.ios/Runner/Info.plist— declaresCFBundleLocalizationsfor all 36 supported locales (enables iOS 16+ per-app language UI).Notes
intlformatters already readLocalizations.localeOf(context), so dates/numbers should follow the new locale without further changes.Screenshots:
Test plan
flutter test)Closes #439.