Loading...
const format = new Intl.NumberFormat('en_US');
format.format(1234.5);const format = new Intl.NumberFormat('en-US');
format.format(1234.5);BCP 47 tags use hyphens; an underscore like 'en_US' makes Intl throw a RangeError.
Read navigator.language for the top preference or navigator.languages for the full list, and let the user override it in settings.
Same language, different region: they differ in spelling, date order, units and currency, for example '3/4' versus '04/03' for the same date.
No. A locale adds region and sometimes script to a language, so 'pt-BR' and 'pt-PT' share a language but differ in words and formats.