-
Notifications
You must be signed in to change notification settings - Fork 19.6k
refactor(i18n): about locales #30336
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
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) system within the frontend application. The primary goal is to streamline locale management by transitioning from a custom context-based approach to a more standard and efficient hook-based method using 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the internationalization (i18n) implementation across the codebase by replacing direct usage of useContext(I18NContext) or useI18N() with a new useLocale() hook. The I18NContext and useI18N hook have been removed from the @/context/i18n module. The I18n component in web/app/components/i18n.tsx was updated to use useLocale() and no longer provides a context. Additionally, i18next-browser-languagedetector was introduced and configured in i18next-config.ts to automatically detect the user's language. Server-side rendering for i18n was also optimized by introducing serverOnlyContext to cache locale and i18n instances, preventing redundant initializations. Corresponding test files were updated to reflect these changes, mocking useLocale instead of I18NContext.Provider.
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.
Pull request overview
This PR refactors the i18n (internationalization) implementation by migrating from a React Context-based approach to using Jotai atoms for state management. The main changes include replacing the useI18N() hook with a simpler useLocale() hook, introducing server-side caching for locale detection and i18n instances, and updating all consumers throughout the codebase.
Key Changes
- Introduced Jotai library for client-side locale state management with
localeAtom - Added server-side caching utilities using React's
cache()API for locale and i18n instances - Replaced context-based
useI18N()hook with atom-baseduseLocale()hook across the entire codebase - Updated 50+ component files and test files to use the new API
Reviewed changes
Copilot reviewed 65 out of 66 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| web/utils/server-only-context.ts | New utility for server-side caching using React cache API |
| web/package.json | Added Jotai dependency for atom-based state management |
| web/pnpm-lock.yaml | Lock file updates for Jotai package |
| web/i18n-config/server.ts | Refactored server-side i18n with caching for locale detection and i18n instances |
| web/i18n-config/i18next-config.ts | Removed empty line (formatting) |
| web/i18n-config/DEV.md | Updated documentation to reflect useI18N → useLocale rename |
| web/context/i18n.ts | Replaced Context-based implementation with Jotai atom-based hooks |
| web/app/components/i18n.tsx | Updated to hydrate localeAtom instead of providing Context |
| web/app/components/with-i18n.tsx | Removed obsolete HOC component |
| web/hooks/use-format-time-from-now.ts | Updated to use useLocale() instead of useI18N() |
| web/hooks/use-format-time-from-now.spec.ts | Updated test mocks for useLocale() |
| web/app/signin/_header.tsx | Updated to use useLocale() and import setLocaleOnClient directly |
| web/app/signin/invite-settings/page.tsx | Updated to import setLocaleOnClient directly instead of from context |
| web/app/signin/components/mail-and-password-auth.tsx | Updated to use useLocale() |
| web/app/signin/components/mail-and-code-auth.tsx | Updated to use useLocale() |
| web/app/signin/check-code/page.tsx | Updated to use useLocale() |
| web/app/signup/components/input-mail.tsx | Updated to use useLocale() |
| web/app/signup/check-code/page.tsx | Updated to use useLocale() |
| web/app/reset-password/page.tsx | Updated to use useLocale() |
| web/app/reset-password/check-code/page.tsx | Updated to use useLocale() |
| web/app/components/workflow/nodes/document-extractor/panel.tsx | Updated to use useLocale() |
| web/app/components/workflow/block-selector/rag-tool-recommendations/uninstalled-item.tsx | Updated to use useLocale() |
| web/app/components/workflow/block-selector/market-place-plugin/item.tsx | Updated to use useLocale() |
| web/app/components/tools/provider/tool-item.tsx | Updated to use useLocale() |
| web/app/components/tools/provider/detail.tsx | Updated to use useLocale() |
| web/app/components/tools/provider/custom-create-card.tsx | Updated to use useLocale() |
| web/app/components/tools/mcp/detail/tool-item.tsx | Updated to use useLocale() |
| web/app/components/tools/mcp/create-card.tsx | Updated to use useLocale() |
| web/app/components/tools/edit-custom-collection-modal/test-api.tsx | Updated to use useLocale() |
| web/app/components/tools/edit-custom-collection-modal/test-api.spec.tsx | Updated test to mock useLocale() directly |
| web/app/components/plugins/provider-card.tsx | Updated to use useLocale() |
| web/app/components/plugins/plugin-page/index.tsx | Updated to use useLocale() |
| web/app/components/plugins/plugin-page/debug-info.tsx | Updated to use useLocale() |
| web/app/components/plugins/plugin-detail-panel/detail-header.tsx | Updated to use useLocale() |
| web/app/components/plugins/marketplace/list/index.spec.tsx | Added useLocale mock to existing test |
| web/app/components/plugins/marketplace/list/card-wrapper.tsx | Updated to use useLocale() |
| web/app/components/plugins/marketplace/description/index.tsx | Renamed translate import alias back to getTranslation |
| web/app/components/header/account-setting/model-provider-page/hooks.ts | Updated to use useLocale() |
| web/app/components/header/account-setting/model-provider-page/hooks.spec.ts | Updated test to mock useLocale() |
| web/app/components/header/account-setting/members-page/invite-modal/index.tsx | Updated to use useLocale() |
| web/app/components/header/account-setting/members-page/index.tsx | Updated to use useLocale() |
| web/app/components/header/account-setting/language-page/index.tsx | Updated to import setLocaleOnClient directly |
| web/app/components/develop/doc.tsx | Updated to use useLocale() |
| web/app/components/datasets/documents/detail/batch-modal/csv-downloader.tsx | Updated to use useLocale() |
| web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/index.tsx | Updated to use useLocale() |
| web/app/components/datasets/create/step-two/index.tsx | Updated to use useLocale() |
| web/app/components/datasets/create/file-uploader/index.tsx | Updated to use useLocale() |
| web/app/components/datasets/create-from-pipeline/list/built-in-pipeline-list.tsx | Updated to use useLocale() |
| web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx | Updated to use useLocale() |
| web/app/components/base/features/new-feature-panel/moderation/index.tsx | Updated to use useLocale() |
| web/app/components/base/features/new-feature-panel/moderation/form-generation.tsx | Updated to use useLocale() |
| web/app/components/base/agent-log-modal/tool-call.tsx | Updated to use useLocale() |
| web/app/components/app/configuration/tools/external-data-tool-modal.tsx | Updated to use useLocale() |
| web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx | Updated to use useLocale() |
| web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.spec.tsx | Updated test to mock useLocale() directly |
| web/app/components/app/annotation/header-opts/index.tsx | Updated to use useLocale() |
| web/app/components/app/annotation/header-opts/index.spec.tsx | Updated test to mock useLocale() |
| web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.tsx | Updated to use useLocale() |
| web/app/components/app/annotation/batch-add-annotation-modal/csv-downloader.spec.tsx | Updated test to mock useLocale() |
| web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx | Updated to use useLocale() |
| web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx | Updated to use useLocale() |
| web/app/(shareLayout)/webapp-signin/check-code/page.tsx | Updated to use useLocale() |
| web/app/(shareLayout)/webapp-reset-password/page.tsx | Updated to use useLocale() |
| web/app/(shareLayout)/webapp-reset-password/check-code/page.tsx | Updated to use useLocale() |
| web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/index.tsx | Updated to use useLocale() |
| web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/date-picker.tsx | Updated to use useLocale() |
Files not reviewed (1)
- web/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Important
Fixes #<issue number>.Summary
fixes #30311
fixes #30133
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods