-
Notifications
You must be signed in to change notification settings - Fork 16
Create a button to change the language #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA user-selectable language feature has been added. The app now stores the user's language preference in settings, persists it, and uses it to determine the app's locale. The settings screen introduces a language selection UI with localization support for English, Spanish, and Italian. A new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsScreen
participant LanguageSelector
participant SettingsNotifier
participant App
User->>SettingsScreen: Opens settings
SettingsScreen->>LanguageSelector: Displays current language
User->>LanguageSelector: Selects a language
LanguageSelector->>SettingsNotifier: updateSelectedLanguage(newValue)
SettingsNotifier->>SettingsNotifier: Update state and save to prefs
SettingsNotifier->>App: Notifies settings change
App->>App: Updates locale based on user-selected language or system locale
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
lib/core/app.dart(2 hunks)lib/features/settings/settings.dart(3 hunks)lib/features/settings/settings_notifier.dart(1 hunks)lib/features/settings/settings_screen.dart(2 hunks)lib/l10n/intl_en.arb(1 hunks)lib/l10n/intl_es.arb(1 hunks)lib/l10n/intl_it.arb(1 hunks)lib/shared/widgets/language_selector.dart(1 hunks)test/mocks.mocks.dart(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
lib/features/settings/settings_screen.dart (2)
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, `eventStorageProvider` is exported from `package:mostro_mobile/shared/providers/mostro_service_provider.dart` and not from a separate `event_storage_provider.dart` file.
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.
lib/core/app.dart (2)
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, `eventStorageProvider` is exported from `package:mostro_mobile/shared/providers/mostro_service_provider.dart` and not from a separate `event_storage_provider.dart` file.
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.
lib/shared/widgets/language_selector.dart (1)
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (15)
lib/l10n/intl_es.arb (1)
402-407: LGTM! Spanish translations are accurate and well-crafted.The language selection keys are properly translated and will integrate seamlessly with the new language selector feature. The translations are clear, natural, and consistent with the existing Spanish localization style.
lib/features/settings/settings_screen.dart (2)
10-10: Import addition looks good.The LanguageSelector widget import is properly added to support the new language settings section.
48-72: Excellent UI integration following established patterns.The language settings section is well-implemented with:
- Consistent CustomCard structure matching other settings sections
- Appropriate language icon and localized strings
- Proper spacing and styling
- Logical placement above currency settings
The integration maintains the existing design consistency while providing a clear and intuitive language selection interface.
test/mocks.mocks.dart (1)
404-404: Appropriate lint suppression for mock class.The
must_be_immutableignore directive is correctly applied to theMockSharedPreferencesAsyncclass. This is standard practice for Mockito-generated mock classes that need mutability for testing purposes.lib/core/app.dart (2)
13-13: Import addition supports the dynamic locale feature.The settingsProvider import is correctly added to enable watching the user's language preference.
52-52: Excellent dynamic locale resolution implementation.The locale logic is well-designed:
- Watches settings provider to get user's language preference
- Prioritizes
selectedLanguagewhen set by creating aLocaleinstance- Falls back to
nullwhen no preference is set, allowing the existinglocaleResolutionCallbackto handle system locale detection- Maintains backward compatibility while enabling user control
This approach cleanly integrates user language selection with the existing locale resolution system.
Also applies to: 59-62
lib/features/settings/settings_notifier.dart (1)
55-58: Well-implemented method following established patterns.The
updateSelectedLanguagemethod correctly:
- Accepts a nullable
Stringparameter to support both language selection and system default- Updates state using
copyWithpattern consistent with other methods- Persists changes via
_saveToPrefs()- Follows the same async signature pattern as other update methods
This implementation integrates seamlessly with the existing
SettingsNotifierarchitecture.lib/l10n/intl_it.arb (1)
402-407: LGTM! Well-structured localization additions.The Italian translations for the language selection feature are properly formatted and linguistically appropriate. The keys are consistent with the feature requirements.
lib/l10n/intl_en.arb (1)
402-407: LGTM! Consistent localization keys added.The English translations for the language selection feature are well-structured and follow proper conventions. The keys match those added in other language files, ensuring consistency across locales.
lib/shared/widgets/language_selector.dart (2)
18-21: LGTM! Proper Riverpod state management.The widget correctly uses
ref.watchto read the current settings and accesses the selected language appropriately.
74-76: LGTM! Correct state update implementation.The
onChangedcallback properly usesref.readwith the notifier to update the selected language setting.lib/features/settings/settings.dart (4)
6-6: LGTM! Well-documented nullable field.The
selectedLanguagefield is properly typed as nullable with a clear comment explaining that null represents using the system locale.
8-14: LGTM! Consistent constructor implementation.The
selectedLanguageparameter is correctly added as an optional parameter, following the same pattern as other optional fields in the class.
16-30: LGTM! Proper copyWith implementation.The
copyWithmethod correctly includes theselectedLanguageparameter and handles the nullable value appropriately with the null-aware operator.
32-48: LGTM! Complete JSON serialization support.Both
toJson()andfromJson()methods properly handle theselectedLanguagefield, ensuring persistence works correctly for the new language selection feature.
grunch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just installed the app on this branch and it starts on english while my mobile is on spanish, it is important to let you know that right now, in main, the app starts on the system default language (spanish in my case), we need to keep this behavior
Catrya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Mi idioma predeterminado del teléfono es español pero me sale como predeterminado al inicio en inglés
- Debe seguir la UI de las demás secciones de esa pantalla, porque sale con un borde blanco y no debe estar, además debe tener el mismo tono de las demás secciones de la moneda y los relays
- Cuando se cambia a cualquier idioma, luego no permite volver a seleccionar el Predeterminado del sistema, pero debería poder seleccionarse también
Catrya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…to properly save selected language
Catrya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK @chebizarro @grunch



Implements #67
Summary by CodeRabbit
New Features
Localization
Bug Fixes