Skip to content
Advertisement

Invalid unit argument for Intl.NumberFormat() with electric units (volt, joule…)

I am trying to localize my web application and I cannot manage to make Intl.NumberFormat work with electric units (ampere, ohm, volt, joule…).

In the documentation, they provide some examples and the list of units available.

Though I cannot manage to make it work with the electric units:

JavaScript

Does someone have an idea why?

Advertisement

Answer

From MDN INTL

A subset of units from the full list was selected for use in ECMAScript.

JavaScript

Pairs of simple units can be concatenated with “-per-” to make a compound unit. There is no default value; if the style is “unit”, the unit property must be provided.

Très cool: Megabytes per second becomes mégaoctets par seconde in French

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement