Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Mar 12, 2025

Context

This is another take on #1538 to lay the foundation for internationalization. Thanks @feifei325 for getting the ball rolling!

Basically this PR:

  1. Removes the notion of a "preferred language" in the UI and just falls back on the chosen VSCode display language so we have a clear source of truth for internationalizing the extension. People can always add to their custom instructions if they prefer Roo speak/think in a different language.
  2. Stores the VSCode display language in the extension state so it's accessible to the webview.
  3. As an example, this internationalizes the "What can Roo do for you?" text. (Not translated yet since I worry that might be more confusing than helpful if only that phrase was translated.)
  4. Adds Translate and Test custom modes since they were helpful for me.

Once this stabilizes we should come up with a plan for internationalizing and then translating the rest of the extension, including the extension backend.


Important

Integrates i18next for internationalization, removes 'preferred language' setting, and updates UI components for translation support in webview-ui.

  • Internationalization:
    • Integrates i18next for language support in webview-ui.
    • Removes 'preferred language' setting; uses VSCode's display language.
    • Adds TranslationProvider in App.tsx for context-based translations.
  • Testing:
    • Adds mock translation setup in __mocks__/i18n for testing.
    • Updates jest.config.cjs to include i18n mocks.
  • UI Components:
    • Updates ChatView.tsx to use t function for translations.
    • Modifies PromptsView.tsx to reflect language changes.
  • Miscellaneous:
    • Adds .gitkeep files for locale directories.
    • Updates package.json with i18n dependencies.

This description was created by Ellipsis for 37e0648695091bc44c52588409de7767f2665430. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2025

⚠️ No Changeset found

Latest commit: 28e7451

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Mar 12, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented Mar 12, 2025

This pull request is quite large, with 54 files changed and over 2000 lines added. To improve reviewability and focus, it might be beneficial to split this into smaller pull requests. Here are some suggestions on how to split the changes:

  1. Internationalization Support: All changes related to adding i18n support, including new JSON files for different languages and updates to the TranslationContext, could be grouped into one pull request.

  2. Language Handling Refactor: Changes that involve refactoring language handling, such as replacing 'preferredLanguage' with 'language' and using the formatLanguage function, could be another pull request.

  3. Testing Updates: Updates to test configurations and snapshots, especially those related to the new language handling, could be a separate pull request.

This separation will help reviewers focus on specific areas and ensure a more thorough review process. Thank you!

@feifei325
Copy link
Contributor

Hi, @mrubens, in the Chinese locale, renaming the language translation folder from zh-cn to zh-CN still works correctly. This is likely because the i18n mechanism follows the UTS language identifier specification.

@mrubens
Copy link
Collaborator Author

mrubens commented Mar 12, 2025

Hi, @mrubens, in the Chinese locale, renaming the language translation folder from zh-cn to zh-CN still works correctly. This is likely because the i18n mechanism follows the UTS language identifier specification.

Yes, I was surprised/frustrated that zh-cn (the format used by vscode) did not work in i18next! Took way too long to figure out why.

How does this PR look to you? Basically trying to set us up to have the webview translations in sync with the extension translations.

@feifei325
Copy link
Contributor

Hi, @mrubens, in the Chinese locale, renaming the language translation folder from zh-cn to zh-CN still works correctly. This is likely because the i18n mechanism follows the UTS language identifier specification.

Yes, I was surprised/frustrated that zh-cn (the format used by vscode) did not work in i18next! Took way too long to figure out why.

How does this PR look to you? Basically trying to set us up to have the webview translations in sync with the extension translations.

This looks awesome! 🎉 I really like the direction you’re taking with syncing the webview translations with the extension translations. It’s a great step towards consistency and improving the overall user experience.

@mrubens mrubens force-pushed the i18n branch 6 times, most recently from cb62b07 to a641329 Compare March 12, 2025 14:35
Copy link
Collaborator

@cte cte left a comment

Choose a reason for hiding this comment

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

👏

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

The pattern for extracting values from events (casting to CustomEvent or HTML input) is repeated across multiple onChange handlers. Consider extracting a helper function to reduce duplication and enhance readability.

@mrubens mrubens merged commit 0d81c0d into main Mar 12, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants