Questions tagged [ecmascript-intl]

ECMAScript Internationalization API

The ECMAScript Internationalization API (ECMA-402) is a series of extensions to the ECMAScript language to add support for various locale-specific formatting of numbers and dates, as well as the comparison of different Unicode strings.

It does so by providing a new Intl global object to work with, as well as providing firmer specification and new arguments to methods which were previously implementation-defined, such as Number.prototype.toLocaleString.

40 questions
34
votes
2 answers

Chrome timeZone option to Date.toLocaleString()

I have recently discovered that there is a new extension to JavaScript. This adds several features to the Date object in the toLocaleString, toLocaleDateString and toLocaleTimeString functions. Reference here. I am particularly interested in the…
19
votes
1 answer

Getting Timezone using Intl API doesn't work in Firefox:

I am using the Intl API. In Chrome: Intl.DateTimeFormat().resolved.timeZone Returns "Europe/London" In Firefox this return undefined, even though Firefox supports Intl. How can I get a timezone with Firefox?
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
19
votes
4 answers

Is there an i18n (Intl) shim for JavaScript?

I am looking for a shim for the ECMAScript Internationalization API. Does anyone know of such a project? (Even if it's still currently a work-in-progress.)
16
votes
7 answers

How to get the weekday names using Intl?

I'd like to display in my i18n-ed app a list of the 7 weekdays: Sunday, Monday, Tuesday... Saturday I rely on the Intl global object for formatting date/time but I can't find an easy way to get only the weekday names. I thought I could add some…
gpbl
  • 4,721
  • 5
  • 31
  • 45
13
votes
2 answers

Space after symbol with JS Intl

I want to format a currency with NumberFormat of Intl and get the returned value with a space " " between the symbol and the number. new Intl.NumberFormat('pt-br', { style: 'currency', currency: 'USD' }).format(12345) // "US$12.345,00" new…
11
votes
1 answer

What is the relation between Number.prototype.toLocaleString() and Intl.NumberFormat.prototype.format?

We are trying to use localization support in our application and looking at the toLocaleString(). We also had a look at Intl.NumberFormat and its format method. Do they have any relation? Which one is better to use?
11
votes
2 answers

Javascript Internationalization API is not supported by PhantomJS

I have series of Jasmine tests running against an AngularJs service that uses ECMAScript Internationalization API. They all run successfully when I run them through Chrome. However, when I use PhantomJS to run them through maven, they all fail as…
10
votes
3 answers

"Intl not available" in Edge 15

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…
rogerkk
  • 5,494
  • 5
  • 37
  • 53
10
votes
2 answers

First day of week from HTML5 Intl API

Is there a way to get the first day of the week (Sunday or Monday for most countries) from the HTML5 internationalization API? The spec can be found here. I would be surprised if it's not somehow disclosed, but I can't seem to find where.
David Mulder
  • 26,123
  • 9
  • 51
  • 114
9
votes
1 answer

Where does Intl API get it's time zone list?

I'm relying on Intl to determine user's time zone. I also want to give users a way to pick their timezone. I have a list of time zones -- some subset of Olson database. I wanna make sure Intl won't give me some weird time zone I don't have in my…
skfd
  • 2,528
  • 1
  • 19
  • 29
7
votes
1 answer

Invalid time zone specified: US/Alaska, US/Arizona, US/Mountain, US/Central etc error in Chrome but working in Mozilla

I am trying to convert timestamp in to various time zone's local time and found certain TimeZone are not supporting in Chrome (v76.0.38) but working fine in Mozilla (v68.0.2). let d = new Date(1567083463); let n = d.toLocaleString('en-GB', {…
kiran goud
  • 803
  • 2
  • 10
  • 17
6
votes
2 answers

Intl.Collator and natural sort with numeric option sorts incorrectly with decimal numbers

Sorting decimal numbers using Intl.Collator and the option to enable numeric compares decimals incorrectly. On some browsers comparing "0.005" and "0.05" returns "0" as in the numbers are the same. Results in different browsers: Chrome 54 =…
Nisd
  • 1,068
  • 9
  • 19
6
votes
2 answers

Is there a way to get the decimal and thousands separator in ECMAscript Internationalization API?

I'm trying to use the new Javascript internationalization API, and would like to know if there is a way to get the decimal and thousands (grouping) separator for a Intl.NumberFormat instance? There is a resolvedOptions method on the object, but that…
4
votes
2 answers

Has Chrome stopped supporting Intl function?

I am using chrome browser (Version 92.0.4515.131). I found that the support for JavaScript Intl is not functioning properly in Chrome browser. const formattedDate = new Intl.DateTimeFormat('nb-NO', { "year": "numeric", "month": "2-digit", …
D.Waasala
  • 145
  • 6
4
votes
2 answers

Javascript Intl DatetimeFormatter as (ISO_8601|custom) output pattern

I want to use Intl.DateTimeFormat but with custom pattern for output. I use this method for php version of ICU dateformat and it's work well. $fmt = datefmt_create( 'fa_IR@calendar=persian', IntlDateFormatter::FULL, …
1
2 3