Bug Fix: Improved handling of `I18n.getText` in rspack/webpack bundles
- Announced
- Tags
- bamboo-data-center, bitbucket-data-center, confluence-data-center, crowd-data-center, jira-data-center
- Severity
- info, set by
reef/atlassian-rule-v2 - Source
- https://developer.atlassian.com/changelog/#CHANGE-3391
I18n.getText() calls are now translated when their method namespace is a function invocation immediately followed by .I18n.getText(...). This covers inlined module loads and ES-module interop getters emitted by webpack and rspack in both development and production builds.
Previously these phrases could fall back to the untranslated key at runtime, and some unminified bundles could be left syntactically invalid.
When using webpack or rspack, prefer an ES module import:
import { I18n } from "@atlassian/wrm-react-i18n";
The following form is still not supported:
- CommonJS destructuring that produces a bare
I18n.getText(...)call, because WRM requires a namespace before.I18n.getText(...):
const { I18n } = require("@atlassian/wrm-react-i18n");
I18n.getText("translation.key");
See https://developer.atlassian.com/server/framework/atlassian-sdk/internationalising-your-plugin-javascript/#supported-method-namespaces for more information
The text above is the source's. reef added the severity, the dates it could read from the text, and the endpoints and scopes named in code.