refactor(web): remove useMixedTranslation, better resource loading#30630
refactor(web): remove useMixedTranslation, better resource loading#30630
Conversation
- Replace useMixedTranslation with useTranslation from #i18n - Remove locale prop from marketplace components - Simplify useTags and useCategories hooks by removing translation parameter - Components now use the global locale from context instead of prop drilling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @hyoban, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the internationalization (i18n) implementation within the web application, particularly for marketplace components. The primary goal is to centralize and simplify how translations are handled by moving away from a custom Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the marketplace components to use the centralized #i18n module instead of the custom useMixedTranslation hook, eliminating prop drilling of the locale parameter throughout the component tree. Components now retrieve locale from the global i18n context rather than receiving it as a prop.
- Removed the
useMixedTranslationhook and replaced it withuseTranslationfrom#i18n - Simplified
useTagsanduseCategorieshooks by removing the translation parameter - Eliminated
localeprop drilling across 21 component files
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
web/app/components/plugins/marketplace/hooks.ts | Removed useMixedTranslation hook that supported external locale injection |
web/app/components/plugins/hooks.ts | Simplified useTags and useCategories to remove translation parameter |
web/app/components/plugins/marketplace/index.tsx | Removed locale prop from Marketplace component interface |
web/app/components/plugins/marketplace/list/*.tsx | Updated list components to use useTranslation from #i18n and useLocale where needed |
web/app/components/plugins/marketplace/search-box/*.tsx | Removed locale prop from search components |
web/app/components/plugins/marketplace/sort-dropdown/index.tsx | Updated to use useTranslation from #i18n |
web/app/components/plugins/marketplace/plugin-type-switch.tsx | Removed locale prop and updated to use useTranslation |
web/app/components/plugins/marketplace/empty/index.tsx | Updated to use useTranslation from #i18n |
web/app/components/plugins/card/index.tsx | Updated to use useTranslation and removed locale prop |
web/app/components/plugins/base/deprecation-notice.tsx | Updated to use useTranslation from #i18n |
web/app/components/plugins/plugin-item/index.tsx | Updated useCategories call to remove translation parameter |
web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsx | Removed locale prop from List component usage |
web/app/components/header/account-setting/data-source-page-new/install-from-marketplace.tsx | Removed locale prop from List component usage |
web/app/(commonLayout)/plugins/page.tsx | Removed locale prop from Marketplace component |
web/app/components/tools/marketplace/index.tsx | Removed locale prop forwarding |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request provides an excellent, large-scale refactoring by removing the useMixedTranslation hook and centralizing i18n logic with the new #i18n module. This change successfully eliminates locale prop drilling across numerous components and simplifies related hooks like useTags and useCategories. The implementation is consistent and clean, leading to a significant improvement in code maintainability. The changes look solid.
Update test files to remove locale prop and useMixedTranslation usage after the refactor to use #i18n module directly: - Remove locale prop from component renders in tests - Update mocks from useMixedTranslation to useTranslation from #i18n - Add useLocale mock where needed - Remove locale-specific test cases that are no longer applicable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add mock for react-i18next's getI18n to prevent test failure when modules that use i18n are imported at module load time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| The PR should be linked to an issue. |
This PR removes
useMixedTranslationand locale prop drilling. And we have a better resource loading experience, no need to reload the page.I know this is related to the marketplace. I will make it correct on both sides.
Fixes #30648
Fixes #30649