polyfill-library
polyfill-library copied to clipboard
Albanian locale is not included for Chrome
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):

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:

So -- not really sure what I should do to make this work as expected.
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?
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":

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":

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?
@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.
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
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
@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.