Skip to content

CONSOLE-5073: Bump i18next to latest#16150

Open
logonoff wants to merge 3 commits intoopenshift:mainfrom
logonoff:CONSOLE-5073-i18n
Open

CONSOLE-5073: Bump i18next to latest#16150
logonoff wants to merge 3 commits intoopenshift:mainfrom
logonoff:CONSOLE-5073-i18n

Conversation

@logonoff
Copy link
Member

@logonoff logonoff commented Mar 16, 2026

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-parser instead of i18next-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

  • Chores
    • Upgraded internationalization libraries to latest versions for enhanced language support.
    • Removed d3 dependency from project dependencies.
    • Added development build tools for improved bundling support.
    • Enhanced i18n formatter registration and streamlined namespace configuration.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@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.

Details

In response to this:

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-parser instead of i18next-cli, that is out of scope for a simple shared module upgrade. There are some differences in configuration which may require additional work.

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.

@openshift-ci openshift-ci bot requested review from Leo6Leo and rhamilto March 16, 2026 14:34
@openshift-ci openshift-ci bot added component/core Related to console core functionality component/sdk Related to console-plugin-sdk approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 16, 2026
@logonoff
Copy link
Member Author

/label px-approved
/label docs-approved

@openshift-ci openshift-ci bot added px-approved Signifies that Product Support has signed off on this PR docs-approved Signifies that Docs has signed off on this PR labels Mar 16, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

This 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)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d1f6f7 and 5078f74.

⛔ Files ignored due to path filters (1)
  • frontend/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • frontend/i18next-parser.config.js
  • frontend/package.json
  • frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md
  • frontend/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.js
  • frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md
  • frontend/public/i18n.js
  • frontend/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 i18n config. [::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 I18n field. [::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 i18n name 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]

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-i18next shared-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-i18next v16/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: showSupportNotice toggle placement looks good.

Setting it inside init options keeps behavior explicit for runtime i18n initialization.

Comment on lines +99 to +107
i18n.services.formatter.add('number', (val, lng) => {
return new Intl.NumberFormat(lng).format(val);
});
i18n.services.formatter.add('fromNow', (val, lng, options) => {
return fromNow(val, null, options);
});
i18n.services.formatter.add('dateTime', (val) => {
return dateTimeFormatter.format(val);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Verify the signature/style of dateTimeFormatter and fromNow in datetime utils
fd -t f 'datetime\.(ts|tsx|js|jsx)$' | xargs -r rg -n -C2 'dateTimeFormatter|fromNow'

# 2) Confirm current formatter registrations in i18n bootstrap
rg -n -C3 "formatter\\.add\\('(number|fromNow|dateTime)'" frontend/public/i18n.js

Repository: openshift/console

Length of output: 3698


Fix formatter registration: dateTimeFormatter factory invocation and missing locale parameter.

At lines 105–106, dateTimeFormatter.format(val) is incorrect—dateTimeFormatter is a factory function, not an instance (defined in frontend/packages/console-shared/src/utils/datetime.ts:41). This will throw at runtime. The correct pattern is dateTimeFormatter(lng).format(val).

Similarly, at line 103, fromNow(val, null, options) omits the langArg parameter. The function signature at frontend/packages/console-shared/src/utils/datetime.ts:84 accepts a fourth parameter to ensure locale-aware relative time formatting. Pass lng as the fourth argument and use undefined instead of null for the second parameter to match existing codebase patterns.

Proposed patch
      i18n.services.formatter.add('fromNow', (val, lng, options) => {
-       return fromNow(val, null, options);
+       return fromNow(val, undefined, options, lng);
      });
      i18n.services.formatter.add('dateTime', (val) => {
-       return dateTimeFormatter.format(val);
+       return dateTimeFormatter(lng).format(val);
      });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/public/i18n.js` around lines 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).

@openshift-ci openshift-ci bot added the kind/demo-plugin Related to dynamic-demo-plugin label Mar 16, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: logonoff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

"{{count}} Worker Node": "{{count}} Worker Node",
"{{count}} Worker Node_plural": "{{count}} Worker Nodes",
"{{count}} Worker Node_one": "{{count}} Worker Node",
"{{count}} Worker Node_other": "{{count}} Worker Node",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This change makes it look as if we are forcing dynamic plugins to bump their versions, which I believe is not the intention here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can revert the changes in dynamic-demo-plugin

return fromNow(val, null, options);
});
i18n.services.formatter.add('dateTime', (val) => {
return dateTimeFormatter.format(val);
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this doesn't appear to be entirely new, it must still be verified since we are bumping versions. The formatter registrations might have incorrect signatures: shouldn't the fromNow formatter pass lng as the 4th argument, and the dateTime formatter invoke dateTimeFormatter(lng) as a factory?

Did you verify these against the actual function signatures in datetime.ts?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 16, 2026

@logonoff: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/backend c78fd06 link true /test backend

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/sdk Related to console-plugin-sdk docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/demo-plugin Related to dynamic-demo-plugin px-approved Signifies that Product Support has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants