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

Try/localize url no calypso #47358

Closed
wants to merge 6 commits into from
Closed

Try/localize url no calypso #47358

wants to merge 6 commits into from

Conversation

lsl
Copy link
Contributor

@lsl lsl commented Nov 12, 2020

Haven't tested this for the etk side yet, the approach worked for domain-picker

Changes proposed in this Pull Request

Testing instructions

Fixes #

p-jackson and others added 3 commits November 12, 2020 17:53
- Restores old i18n-utils lib tests
- Removes calypso dep from i18n-utils
- Makes locale requried param
- Updates up tests, removes mocks
@matticbot
Copy link
Contributor

@lsl lsl requested a review from p-jackson November 12, 2020 09:00
@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 12, 2020
@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.

D52650-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

@matticbot
Copy link
Contributor

matticbot commented Nov 12, 2020

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

App Entrypoints (~472 bytes added 📈 [gzipped])

name                   parsed_size           gzip_size
entry-gutenboarding         +567 B  (+0.0%)     +266 B  (+0.1%)
entry-main                  +233 B  (+0.0%)      +56 B  (+0.0%)
entry-login                 +215 B  (+0.0%)      +53 B  (+0.0%)
entry-domains-landing       +215 B  (+0.0%)      +97 B  (+0.1%)

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

Async-loaded Components (~131 bytes added 📈 [gzipped])

name                                           parsed_size           gzip_size
async-load-calypso-blocks-editor-launch-modal       +334 B  (+0.2%)     +131 B  (+0.3%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

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.

const { i18nLocale } = useI18n();

return {
locale: i18nLocale,
localizeUrl: ( fullUrl: string, locale?: Locale ) => {
if ( locale ) {
return localizeUrl( fullUrl, locale );
Copy link
Member

Choose a reason for hiding this comment

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

At first I didn't think we needed to support this case i.e. passing in their own value for locale. If they had the locale all along then maybe we should have encouraged them to use the non-hook version.

But I think this is good actually. By virtue of the fact that useI18nUtils() calls useI18n(), it means the hook will re-render when the underlying locale data changes and that makes sense.

So what I'm saying is leave it like this 😅

Copy link
Member

Choose a reason for hiding this comment

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

I don't know why GitHub is highlighting the locale: i18nLocale line. I'm talking about the return localizeUrl( fullUrl, locale ); line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a nice side effect, the reason I did this was to maintain the same api publicly as the original version, but if you pull in the function directly you should be under no assumption that the locale is optional in that context - hopefully typescript catches this as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's highlighting because I removed the locale in a later commit, I think I might have linked you the latest version to avoid seeing all your earlier (not yet merged) changes in the PR

@lsl lsl closed this Nov 20, 2020
@lsl lsl deleted the try/localize-url-no-calypso branch November 20, 2020 06:00
@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 20, 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