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

Set usage isn't IE11-safe #2529

Closed
devnix opened this issue Jan 22, 2021 · 13 comments
Closed

Set usage isn't IE11-safe #2529

devnix opened this issue Jan 22, 2021 · 13 comments
Labels

Comments

@devnix
Copy link

devnix commented Jan 22, 2021

Hi. I'm literally getting a Missing locale data for without more info, it's literally that message in IE11.

Tested code:

new Date().toLocaleString("es", {timeZone: "MADRID/EUROPE"});

Added dependencies:

import '@formatjs/intl-getcanonicallocales/polyfill';
import '@formatjs/intl-locale/polyfill';

import '@formatjs/intl-pluralrules/polyfill'
import '@formatjs/intl-pluralrules/locale-data/en' // locale-data for en

import '@formatjs/intl-numberformat/polyfill'
import '@formatjs/intl-numberformat/locale-data/en' // locale-data for en

import '@formatjs/intl-datetimeformat/polyfill'
import '@formatjs/intl-datetimeformat/add-all-tz' // Add ALL tz data

Is there something I'm missing from the docs? I've been banging my head on the keyboard for hours.

@devnix devnix added the bug label Jan 22, 2021
@longlho
Copy link
Member

longlho commented Jan 22, 2021

You have to add es locale data instead of en. Your timezone also isn't valid

@devnix
Copy link
Author

devnix commented Jan 22, 2021

@longlho Already tried importing @formatjs/intl-pluralrules/locale-data/es and @formatjs/intl-numberformat/locale-data/es with same results. Also with new Date().toLocaleString("en", {timeZone: "MADRID/EUROPE"}); with both required.

Not specifying a timezone (I'm using this polyfill just for that feature that works on Chrome and other browsers) has the same problem: new Date().toLocaleString("es");

What annoys me more is that white space at the end of the error string:
image

@longlho
Copy link
Member

longlho commented Jan 23, 2021

Do u have a reproducible repo of some sort? Can you use Intl.DateTimeFormat? Date.toLocaleString is significantly slower.

@devnix
Copy link
Author

devnix commented Jan 25, 2021

@longlho same Missing locale data for

@longlho
Copy link
Member

longlho commented Jan 25, 2021

oh u didn't add any locale data for intl-datetimeformat...

@devnix
Copy link
Author

devnix commented Jan 25, 2021

@longlho Didn't I? Look at the last line of the first post:

import '@formatjs/intl-datetimeformat/add-all-tz' // Add ALL tz data

@longlho
Copy link
Member

longlho commented Jan 25, 2021

That's timezone data which is separate from locale-data. See https://formatjs.io/docs/polyfills/intl-datetimeformat#simple

@devnix
Copy link
Author

devnix commented Jan 25, 2021

Oh no... Will test it tomorrow.

Is there any way to load the browser locale automatically?

Thanks for your patience @longlho

@devnix devnix closed this as completed Jan 25, 2021
@longlho
Copy link
Member

longlho commented Jan 25, 2021

Unfortunately we do not get access to browser default locale due to fingerprinting privacy issue.

@devnix
Copy link
Author

devnix commented Jan 26, 2021

@longlho So now it's working, but it does not find the timezone
image
It should work with this configuration, right?

import '@formatjs/intl-getcanonicallocales/polyfill';
import '@formatjs/intl-locale/polyfill';

import '@formatjs/intl-pluralrules/polyfill'
import '@formatjs/intl-pluralrules/locale-data/en' // locale-data for en

import '@formatjs/intl-numberformat/polyfill'
import '@formatjs/intl-numberformat/locale-data/en' // locale-data for en

import '@formatjs/intl-datetimeformat/polyfill'
import '@formatjs/intl-datetimeformat/locale-data/en' // locale-data for en
import '@formatjs/intl-datetimeformat/add-all-tz' // Add ALL tz data

@longlho
Copy link
Member

longlho commented Jan 26, 2021

hmm I can't reproduce this. Do you have a reproducible repo? What versions of things are you using?

@boschni
Copy link

boschni commented Jan 26, 2021

I was running into the same issue on IE11 and tracked it down to https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/IsValidTimeZoneName.ts .

A Set instance is created by providing an iterable to the constructor, which is not supported in IE11. You can get it working by adding a Set polyfill.

Might be good to change the IsValidTimeZoneName implementation or to mention this dependency at https://formatjs.io/docs/guides/runtime-requirements ?

@longlho
Copy link
Member

longlho commented Jan 26, 2021

thanks for the info @boschni that's something we can fix on our side

@longlho longlho changed the title "Missing locale data for" Set usage isn't IE11-safe Jan 26, 2021
@longlho longlho reopened this Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants