The toString() method of Intl.Locale instances returns this Locale's full locale identifier string.
The toString() method of Intl.Locale instances returns this Locale's full locale identifier string.
toString()
None.
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.
const myLocale = new Intl.Locale("fr-Latn-FR", { hourCycle: "h12", calendar: "gregory", }); console.log(myLocale.baseName); // Prints "fr-Latn-FR" console.log(myLocale.toString()); // Prints "fr-Latn-FR-u-ca-gregory-hc-h12"
| Specification |
|---|
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.toString |
| Desktop | Mobile | Server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
toString |
74 | 79 | 75 | 62 | 14 | 74 | 79 | 53 | 14 | 11.0 | 74 | 1.8 | 12.0.0 | |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/toString