Skip to content

Conversation

@mindmonk
Copy link
Contributor

Currently, when selecting a language in the user profile, no selection is shown until the user explicitly picks one. In this initial state, the application defaults to the browser's language for localization. Once a language is selected, there is no way to revert to the previous behavior.

With this PR, a new option titled "Browser Language" is added to the language selection list. This ensures that:

  • A selection is visible in the dropdown upon first login.
  • Users can revert to the browser's language preference after manually selecting another language.

Changes

  • Added "Browser Language" as an option in the language selection dropdown.
  • Ensured this option is pre-selected if no explicit choice has been made.
  • Allowed users to revert back to the browser's language after making a manual selection.

@mindmonk mindmonk requested a review from SailReal February 26, 2025 12:26
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

The pull request introduces changes to the language selection functionality in the UserProfile.vue component. The v-model of the Listbox component has been updated to use a local locale variable instead of $i18n.locale. A new variable, browserLocale, captures the user's browser language using navigator.language. A new ListboxOption allows users to select their browser's language, which triggers the modified saveLanguage method with an undefined argument. This method now updates the locale based on the selected locale or defaults to browserLocale if no selection is made. Additionally, the saveLanguage function's signature has been changed to accept a selectedLocale parameter. The localization file (en-US.json) has been updated with a new entry for the label "Browser Language," enhancing the language selection options available to users.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 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 f95b79d and aa6000a.

📒 Files selected for processing (1)
  • frontend/src/components/UserProfile.vue (4 hunks)
🔇 Additional comments (8)
frontend/src/components/UserProfile.vue (8)

25-25: Correct update to Listbox v-model binding.

Changing the binding from $i18n.locale to locale is appropriate given the new feature. This allows proper handling of the browser language option through the extracted locale ref from useI18n().


36-41: Browser language option implementation looks good.

The new ListboxOption for browser language is well-implemented. It correctly:

  • Uses browserLocale as the value
  • Passes undefined to saveLanguage to trigger browser language selection
  • Uses appropriate styling classes
  • Displays the translated "Browser Language" text

The UI/UX improvement allows users to explicitly choose their browser's language setting, which addresses the PR objective.


42-44: Appropriate refactoring of existing language options.

The existing language options have been properly updated to maintain consistent behavior with the new browser language option. The click handler now passes the locale explicitly to the saveLanguage function, which matches the updated function signature.


84-84: Correct extraction of locale from useI18n.

Extracting locale along with t from useI18n() is the right approach to make the locale value accessible for manipulation within the component.


90-90: Browser locale detection looks good.

Using navigator.language to detect the browser's language preference is appropriate. This provides the default language when users want to revert to their browser settings.


109-111: Improved saveLanguage function signature and implementation.

The updated function now properly:

  1. Accepts an optional locale parameter
  2. Falls back to browser language when undefined is passed
  3. Updates the i18n locale immediately

This implementation correctly fulfills the requirement of allowing users to revert to browser language.


113-113: Correctly handles user language persistence.

The update to use selectedLocale?.toString() properly handles the case where no specific language is selected (undefined is passed). This ensures that when a user selects "Browser Language", that preference is correctly saved to their profile.


25-116: Verify browser language compatibility.

While the implementation looks good, it's important to ensure that navigator.language returns a format compatible with your application's localization system. Sometimes browsers return language codes with region specifics (e.g., 'en-US' instead of 'en').

Could you verify that:

  1. The application correctly handles the format returned by navigator.language?
  2. If the browser language isn't supported by your application, does it fall back gracefully to a default language?

You might want to test with browsers set to languages that aren't supported by your application to ensure proper fallback behavior.


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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
Member

@SailReal SailReal left a comment

Choose a reason for hiding this comment

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

In this initial state, the application defaults to the browser's language for localization.

This is not true, if the user doesn't have a language selected, English is currently used as default so not set corresponds to English.

Edit: No idea what went wrong with the test, on Friday it didn't work on my device, today it uses the language of the browser, which is pretty weird.

@SailReal SailReal merged commit 613ba0e into develop Mar 17, 2025
2 checks passed
@SailReal SailReal deleted the feature/browser-default-language branch March 17, 2025 15:42
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.

3 participants