The Intl API (Internationalization API) in Chromium-based browsers follows the Unicode standard for formatting currencies, specifically the Unicode Technical Standard #35: Unicode locale data markup language (UTS #35). This standard provides guidelines for how currencies should be formatted in different locales, including the use of commas versus dots for the thousand separator.
The Unicode standard defines a set of locale data that includes information about currency formatting, such as the symbol used for the currency, the digits used for numbers, and the symbols used for grouping numbers (thousand separators). This data is used by the Intl API when formatting currency values.
For example, in English-speaking countries like the United States, the standard is to use a period (".") as the thousand separator and a comma (",") as the decimal separator. In other countries, such as those in the European Union, the opposite is true: a comma (",") is used as the thousand separator, and a period (".") is used as the decimal separator.
When you use the Intl.NumberFormat object to format currency, you can specify the locale using the locale or localeMatcher parameter. The Intl API will then use the Unicode locale data to determine the correct formatting for that locale, including the separator for thousands.
Here's an example of how to format currency using the Intl.NumberFormat with the correct separators for a specific locale:
// Assuming you have a number representing a currency value
const amount = 1000.50;
// Format the currency using the Intl.NumberFormat
const numberFormat = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
const formattedAmount = numberFormat.format(amount);
console.log(formattedAmount); // Output: $1,000.50
In this example, 'en-US' is the locale identifier for English in the United States, and 'USD' is the currency code for the United States dollar. The Intl.NumberFormat will use the Unicode locale data for 'en-US' to format the currency with the appropriate symbols and separators, which in this case is a comma for the thousand separator and a period for the decimal separator.
For more information on the Unicode locale data and how it is used in the Intl API, you can refer to the Unicode and ECMA Internationalization API specifications.