Open 1ec5 opened 2 years ago
locale-utils:
let locale = utils.parseLocaleIntoCodes("es-MX");
// {
// locale: "es-MX",
// language: "es",
// script: undefined,
// region: "MX"
// }
Intl
:
let locale = new Intl.Locale("es-MX");
locale.toLocaleString(); // "es-MX"
locale.language; // "es"
locale.script; // undefined
locale.region; // "MX"
parseLocaleIntoCodes()
is now redundant toIntl.Locale
and its properties likelanguage
, which has been supported by Node.js since v12.0.0.Intl.getCanonicalNames()
is also useful in some of the same use cases. We should deprecate or removeparseLocaleIntoCodes()
, because it’s probably less robust than the ICU-backed methods built into ECMAScript.