Current versions of the major browsers integrate the ECMAScript Internationalization API within their JavaScript implementations.
This API allows you to convert dates, times and numbers into strings and offers some functions for language sensitive string comparision. It is available through the Intl
object.
E.g. it allows to format the float number 10.2
as 10,20 €
using the following code:
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(10.2)
Though the first version of this API is limited to output formatting. It doesn't provide functions for normalization of language specific input.
For locale specific numerical input you can use the <input>
tag like this:
<input type="number" step="0.01" lang="de">
Where the value of the lang
attribute defines the language and how the value within the input is displayed and interpreted. Though note that this is not supported by all major browsers. Mainly Internet Explorer up to version 11 doesn't handle the input as expected.