10

I'm seeing an Intl not available error in the JS console when my script runs the following code in Edge 15:

new Date().toLocaleDateString()

I'm a bit stumped by this. It is working just fine in Edge 14, and I can't find any reference to the internationalization API suddenly disappearing from Edge 15.

I'm not sure if this is the proper way to test it, but running window.hasOwnProperty("Intl") in the console actually returns true. To me this seems to indicate that Intl actually is there.

Anyone with more JS skills able to tell what is really going on here?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
rogerkk
  • 5,494
  • 5
  • 37
  • 53
  • [*toLocaleDateString*](http://ecma-international.org/ecma-262/7.0/index.html#sec-date.prototype.tolocaledatestring) is actually part of ECMAScript (ECMA-262) so the error message is bogus. Support for the Intl object ([ECMA-402](http://www.ecma-international.org/ecma-402/1.0/#sec-8)) is required for support of the optional parameters. – RobG Jun 01 '17 at 09:28
  • FWIW: Both `new Date().toLocaleDateString()` and stuff like `new Date().toLocaleString('no-NB', {weekday: 'long'})` returns that same error. :/ – rogerkk Jun 01 '17 at 09:35
  • 1
    Norsk again...... it seems to be a problem language/culture..... try adding a lang/xmllang attribute to the html tag AND include a http-equivalent content-language meta tag to your page. – Rob Parsons Jun 04 '17 at 19:30
  • 1
    Thanks Rob. I already have a , and the way I understand it Content-Language on meta http-equiv should not be used at all? See w3.org/International/questions/qa-http-and-lang#quickanswer – rogerkk Jun 06 '17 at 10:04
  • 1
    Just checked in Edge, no such problem (Edge 40.15063.0.0). Maybe there was a bug? – Zero Jun 06 '17 at 15:12
  • 1
    try lang="nb" , see my answer at https://stackoverflow.com/questions/42576222/automatic-soft-hyphenation-in-css/42713047#42713047. The http-equivalent content-language of "no" is for google translate which seems to require a content-language value for the from language query parameter. – Rob Parsons Jun 10 '17 at 09:30
  • @Zero Thanks for checking. That is unfortunately exactly the same version I'm using (via BrowserStack), so I guess something else must be different here. :/ – rogerkk Jun 12 '17 at 12:25
  • @RobParsons Thanks for that tip, I wasn't aware of this. I've changed it now, but unfortunately still getting exactly the same error. – rogerkk Jun 12 '17 at 12:26
  • Can you test on a real browser or provide a reproduction url..... seems to me its a browserStack issue.. usually Edge console messages are proceeded with a code eg. JS1024... mashups like js fiddle are not suitable as you cannot specify the content language. If it is a BS issue then I guess other browsers would should show the same issue. – Rob Parsons Jun 12 '17 at 22:08
  • on my local Edge (mshtml: 15.15063) (new Date().toLocaleString('no-bok', {weekday: 'long'}) returns "‎tirsdag" , new Date().toLocaleString('no-nyn', {weekday: 'long'}) returns "‎tysdag" while new Date().toLocaleString('no-NB', {weekday: 'long'}) returns "Tuesday"... ref: https://tools.ietf.org/html/rfc5646 – Rob Parsons Jun 12 '17 at 22:46

3 Answers3

3

Make sure your JS code doesn't redefine standard Map class.

We had almost the same problem, but with Intl.Collator object instead. We couldn't use String.prototype.localeCompare("...", "locale") because of this.

You can look at this codepen in Edge 15 and in other browsers for explanation: https://codepen.io/kgorob/pen/pweaWV.

P.S. I'm not sure your problem is because of Map class specifically, maybe it's some other standard JS class you are re-defining.

  • http://jsbin.com/yejafopiza/edit?js,console This is totally it, thanks! :) – lpd Jun 20 '17 at 07:34
  • This was exactly the problem in my case. I had indeed redefined Map for some custom Google Maps integration, and was not aware that this would cause problems elsewhere. For some reason the load order seems to be different in Edge 15 than anywhere else. Thanks a lot! – rogerkk Jun 29 '17 at 08:33
1

The problem is because of these lines in Chakracore code. Intl.js is javascript file that is used internally to perform various internationalization specific operations. Since Mapis used, over-writing it before Intl.js code executes (it is executed lazily), causes problem. This should be addressed soon.

ksp
  • 132
  • 1
  • 5
0

As ksp's answer says, this is caused by Intl lazy-loading after Map is overwritten. Therefore, the easiest workaround is to just force it to initialise early, before other scripts run:

<html>
  <head>
  <script>Intl.DateTimeFormat</script>
  ...

Here is the issue in the Chakra repo: https://github.com/Microsoft/ChakraCore/issues/3189

lpd
  • 2,151
  • 21
  • 29