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

Remove locale from react-i18n now that it is available in i18n-utils #47446

Closed
wants to merge 1 commit into from

Conversation

p-jackson
Copy link
Member

@p-jackson p-jackson commented Nov 16, 2020

Changes proposed in this Pull Request

The react-i18n library currently supplies the current locale slug, however that package is trying to do things in a way that will work for any Gutenberg user, and there is no standard way to access the current locale slug in Gutenberg/core WP.

Since #47566 the @automattic/i18n-utils package has had the ability to supply a locale slug, and after #47567 is merged there will no longer be any references to the locale from react-i18n. So this PR removes it.

  • Remove i18nLocale from the useI18n() hook
  • Update readme

Testing instructions

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Nov 16, 2020

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~103 bytes removed 📉 [gzipped])

name                 parsed_size           gzip_size
entry-main                -111 B  (-0.0%)      -54 B  (-0.0%)
entry-gutenboarding       -111 B  (-0.0%)      -49 B  (-0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

lsl
lsl previously requested changes Nov 16, 2020
Copy link
Contributor

@lsl lsl left a comment

Choose a reason for hiding this comment

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

Approach lgtm.

i18n-utils isn't yet safe to import unless you're ok with bringing in i18n-calypso along with it. (We're trying to avoid this - why its so difficult to untangle)

^that coupling will be fixed up with #47358 which replaces i18n-calypso's getLocaleSlug with react-i18n's i18nLocale value instead.

Of course #47358 depends on your work in #47352 which is what makes the locale available in react-i18n.

Bit of a chicken and egg situation as this PR then removes that locale from react-i18n. I guess we need to use this new provider and set the locale along side setting the localeData in react-i18n in components/calypso-i18n-provider

There is a getLocaleSlug in the i18n-calypso that should be usable for this.

phew - round abouts but I think this will work.

@yuliyan yuliyan self-requested a review November 16, 2020 11:21
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 16, 2020
@lsl
Copy link
Contributor

lsl commented Nov 17, 2020

Followed up on this here #47492

@p-jackson p-jackson changed the title Add locale to i18n-utils so it can be used and set in React components Move locale from react-i18n to i18n-utils as it's a WordPress.com specific feature Nov 18, 2020
@p-jackson p-jackson marked this pull request as ready for review November 18, 2020 08:34
@p-jackson p-jackson force-pushed the try/locale-context-in-i18n-utils branch from e819415 to 6916ea7 Compare November 18, 2020 08:35
@matticbot
Copy link
Contributor

Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D52928-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2

@p-jackson p-jackson force-pushed the try/locale-context-in-i18n-utils branch from 6916ea7 to 9994c95 Compare November 19, 2020 04:04
@p-jackson p-jackson changed the title Move locale from react-i18n to i18n-utils as it's a WordPress.com specific feature Remove locale from react-i18n now that it is available in i18n-utils Nov 19, 2020
@p-jackson p-jackson dismissed lsl’s stale review November 19, 2020 04:10

Big changes since this review. This PR no longer tries to do everything and just removes i18nLocale from the the react-i18n package one all references to it have been removed.

The ability to get the locale slug has moved to i18n-utils since it's a
Calypso specific feature.
@p-jackson p-jackson force-pushed the try/locale-context-in-i18n-utils branch from 9994c95 to 65c8422 Compare November 20, 2020 02:40
@sarayourfriend sarayourfriend changed the base branch from master to trunk November 20, 2020 16:10
@p-jackson
Copy link
Member Author

Done by #47352

@p-jackson p-jackson closed this Nov 23, 2020
@p-jackson p-jackson deleted the try/locale-context-in-i18n-utils branch November 23, 2020 21:10
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants