Skip to content
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

[i18n][system upgrade] Upgrade Intl Packages from v2 to v6 #179506

Merged
merged 91 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
0791354
upgrade packages
Bamieh Mar 27, 2024
57b3392
progress so far
Bamieh Apr 8, 2024
f0af2c1
fix kbn-i18n test cases
Bamieh Apr 8, 2024
37d2665
merge main
Bamieh Apr 8, 2024
ef3f2b6
more i18n fixes
Bamieh Apr 8, 2024
f269303
mock Provider to init i18n at jest level
Bamieh Apr 8, 2024
f51d59c
remove init
Bamieh Apr 11, 2024
196ce7d
code review changes
Bamieh Apr 11, 2024
81baedb
merge main, run linter, PR ready
Bamieh Apr 24, 2024
6657bdd
codereview updates
Bamieh May 6, 2024
c773321
merge main
Bamieh May 7, 2024
f75b609
revert observability_solution linter changes
Bamieh May 7, 2024
5fbd063
revert observability_solution linter changes
Bamieh May 7, 2024
706a652
i18n fixes to reverted files
Bamieh May 7, 2024
1f6d244
fix maps plugin escaping situation
Bamieh May 7, 2024
03ef603
revert obs solution linter changes
Bamieh May 7, 2024
cd59f2d
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 7, 2024
931ff5d
run i18n_check
Bamieh May 7, 2024
5a1bc70
remove yarn.lock duplicates
Bamieh May 7, 2024
910e32f
update codeowners and run linter
Bamieh May 8, 2024
17eb85f
update codeowners and run linter
Bamieh May 8, 2024
408c833
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 8, 2024
2f468a7
fix linter type bug
Bamieh May 8, 2024
027f61d
fix checker
Bamieh May 8, 2024
d0e9be8
fix jest enzyme
Bamieh May 14, 2024
515c5c9
merge main
Bamieh May 14, 2024
e446c0a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 14, 2024
3f380f5
fix types and module resolution
Bamieh May 15, 2024
89a9b8b
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 15, 2024
aa3c57f
fix enzyme helpers
Bamieh May 16, 2024
db4c286
update ml snapshots and messages
Bamieh May 16, 2024
e461d08
merge main
Bamieh May 16, 2024
33dd416
update src/plugins snapshots
Bamieh May 16, 2024
94f1f6d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 16, 2024
ff66bbb
fix tests
Bamieh May 18, 2024
f1df11d
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 18, 2024
f3eeda8
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 18, 2024
433d9dd
more test fixes
Bamieh May 18, 2024
1aa48aa
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 18, 2024
737d9bc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 18, 2024
429263a
fix all tests
Bamieh May 18, 2024
d9c32c8
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 18, 2024
33a944b
ftr test fix
Bamieh May 18, 2024
5226361
merge main
Bamieh May 18, 2024
09637a9
more snapshot updates
Bamieh May 19, 2024
ffb71ab
update alerting rules
Bamieh May 19, 2024
954a48a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 19, 2024
d68c470
fix ftr i18n tests
Bamieh May 19, 2024
8152385
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 19, 2024
46b6105
more snapshot tests fixes
Bamieh May 19, 2024
a12c634
fix jest tests
Bamieh May 19, 2024
ca78e6e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 19, 2024
0fb5792
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 22, 2024
df69a99
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 22, 2024
370ee39
2nd ftr fix
Bamieh May 22, 2024
84ea023
fix web worker issue
Bamieh May 22, 2024
08092ff
more ftr fixes
Bamieh May 22, 2024
27e32b1
all resolved???
Bamieh May 22, 2024
3ade053
wrap with joblist with <I18nProvider>
Bamieh May 22, 2024
37022cd
final ftr failing
Bamieh May 23, 2024
5bebdd4
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 23, 2024
c76ed04
try to revert dev docs unnecessary change
Bamieh May 23, 2024
5c806f3
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 23, 2024
a87bd92
ignore tags
Bamieh May 24, 2024
0c67424
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 24, 2024
f7ee537
fix jest tests
Bamieh May 25, 2024
056a7db
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 25, 2024
a3516db
fix more tests
Bamieh May 25, 2024
56b6707
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 25, 2024
cc484bc
fix jest test
Bamieh May 25, 2024
229363c
return empty object instead of undefiend
Bamieh May 25, 2024
f670781
revert last commit apm change
Bamieh May 26, 2024
9cc6ad7
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 27, 2024
5473ed6
fix newly failed jest test
Bamieh May 27, 2024
a72df75
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 27, 2024
53219e7
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 27, 2024
806c0ef
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 27, 2024
cffa876
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 27, 2024
bef49c6
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 27, 2024
e6602f7
fix(NA): yarn lock file
mistic May 27, 2024
27e0121
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 27, 2024
85bb769
Merge branch 'main' of github.com:elastic/kibana into intl_pack_upgrade
Bamieh May 27, 2024
18ae5ac
Merge branch 'intl_pack_upgrade' of github.com:Bamieh/kibana into int…
Bamieh May 27, 2024
57897c6
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 28, 2024
46284e5
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 28, 2024
3c59599
Merge branch 'main' into intl_pack_upgrade
kibanamachine May 28, 2024
fede365
merge main and fix snapshot
Bamieh Jun 2, 2024
71507f1
fix test missing i18n provider
Bamieh Jun 2, 2024
562eb1d
add formatter test for nospace and fix 0ms not 155ms
Bamieh Jun 2, 2024
1473b8b
skip failing journeys on main
Bamieh Jun 2, 2024
b080cf2
2 more journeys
Bamieh Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,22 @@ module.exports = {
'jsx-a11y/click-events-have-key-events': 'off',
},
},

