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

Albanian locale is not included for Chrome #1254

Open
arturmuller opened this issue Dec 6, 2021 · 6 comments
Open

Albanian locale is not included for Chrome #1254

arturmuller opened this issue Dec 6, 2021 · 6 comments
Labels
library Relates to an Origami library service Relates to an Origami service

Comments

@arturmuller
Copy link

Bug

What

Albanian locale is not included for Chrome (which doesn't support this locale out of the box)

Details

Screenshot of polyfill.io response alongside console usage that's not recognising Albanian (sq):
image

I expected Albanian to be included for Chrome (but not be included for eg. Firefox).

My env:

  • Win10 / Chrome Version 96.0.4664.45 (Official Build) (64-bit)

I tried to force the inclusion of the sq locale via flags=always, but that resulted in various errors as below:
image

So -- not really sure what I should do to make this work as expected.

@github-actions github-actions bot added the service Relates to an Origami service label Dec 6, 2021
@JakeChampion
Copy link
Owner

Thanks for the issue @arturmuller - when using flags=always we also recommend using the gated flag. E.G. flags=always,gated because then the polyfills will only be applied if our feature-detection logic determines the browser is missing the feature.

That should solve the issue immediately for you.

I think we also need to fix the issue properly, which would be to serve Albanian to Chrome versions which are missing it. Do you happen to know which versions that would be?

@longlho do you know which versions of Chrome are missing the Intl locales for Albanian?

@arturmuller
Copy link
Author

Thanks for the quick response @JakeChampion!

Based on my research, Intl was introduced to Chrome in v24, so I would probably see if that version supports it. Chrome v76 introduced many featured to Intl (for example dateStyle which I am using in my example), so that could be another place to investigate.

I would not be surprised if it was indeed never supported.


Regarding your suggestion for an immediate fix, I am afraid that it doesn't do the trick.

This is the output when running with "always,gated":

Screenshot 2021-12-07 at 14 15 56

So — it seems that the feature detection logic decides to not apply the polyfill. The script runs to completion and triggers a callback specified in the polyfill URL.

This is the output when running with "always":

Screenshot 2021-12-07 at 14 17 34

The script errors-out and nukes JS on the page. Specified callback is not called and no polyfill is applied.


Any ideas on what else I could do to proceed?

@JakeChampion
Copy link
Owner

@arturmuller I can see the issue here now.

To polyfill the locales we need to use our Intl polyfill, because there is no way to add locales to the native implementations of Intl. The feature detects for Intl.DateTimeFormat and Intl.NumberFormat are saying the browser has those features, and so we do not polyfill them, which means we are not able to add our sq locale.

We likely need to update our browser targeting and feature detects for Intl.DateTimeFormat and Intl.NumberFormat or find some other way to load those polyfills when a requested locale needs to be polyfilled.

@longlho
Copy link
Contributor

longlho commented Dec 7, 2021

So locale data can change version to version so it's hard to tell what version contains what locale data.
In terms of gating check how are we doing it right now? We can update that from the formatjs side

@JakeChampion
Copy link
Owner

Perhaps a dynamically generated feature detect could be implemented for the Intl polyfills - this would require changing how feature detects are implemented within polyfill-library but it would allow for the smallest feature detect for Intl to be implemented. I.E. The feature detect could include the requested locales.

Right now feature detects are hard-coded and the ones for the Intl methods are quite broad:

https://github.com/Financial-Times/polyfill-library/blob/40f87d475f0e4c9cddb0febd2f4555bcc1ff32ae/polyfills/Intl/DateTimeFormat/detect.js#L1-L6

https://github.com/Financial-Times/polyfill-library/blob/40f87d475f0e4c9cddb0febd2f4555bcc1ff32ae/polyfills/Intl/NumberFormat/detect.js#L1-L11

@arturmuller
Copy link
Author

@JakeChampion thanks for the clarification. Makes sense.

If there is anything I can do on my side to help to get the feature detection implemented, I'd be happy to help. We're not currently in desperate need for a fix, but eventually we'll need to get this working.

@JakeChampion JakeChampion transferred this issue from polyfillpolyfill/polyfill-service Jan 9, 2023
@github-actions github-actions bot added the library Relates to an Origami library label Jan 9, 2023
@robertboulton robertboulton removed this from Backlog in Origami ✨ Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library Relates to an Origami library service Relates to an Origami service
Projects
None yet
Development

No branches or pull requests

3 participants