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

Conversation

Bamieh
Copy link
Member

@Bamieh Bamieh commented Mar 27, 2024

Summary

Upgrading intl packages from v2 to v6

Packages upgrade:

  • Add @formatjs packages
  • react-intl Upgraded
  • intl-messageformat Upgraded
  • intl-format-cache removed
  • intl-relativeformat removed
  • intl-messageformat-parser removed

Todo list:

Closes #178968
Closes #38642

Notes to code reviewers

For team other than the core team, please review your plugins code changes by filtering files by codeowners.

Test Snapshot updates

Most of the changes are refactors of renamed functions and changed ICU syntax.

The main updates are snapshot changes where FormattedMessage is now memoized so snapshots capturing the html tree needed to be updated to use <Memo(MemoizedFormattedMessage) instead of <FormattedMessage

ICU now supports HTML tags:

before:

<FormattedMessage
  defaultMessage="To buy a shoe, { link } and { cta }"
  values={{
    link: (
      <a class="external_link" target="_blank" href="https://www.shoe.com/">
        visit our website
      </a>
    ),
    cta: <strong class="important">eat a shoe</strong>,
  }}
/>

after:

<FormattedMessage
  defaultMessage="To buy a shoe, <a>visit our website</a> and <cta>eat a shoe</cta>"
  values={{
    a: msg => (
      <a class="external_link" target="_blank" href="https://www.shoe.com/">
        {msg}
      </a>
    ),
    cta: msg => <strong class="important">{msg}</strong>,
  }}
/>

Escape character to prevent ICU parsing changed from double slashes to single quotes:

before: \\{escaped\\}
after: '{escaped}'

No need for Intl Shape

the new packages under formatJS are written in typescript and come with types support out of the box so no need to set types when using i18n.

Renamed InjectedIntlProps with WrappedComponentProps.
Removed prop-types and intlShape in favor of IntlShape.

FormattedRelative has been renamed to FormattedRelativeTime and its API has changed significantly. See FormattedRelativeTime for more details.

All tags specified must have corresponding values and will throw error if it's missing

All tags are now parsed and expected to be formatted properly (all opened tags must be closed).

To skip this check you can use the ignoreTag: true property

i18n.translate('xpack.apm.agentConfig.captureJmxMetrics.description', {
      defaultMessage: 'This is not an HTML tag <JMX object name pattern>' +
      ignoreTag: true,
    }),

When do I use ignore tags?

If your message has HTML tags, it is preferred not to ignore the Tag to have some string verification that the html tags you are adding are properly formatted and closed.

If it the text between brackets is not an HTML tag and it is just a fomat preference then using ignoreTag makes sense.

@Bamieh Bamieh added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Project:i18n 8.14 candidate labels Mar 27, 2024
@Bamieh Bamieh requested a review from gsoldevila March 27, 2024 05:10
@Oscurz
Copy link

Oscurz commented May 27, 2024 via email

@Bamieh
Copy link
Member Author

Bamieh commented May 27, 2024

@elasticmachine merge upstream

@Bamieh
Copy link
Member Author

Bamieh commented May 28, 2024

@elasticmachine merge upstream

@Bamieh
Copy link
Member Author

Bamieh commented May 28, 2024

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@Bamieh
Copy link
Member Author

Bamieh commented May 28, 2024

@elasticmachine merge upstream

@Bamieh Bamieh requested a review from maryam-saeidi June 1, 2024 08:41
@kibana-ci
Copy link
Collaborator