/**
* FormatJS linter for i18n code.
* https://formatjs.io/docs/tooling/linter
*/
{
files: [
'src/**/*.{js,mjs,ts,tsx}',
'x-pack/**/*.{js,mjs,ts,tsx}',
'packages/**/*.{js,mjs,ts,tsx}',
],
plugins: ['formatjs'],
rules: {
'formatjs/enforce-default-message': ['error', 'anything'],
'formatjs/enforce-description': 'off',
},
},
/**
* Files that require dual-license headers, settings
* are overridden below for files that require Elastic
Expand Down
1 change: 1 addition & 0 deletions dev_docs/tutorials/advanced_settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class ChartsServerPlugin implements Plugin<object, object> {
description: i18n.translate('charts.advancedSettings.visualization.colorMappingText', {
defaultMessage:
'Maps values to specific colors in charts using the <strong>Compatibility</strong> palette.',
ignoreTag: true,
}),
deprecation: {
message: i18n.translate(
Expand Down
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@faker-js/faker": "^8.3.1",
"@formatjs/icu-messageformat-parser": "^2.7.6",
"@formatjs/intl": "^2.10.1",
"@formatjs/intl-pluralrules": "^5.2.12",
"@formatjs/intl-relativetimeformat": "^11.2.12",
"@formatjs/intl-utils": "^3.8.4",
"@grpc/grpc-js": "^1.6.8",
"@hapi/accept": "^5.0.2",
"@hapi/boom": "^9.1.4",
Expand Down Expand Up @@ -1022,10 +1027,7 @@
"immer": "^9.0.21",
"inquirer": "^7.3.3",
"intl": "^1.2.5",
"intl-format-cache": "^2.1.0",
"intl-messageformat": "^2.2.0",
"intl-messageformat-parser": "^1.4.0",
"intl-relativeformat": "^2.1.0",
"intl-messageformat": "10.5.11",
"io-ts": "^2.0.5",
"ipaddr.js": "2.0.0",
"isbinaryfile": "4.0.2",
Expand Down Expand Up @@ -1101,7 +1103,7 @@
"react-fast-compare": "^2.0.4",
"react-grid-layout": "^1.3.4",
"react-hook-form": "^7.44.2",
"react-intl": "^2.8.0",
"react-intl": "6.6.3",
"react-is": "^17.0.2",
"react-markdown": "^6.0.3",
"react-monaco-editor": "^0.54.0",
Expand Down Expand Up @@ -1211,6 +1213,8 @@
"@elastic/synthetics": "^1.5.0",
"@emotion/babel-preset-css-prop": "^11.11.0",
"@emotion/jest": "^11.11.0",
"@formatjs/cli": "^6.2.8",
"@formatjs/cli-lib": "^6.3.8",
"@frsource/cypress-plugin-visual-regression-diff": "^3.3.10",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@istanbuljs/schema": "^0.1.2",
Expand Down Expand Up @@ -1444,7 +1448,6 @@
"@types/hjson": "^2.4.2",
"@types/http-proxy": "^1.17.4",
"@types/inquirer": "^7.3.1",
"@types/intl-relativeformat": "^2.1.0",
"@types/jest": "^29.5.3",
"@types/jest-axe": "^3.5.3",
"@types/jquery": "^3.3.31",
Expand Down Expand Up @@ -1585,11 +1588,12 @@
"ejs": "^3.1.8",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"eslint": "^8.46.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-ban": "^1.6.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-formatjs": "^4.12.2",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-jsx-a11y": "^6.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,4 @@ describe('I18nProviderMock', () => {
).html()
).toMatchInlineSnapshot(`"default message"`);
});

it('interpolates to id if default message is not present', () => {
expect(
shallow(
<I18nProviderMock>
<FormattedMessage id="id" />
</I18nProviderMock>
).html()
).toMatchInlineSnapshot(`"id"`);
});
Bamieh marked this conversation as resolved.
Show resolved Hide resolved
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@ import { i18n, i18nLoader } from '@kbn/i18n';
export const initTranslations = async (locale: string, translationFiles: string[]) => {
i18nLoader.registerTranslationFiles(translationFiles);
const translations = await i18nLoader.getTranslationsByLocale(locale);
i18n.init(
Object.freeze({
locale,
...translations,
})
);
i18n.init(Object.freeze({ ...translations }));
Bamieh marked this conversation as resolved.
Show resolved Hide resolved
Bamieh marked this conversation as resolved.
Show resolved Hide resolved
};
3 changes: 3 additions & 0 deletions packages/kbn-eslint-config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ module.exports = {
from: 'react-intl',
to: '@kbn/i18n-react',
disallowedMessage: `import from @kbn/i18n-react instead`,
exclude: [
/packages[\/\\]kbn-i18n-react[\/\\]/,
]
},
{
from: 'styled-components',
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-i18n-react/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ BUNDLER_DEPS = [
"//packages/kbn-i18n",
"@npm//prop-types",
"@npm//react",
"@npm//react-intl"
"@npm//react-intl",
"@npm//@formatjs/intl-utils"
]

js_library(
Expand Down
24 changes: 15 additions & 9 deletions packages/kbn-i18n-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line @kbn/eslint/module_migration
export type { InjectedIntl, InjectedIntlProps } from 'react-intl';
import type { IntlShape, WrappedComponentProps } from 'react-intl';
import {
FormattedDate,
FormattedTime,
FormattedNumber,
FormattedPlural,
FormattedMessage,
FormattedRelativeTime,
} from 'react-intl';

export type { IntlShape, WrappedComponentProps };
export {
intlShape,
FormattedDate,
FormattedTime,
FormattedRelative,
FormattedNumber,
FormattedPlural,
FormattedMessage,
FormattedHTMLMessage,
// Only used for testing. Use I18nProvider otherwise.
IntlProvider as __IntlProvider, // eslint-disable-next-line @kbn/eslint/module_migration
} from 'react-intl';
FormattedRelativeTime,
};

export { FormattedRelative } from './src/compatiblity_layer';
export type { FormattedRelativeProps } from './src/compatiblity_layer';
export { I18nProvider } from './src/provider';
export { injectI18n } from './src/inject';
export { injectI18n, useI18n } from './src/inject';
171 changes: 149 additions & 22 deletions packages/kbn-i18n-react/src/__snapshots__/provider.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading