Intl.Locale
Creates an Intl.Locale object that represents a Unicode locale identifier and provides access to locale data
Syntax
new Intl.Locale(tag, options?)Parameters
| Parameter | Type | Description |
|---|---|---|
| tag | string | A BCP 47 language tag string |
| options | Intl.LocaleOptions | Options: calendar, caseFirst, collation, hourCycle, numberingSystem, language, script, region |
Return Value
An Intl.Locale object with properties and methods for locale information
Examples
const locale = new Intl.Locale('en-US')
console.log(locale.language) // 'en'
console.log(locale.region) // 'US'const locale = new Intl.Locale('ja-JP', { calendar: 'japanese' })
console.log(locale.toString()) // 'ja-JP-u-ca-japanese'
console.log(locale.calendar) // 'japanese'const locale = new Intl.Locale('en-US')
console.log(locale.maximize().toString()) // 'en-Latn-US'
console.log(locale.minimize().toString()) // 'en'Understanding Intl.Locale
The Intl.Locale method in JavaScript creates an Intl.Locale object that represents a Unicode locale identifier and provides access to locale data. It belongs to the Intl object and is one of the most widely used methods for working with intl values in modern JavaScript and TypeScript applications.
The method signature is new Intl.Locale(tag, options?). It accepts 2 parameters: tag, options. When called, it returns an intl.locale object with properties and methods for locale information. Understanding when and how to use Locale() helps you write more expressive, readable code.
Common use cases for Intl.Locale include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-displaynames, intl-numberformat, intl-datetimeformat, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Intl.Locale is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Intl.DisplayNamesCreates an Intl.DisplayNames object that enables the consistent translation of language, region, and script display names
Intl.NumberFormatCreates an Intl.NumberFormat object that enables language-sensitive number formatting
Intl.DateTimeFormatCreates an Intl.DateTimeFormat object that enables language-sensitive date and time formatting
More Intl Methods
Other methods in the Intl object
Related Tools
More Intl Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.