The Intl.Locale.prototype.toString() returns the Locale's full locale identifier string.



Return value

The locale's Unicode locale identifier string.


The locale object is a JavaScript representation of a concept Unicode locale identifier. Information about a particular locale (language, script, calendar type, etc.) can be encoded in a locale identifier string. To make it easier to work with these locale identifiers, the locale object was introduced to JavaScript. Calling the toString method on a Locale object will return the identifier string for that particular Locale. The toString method allows locale instances to be provided as an argument to existing Intl constructors, serialized in JSON, or any other context where an exact string representation is useful.


Using toString

let myLocale = new Intl.Locale("fr-Latn-FR", {hourCycle: "h24", calendar: "gregory"});
console.log(myLocale.baseName); // Prints "fr-Latn-FR"
console.log(myLocale.toString()); // Prints "fr-Latn-FR-u-ca-gregory-hc-h24"


ECMAScript Internationalization API Specification (ECMAScript Internationalization API)
# sec-Intl.Locale.prototype.toString

Browser compatibility

BCD tables only load in the browser

See also