question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Safari 14 Intl.NumberFormat usage throwing "Error: locale data nu must be an object"

See original GitHub issue

Bug Report

What

Trying to initialize an Intl.NumberFormat object in Safari 14 with the latest version of the polyfill loaded throws an exception.

Details

Browser Safari (Desktop) Version 14.0 (15610.1.28.1.9, 15610)

Minimal code example https://jsbin.com/xikuwesiru/edit?html,console

<script src="https://polyfill.io/v3/polyfill.min.js?features=Intl.~locale.ja" crossorigin></script>

<script>
  const nf = new Intl.NumberFormat();
  console.log(nf.format(1e3));
</script>

Expected result Console logs: 1,000 Screen Shot 2020-10-03 at 13 22 56

Actual result Error: locale data nu must be an object is thrown. Screen Shot 2020-10-03 at 13 23 31

Possible workaround for users of pollyfill.io service Set the library to an earlier version without these polyfills: (i.e. https://polyfill.io/v3/polyfill.min.js?features=Intl.~locale.ja&version=3.89.4)

More info

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeChampioncommented, Oct 13, 2020

@longlho and @romainmenke thank you for taking the time to handle this issue 👍

1reaction
Calveincommented, Oct 7, 2020

I have the same issue in Safari 13 with RelativeTimeFormat and fixing the version to 3.89.4 (I tried every versions between 3.89.4 & 3.96.0) also fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intl.NumberFormat() constructor - JavaScript - MDN Web Docs
The Intl.NumberFormat() constructor creates Intl.NumberFormat objects that enable language-sensitive number formatting.
Read more >
Why doesn't Intl.NumberFormat work with units in Safari and ...
The problem comes from the value unit of the style field. According to ECMA-402, 6th edition, June 2019 ECMAScript® 2019 ...
Read more >
Generated Content by David Storey - RSSing.com
These share a common parent Intl object. One way to localise a string, number, or date is to use the relevant object's constructor,...
Read more >
Number.prototype.toLocaleString() - JavaScript
This tests for a global Intl object, checks that it's not null and that it has a NumberFormat property that is a function....
Read more >
How To Correctly Polyfill Intl Locale Data - ADocLib
Returns a new object with properties reflecting the locale and collation ... Safari 14 Intl.NumberFormat usage throwing Error: locale data nu must be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found