Skip to content

Conversation

@chebizarro
Copy link
Contributor

@chebizarro chebizarro commented Jul 8, 2025

Implements #67

  • Added a language selector to the app settings, allowing users to override the app language or use the device default.
  • Integrated all relevant localization strings and resolved ARB file issues.
  • The app now updates its language immediately based on user selection or falls back to the system locale.

Summary by CodeRabbit

  • New Features

    • Added a language selection option in the settings, allowing users to choose their preferred app language or use the system default.
    • Introduced a language selector widget with support for English, Spanish, and Italian.
    • Updated the settings screen with a new language section.
    • Improved locale handling to dynamically prioritize user-selected language or system locale with a refined fallback mechanism.
  • Localization

    • Added new localization strings for language selection in English, Spanish, and Italian.
  • Bug Fixes

    • The app now correctly uses the user-selected language preference instead of always defaulting to Spanish when the system locale is Spanish.

@chebizarro chebizarro requested review from Catrya and grunch July 8, 2025 01:51
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Walkthrough

A 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 LanguageSelector widget manages the language dropdown. The system locale is now observed reactively via a LocaleNotifier.

Changes

File(s) Change Summary
lib/core/app.dart Updated locale logic to use reactive system locale provider and user-selected language from settings; replaced hardcoded Spanish locale logic with dynamic locale resolution callback.
lib/features/settings/settings.dart Added nullable selectedLanguage field; updated constructor, copyWith, JSON serialization, and deserialization to include it.
lib/features/settings/settings_notifier.dart Initialized selectedLanguage to null in default settings; added updateSelectedLanguage async method to update and persist language selection.
lib/features/settings/settings_screen.dart Added language selection section with LanguageSelector widget above currency settings; imported LanguageSelector.
lib/l10n/intl_en.arb
lib/l10n/intl_es.arb
lib/l10n/intl_it.arb
Added new localization keys for language selection UI strings in English, Spanish, and Italian.
lib/shared/widgets/language_selector.dart Added new LanguageSelector ConsumerWidget with dropdown for selecting app language integrated with Riverpod.
lib/shared/notifiers/locale_notifier.dart Added LocaleNotifier class to track system locale reactively; added systemLocaleProvider StateNotifierProvider.

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
Loading

Poem

🐇
A hop and a skip, the app learns to say,
"Hola!" or "Ciao!" in a user-chosen way.
With a dropdown of tongues,
And persistence that clings,
Now every bunny can greet you each day!
🌍✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3470b6b and f66da7d.

📒 Files selected for processing (2)
  • lib/features/settings/settings.dart (3 hunks)
  • lib/shared/widgets/language_selector.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/features/settings/settings.dart
  • lib/shared/widgets/language_selector.dart
⏰ 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

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1cde1d9 and a2281f7.

📒 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_immutable ignore directive is correctly applied to the MockSharedPreferencesAsync class. 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 selectedLanguage when set by creating a Locale instance
  • Falls back to null when no preference is set, allowing the existing localeResolutionCallback to 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 updateSelectedLanguage method correctly:

  • Accepts a nullable String parameter to support both language selection and system default
  • Updates state using copyWith pattern 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 SettingsNotifier architecture.

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.watch to read the current settings and accesses the selected language appropriately.


74-76: LGTM! Correct state update implementation.

The onChanged callback properly uses ref.read with the notifier to update the selected language setting.

lib/features/settings/settings.dart (4)

6-6: LGTM! Well-documented nullable field.

The selectedLanguage field is properly typed as nullable with a clear comment explaining that null represents using the system locale.


8-14: LGTM! Consistent constructor implementation.

The selectedLanguage parameter 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 copyWith method correctly includes the selectedLanguage parameter and handles the nullable value appropriately with the null-aware operator.


32-48: LGTM! Complete JSON serialization support.

Both toJson() and fromJson() methods properly handle the selectedLanguage field, ensuring persistence works correctly for the new language selection feature.

Copy link
Member

@grunch grunch left a 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

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chebizarro

  • 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

image
image

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it does appear in the default language. But the language is selected directly and it doesn't allow selecting the default language afterward.
image

Copy link
Member

@Catrya Catrya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grunch grunch closed this Jul 8, 2025
@grunch grunch reopened this Jul 8, 2025
@grunch grunch merged commit 3b11496 into main Jul 8, 2025
3 checks passed
@chebizarro chebizarro deleted the chebizarro/issue67 branch July 8, 2025 22:40
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.

4 participants