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: update test for new canonical locale codes #6360

Merged
merged 1 commit into from
Oct 22, 2018
Merged

i18n: update test for new canonical locale codes #6360

merged 1 commit into from
Oct 22, 2018

Conversation

brendankenny
Copy link
Member

Some recent ICU update (maybe in Node 10.7?) now acts upon the recommended deprecation of some locale codes (namely, in -> id and iw -> he), and so we have a failure on a test checking that all our supported locales use canonical codes in more recent versions of Node.

For now we still support the deprecated codes with explicit aliases in locales.js because existing versions of Node won't do that extra canonicalization step, so this PR updates the test to recognize both the old and new behavior.

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

LGTM

// Map of deprecated codes to their canonical version. Depending on the ICU
// version used to run Lighthouse/this test, these *may* come back as their
// substitute, not themselves.
const deprecatedCodes = {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this won't scale if we don't keep up on our deprecation notices. Do we have a transition plan for the future where we won't need to map these? Or will this be necessary for the foreseeable future as we encounter old Node versions and support explicit aliases?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively, should we be offering deprecated locales before we even have anyone relying on our locales, or should we just update to canonical now? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like this won't scale if we don't keep up on our deprecation notices.

Ideally it won't have to scale. There's been a few major ICU updates between Node 8 and latest 10, and these are the only locales that have had their getCanonicalLocale response changed. Looking at
https://www.unicode.org/cldr/charts/latest/supplemental/aliases.html
which has all the aliases in the next version of ICU, the only other deprecated one I spot from our list is mo, so we may have to eventually add that here.

Do we have a transition plan for the future where we won't need to map these?

When we move to Node 10 as the minimum required version, our i18n lib will return id even if the user explicitly requests in, so we can safely remove it from locales.js, at which point it can be removed from here.

So, yeah, basically support both until all our users only get one or the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, should we be offering deprecated locales before we even have anyone relying on our locales, or should we just update to canonical now? :)

In theory it's not necessary since LR is presumably running on recent Chrome (which has been doing the deprecated mapping for a while now), so, yeah, no actual users can use the deprecated codes until we launch support in the CLI.

@paulirish wanted to keep support in because it's trivial (just a mapping in locales.js) and tbf this test was always just a sanity check that we weren't trying to support locales that a user couldn't ever get. It makes sense to update it to recognize we're still providing the deprecated codes to the subset of users (CLI on Node < 10.7) that can still request them (until they can't anymore).

@brendankenny
Copy link
Member Author

lol, whoops, should have pushed this before #6361, as the Node 10 build on master is now broken 😳

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

cool cool LGTM!

@brendankenny brendankenny merged commit 926f641 into master Oct 22, 2018
@brendankenny brendankenny deleted the icu branch October 22, 2018 23:09
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.

None yet

3 participants