kibana-ci commented Jun 2, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/content-management-table-list-view-table 31 32 +1
@kbn/i18n 48 29 -19
@kbn/i18n-react 1 7 +6
@kbn/test-jest-helpers 103 98 -5
total -17

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
@kbn/test-jest-helpers 5 3 -2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
alerting 91.4KB 91.4KB +10.0B
apm 3.3MB 3.3MB +93.0B
canvas 1.1MB 1.1MB +42.0B
cloudSecurityPosture 450.5KB 450.5KB -2.0B
crossClusterReplication 148.7KB 148.8KB +64.0B
dashboard 495.5KB 495.5KB +2.0B
data 46.7KB 46.7KB +4.0B
dataViewEditor 48.6KB 48.6KB +2.0B
dataViewFieldEditor 176.3KB 176.3KB +6.0B
dataViewManagement 136.4KB 136.5KB +49.0B
dataVisualizer 757.6KB 757.6KB +4.0B
discover 811.0KB 811.0KB +14.0B
enterpriseSearch 2.7MB 2.7MB +113.0B
exploratoryView 182.0KB 182.0KB +13.0B
fileUpload 951.8KB 951.8KB +2.0B
fleet 1.3MB 1.3MB +362.0B
indexLifecycleManagement 148.8KB 148.8KB +2.0B
indexManagement 664.8KB 664.8KB +44.0B
infra 1.5MB 1.5MB +4.0B
ingestPipelines 368.9KB 368.9KB +10.0B
inputControlVis 52.0KB 52.0KB +2.0B
kubernetesSecurity 213.9KB 213.9KB -5.0B
lens 1.5MB 1.5MB +2.0B
logsShared 54.9KB 54.9KB -6.0B
logstash 33.3KB 33.3KB +2.0B
maps 3.0MB 3.0MB +40.0B
ml 4.1MB 4.1MB -335.0B
remoteClusters 78.8KB 78.8KB +18.0B
rollup 114.3KB 114.4KB +12.0B
savedObjectsManagement 84.3KB 84.4KB +136.0B
savedObjectsTagging 132.6KB 132.6KB +4.0B
security 587.1KB 587.2KB +60.0B
securitySolution 15.2MB 15.2MB +452.0B
slo 866.2KB 866.2KB +2.0B
snapshotRestore 262.0KB 262.1KB +60.0B
spaces 175.1KB 175.1KB +22.0B
stackAlerts 86.5KB 86.5KB +4.0B
transform 479.4KB 479.4KB +18.0B
triggersActionsUi 1.6MB 1.6MB +10.0B
uiActionsEnhanced 135.8KB 135.8KB -12.0B
visualizations 285.8KB 285.8KB +6.0B
watcher 165.9KB 166.0KB +16.0B
total +1.3KB

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5499 +5499
total size - 8.9MB +8.9MB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/i18n 0 2 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
alerting 25.0KB 25.0KB +6.0B
apm 35.4KB 35.0KB -420.0B
core 417.0KB 416.9KB -152.0B
dashboard 43.4KB 43.4KB +4.0B
dataViewFieldEditor 26.3KB 26.3KB +4.0B
expressionRevealImage 8.5KB 8.5KB +4.0B
expressions 99.5KB 99.5KB +6.0B
expressionShape 23.2KB 23.2KB +8.0B
infra 101.9KB 101.7KB -278.0B
kbnUiSharedDeps-srcJs 3.2MB 3.1MB -6.8KB
lens 49.3KB 49.3KB +2.0B
observability 122.6KB 122.6KB -30.0B
reporting 52.8KB 52.8KB +8.0B
savedObjects 25.5KB 25.5KB +4.0B
security 69.0KB 69.0KB -18.0B
slo 23.0KB 22.9KB -110.0B
stackAlerts 24.9KB 24.8KB -92.0B
transform 18.8KB 18.6KB -232.0B
triggersActionsUi 115.5KB 115.5KB -18.0B
total -8.0KB
Unknown metric groups

API count

id before after diff
@kbn/content-management-table-list-view-table 47 48 +1
@kbn/i18n 51 39 -12
@kbn/i18n-react 61 36 -25
@kbn/test-jest-helpers 133 131 -2
total -38

ESLint disabled in files

id before after diff
@kbn/i18n 2 0 -2

ESLint disabled line counts

id before after diff
@kbn/core-i18n-browser-mocks 1 0 -1
@kbn/i18n 1 2 +1
@kbn/i18n-react 4 0 -4
total -4

Total ESLint disabled count

id before after diff
@kbn/core-i18n-browser-mocks 1 0 -1
@kbn/i18n 3 2 -1
@kbn/i18n-react 4 0 -4
total -6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Bamieh Bamieh merged commit f1c854b into elastic:main Jun 2, 2024
51 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Jun 2, 2024
@Bamieh Bamieh deleted the intl_pack_upgrade branch June 4, 2024 10:44
mattkime added a commit that referenced this pull request Jun 5, 2024
## Summary

Address two cases where single quotes needed to be doubled up to prevent
escaping of string interpolation. Also addressed some doc examples.

Verify confirm toasts after saving field in discover and creating a
scripted field in data view management.

Follow up to #179506

---------

Co-authored-by: Julia Rechkunova <julia.rechkunova@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.15 candidate apm:review backport:skip This commit does not require backporting ci:project-deploy-observability Create an Observability project Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Project:i18n release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Team:Fleet Team label for Observability Data Collection Fleet team Team:Obs AI Assistant Observability AI Assistant Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team Team:obs-ux-management Observability Management User Experience Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[i18n][system upgrade] Upgrade Intl Packages from v2 to v6 [i18n] React-Intl v3 soon out of beta