-
Notifications
You must be signed in to change notification settings - Fork 153
i18n: Change middleware usage to global container #1443
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
|
Caution Review failedThe pull request is closed. WalkthroughThe i18n package is refactored from a per-request middleware to a reusable, thread-safe container. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant I18n as i18n Container
participant Localizer as go-i18n
App->>I18n: New(config) → *I18n
activate I18n
I18n->>I18n: prepareConfig()
I18n->>Localizer: build bundle & localizers
deactivate I18n
App->>App: register route handlers
App->>I18n: translator.Localize(ctx, params)
activate I18n
I18n->>I18n: resolve language (ctx -> LangHandler)
I18n->>Localizer: get localizer & localize(config)
Localizer-->>I18n: translated string / error
I18n-->>App: string or error
deactivate I18n
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
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. Comment |
Summary of ChangesHello @ReneWerner87, 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 Highlights
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 is a significant improvement to the i18n package. It refactors the package from a middleware-based approach to a more flexible and efficient thread-safe container. The removal of the Next hook and the introduction of the I18n struct are well-executed. The changes make the package's API clearer and its usage more intuitive, as demonstrated by the updated examples and the new migration guide in the README.
Key improvements include:
- A cleaner, non-middleware API that is easier to use and test.
- Enhanced robustness by creating copies of default configurations, preventing unintended side effects on the global default settings.
- Improved test suite, including fixes for resource leaks (
Body.Close()) and the addition of a crucial concurrency test to validate the thread-safety of the new design. - Code cleanup, such as removing redundant checks.
The changes are thorough and of high quality. I have no specific comments for code changes. Great work!
|
@coderabbitai pls update the summary |
|
@ReneWerner87: I'll regenerate the summary for this PR. 🧠 Learnings used✅ Actions performedSummary regeneration triggered. |
fixes #1142
https://chatgpt.com/codex/tasks/task_e_69038608cf1c8326b3922f65fa0ff45d
Summary by CodeRabbit
Breaking Changes
New Features
Improvements
Tests / Documentation