CONSOLE-5073: Bump i18next to latest#16150
Conversation
|
@logonoff: This pull request references CONSOLE-5073 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/label px-approved |
📝 WalkthroughWalkthroughThis pull request upgrades the i18next internationalization library ecosystem across the frontend, including major version updates to i18next, react-i18next, and related packages. Configuration changes suppress a library support notice, adjust initialization options, and register custom formatters post-initialization. Dependency updates include adding a webpack polyfill plugin and removing d3, while the release notes are updated to reflect the new shared module requirement for react-i18next v16. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/public/i18n.js`:
- Around line 99-107: The i18n formatter registrations are calling the wrong
signatures: change the 'fromNow' formatter to pass the locale as the fourth
argument (use undefined for the second param) and change the 'dateTime'
formatter to invoke the factory before formatting; specifically, update the
i18n.services.formatter.add callbacks so fromNow is called as fromNow(val,
undefined, options, lng) and dateTimeFormatter is invoked as
dateTimeFormatter(lng).format(val) (adjusting the callbacks for the 'fromNow'
and 'dateTime' registrations that reference fromNow and dateTimeFormatter).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: b9999da1-5b33-4e72-a114-877439cd9f05
⛔ Files ignored due to path filters (1)
frontend/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (4)
frontend/i18next-parser.config.jsfrontend/package.jsonfrontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.mdfrontend/public/i18n.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/i18next-parser.config.jsfrontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.mdfrontend/public/i18n.jsfrontend/package.json
🧬 Code graph analysis (1)
frontend/public/i18n.js (1)
frontend/packages/console-shared/src/utils/datetime.ts (2)
fromNow(84-136)dateTimeFormatter(41-48)
🔀 Multi-repo context openshift/console-operator
Linked repositories findings
openshift/console-operator
-
Plugin CRD / types referencing i18n plugin config:
- vendor/github.com/openshift/api/console/v1/types_console_plugin.go — ConsolePluginI18n field and LoadType enum references to i18n configuration. [::openshift/console-operator::vendor/github.com/openshift/api/console/v1/types_console_plugin.go]
- vendor/github.com/openshift/api/console/v1/zz_generated.crd-manifests/90_consoleplugins.crd.yaml — CRD schema describing
i18nconfig. [::openshift/console-operator::vendor/github.com/openshift/api/console/v1/zz_generated.crd-manifests/90_consoleplugins.crd.yaml] - vendor/github.com/openshift/client-go/console/applyconfigurations/console/v1/consolepluginspec.go — apply-configuration struct includes
I18nfield. [::openshift/console-operator::vendor/github.com/openshift/client-go/console/applyconfigurations/console/v1/consolepluginspec.go]
-
Console server / configmap code that builds i18n namespaces passed to the console frontend:
- pkg/console/subresource/consoleserver/config_builder.go — I18nNamespaces builder, I18nNamespaces field in generated config. (functions: ConsoleServerCLIConfigBuilder.I18nNamespaces, i18nNamespaces()) [::openshift/console-operator::pkg/console/subresource/consoleserver/config_builder.go]
- pkg/console/subresource/consoleserver/types.go — ConsoleServer config contains I18nNamespaces []string. [::openshift/console-operator::pkg/console/subresource/consoleserver/types.go]
- pkg/console/subresource/configmap/configmap.go — computes i18nNamespaces from plugins and adds to configmap. [::openshift/console-operator::pkg/console/subresource/configmap/configmap.go]
- pkg/api/api.go — V1Alpha1PluginI18nAnnotation constant ("console.openshift.io/use-i18n") used to indicate plugin i18n usage. [::openshift/console-operator::pkg/api/api.go]
-
Generated client / swagger docs referencing i18n:
- vendor/github.com/openshift/client-go/console/applyconfigurations/internal/internal.go — contains
i18nname entry. [::openshift/console-operator::vendor/github.com/openshift/client-go/console/applyconfigurations/internal/internal.go] - vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go — swagger doc includes
"i18n": "i18n is the configuration of plugin's localization resources."[::openshift/console-operator::vendor/github.com/openshift/api/console/v1/zz_generated.swagger_doc_generated.go]
- vendor/github.com/openshift/client-go/console/applyconfigurations/internal/internal.go — contains
Relevance: the operator produces console server config and plugin-related CRD fields that include i18n namespaces and plugin i18n configuration. Upgrades in frontend i18next/react-i18next and changes to namespaces, formatter behavior, or config shape (as in the PR) could affect how the operator populates or expects i18n-related config, and how plugins declare/are served i18n resources.
🔇 Additional comments (4)
frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md (1)
13-13: Release-note compatibility guidance is correctly updated.The
react-i18nextshared-module requirement now matches the v16 upgrade and communicates plugin compatibility clearly.frontend/i18next-parser.config.js (1)
3-9: Suppression shim is safely scoped for parser startup.This runs early, is guarded by
typeof globalThis !== 'undefined', and does not alter exported parser options.frontend/package.json (1)
188-192: Dependency upgrades are consistent with the i18n migration objective.The manifest changes align cleanly with the
react-i18nextv16/i18next ecosystem bump and related build-tool updates.Also applies to: 212-212, 239-239, 281-281, 299-299, 323-323, 327-327
frontend/public/i18n.js (1)
52-52:showSupportNoticetoggle placement looks good.Setting it inside init options keeps behavior explicit for runtime i18n initialization.
dynamic-demo-plugin/locales/en/plugin__console-demo-plugin.json
Outdated
Show resolved
Hide resolved
c78fd06 to
a6fce01
Compare
Per code review. It's unclear whether the type is correct (fromNow `lng` requires a [`Intl.LocalesArgument`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument) and it's unclear from the docs if this is satisfied by [`i18n.services.formatter.add` lng](https://www.i18next.com/translation-function/formatting). but this is probably a safe assumption
`dateTime` and `fromNow` have 0 mentions in our locale files, number is a built-in formatter now, thus we don't need any of them. Just in case a plugin is using these formatters (even though they were never public API, they would be able to because we share the i18n instance), a remark about the removal has been added to the release notes.
71cbcdb to
acd6c66
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cajieh, logonoff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/assign @yapei |
performed manual regression testings about pseudo and real language translations, no regression issues found /verified by @yapei |
|
@yapei: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/test all |
|
/retest |
|
@logonoff: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |


The goal of this PR is to update the react-i18next shared module to a newer available version. Note we are still using the deprecated
i18next-parserinstead ofi18next-cli, that is out of scope for a simple shared module upgrade. There are some differences in configuration which may require additional work.Summary by CodeRabbit
Release Notes