recursal/MDN huggingface dataset:
Intl.Locale.prototype.getCalendars()
====================================

The **`getCalendars()`** method of `Intl.Locale` instances returns a list of one or more unique calendar identifiers for this locale.

**Note:** In some versions of some browsers, this method was implemented as an accessor property called `calendars`. However, because it returns a new array on each access, it is now implemented as a method to prevent the situation of `locale.calendars === locale.calendars` returning `false`. Check the browser compatibility table for details.

Syntax
------


```js
getCalendars()
```

### Parameters

None.

### Return value

An array of strings representing all calendars commonly used for the `Locale`, sorted in descending preference. If the `Locale` already has a `calendar`, then the returned array contains that single value.

Below is a list of the supported calendar era types.

### Supported calendar types

`buddhist`

Thai Buddhist calendar

`chinese`

Traditional Chinese calendar

`coptic`

Coptic calendar

`dangi`

Traditional Korean calendar

`ethioaa`

Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E)

`ethiopic`

Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.)

`gregory`

Gregorian calendar

`hebrew`

Traditional Hebrew calendar

`indian`

Indian calendar

`islamic`

Islamic calendar

`islamic-umalqura`

Islamic calendar, Umm al-Qura

`islamic-tbla`

Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch)

`islamic-civil`

Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch)

`islamic-rgsa`

Islamic calendar, Saudi Arabia sighting

`iso8601`

ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules)

`japanese`

Japanese Imperial calendar

`persian`

Persian calendar

`roc`

Civil (algorithmic) Arabic calendar

`islamicc`

Civil (algorithmic) Arabic calendar

**Warning:** The `islamicc` calendar key has been deprecated. Please use `islamic-civil`.

Examples
--------

### Obtaining supported calendars

If the `Locale` object doesn't have a `calendar` already, `getCalendars()` lists all commonly-used calendars for the given `Locale`. For examples of explicitly setting a `calendar`, see `calendar` examples.


```js
const arEG = new Intl.Locale("ar-EG");
console.log(arEG.getCalendars()); // ["gregory", "coptic", "islamic", "islamic-civil", "islamic-tbla"]
```



```js
const jaJP = new Intl.Locale("ja-JP");
console.log(jaJP.getCalendars()); // ["gregory", "japanese"]
```

Specifications
--------------

| Specification |
| --- |
| Intl Locale Info Proposal # sec-Intl.Locale.prototype.getCalendars |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.calendar`
* Unicode Calendar Identifier in the Unicode locale data markup language spec
Intl.Locale.prototype.toString()
================================

The **`toString()`** method of `Intl.Locale` instances returns this Locale's full locale identifier string.

Try it
------

Syntax
------


```js
toString()
```

### Parameters

None.

### Return value

The *locale*'s Unicode locale identifier string.

Description
-----------

 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.

Examples
--------

### Using toString


```js
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"
```

Specifications
--------------

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

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* `baseName`
Intl.Locale.prototype.calendar
==============================

The **`calendar`** accessor property of `Intl.Locale` instances returns the calendar type for this locale.

Description
-----------

While most of the world uses the Gregorian calendar, there are several regional calendar eras used around the world. The `calendar` property's value is set at construction time, either through the `ca` key of the locale identifier or through the `calendar` option of the `Intl.Locale()` constructor. The latter takes priority if they are both present; and if neither is present, the property has value `undefined`.

For a list of supported calendar types, see `Intl.Locale.prototype.getCalendars()`.

The set accessor of `calendar` is `undefined`. You cannot change this property directly.

Examples
--------

Like other locale subtags, the calendar type can be added to the `Intl.Locale` object via the locale string, or a configuration object argument to the constructor.

### Adding a calendar type via the locale string

In the Unicode locale string spec, calendar era types are locale key "extension subtags". These subtags add additional data about the locale, and are added to locale identifiers by using the `-u` extension. Thus, the calendar era type can be added to the initial locale identifier string that is passed into the `Intl.Locale()` constructor. To add the calendar type, first add the `-u` extension to the string. Next, add the `-ca` extension to indicate that you are adding a calendar type. Finally, add the calendar era type to the string.


```js
const locale = new Intl.Locale("fr-FR-u-ca-buddhist");
console.log(locale.calendar); // Prints "buddhist"
```

### Adding a calendar type via the configuration object argument

The `Intl.Locale()` constructor has an optional configuration object argument, which can contain any of several extension types, including calendars. Set the `calendar` property of the configuration object to your desired calendar era, and then pass it into the constructor.


```js
const locale = new Intl.Locale("fr-FR", { calendar: "buddhist" });
console.log(locale.calendar); // "buddhist"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.calendar |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.getCalendars()`
* Unicode Calendar Identifier in the Unicode locale data markup language spec
Intl.Locale.prototype.caseFirst
===============================

The **`caseFirst`** accessor property of `Intl.Locale` instances returns whether case is taken into account for this locale's collation rules.

Description
-----------

A locale's collation rules are used to determine how strings are ordered in that locale. Certain locales use a character's case (UPPERCASE or lowercase) in the collation process. This additional rule can be expressed in a `Intl.Locale` object's `caseFirst` property.

There are 3 values that the `caseFirst` property can have, outlined in the table below.

### `caseFirst` values

| Value | Description |
| --- | --- |
| `upper` | Upper case to be sorted before lower case. |
| `lower` | Lower case to be sorted before upper case. |
| `false` | No special case ordering. |

Examples
--------

### Setting the caseFirst value via the locale string

In the Unicode locale string spec, the values that `caseFirst` represents correspond to the key `kf`. `kf` is treated as a locale string "extension subtag". These subtags add additional data about the locale, and are added to locale identifiers by using the `-u` extension key. Thus, the `caseFirst` value can be added to the initial locale identifier string that is passed into the `Locale` constructor. To add the `caseFirst` value, first add the `-u` extension key to the string. Next, add the `-kf` extension key to indicate that you are adding a value for `caseFirst`. Finally, add the `caseFirst` value to the string.


```js
const locale = new Intl.Locale("fr-Latn-FR-u-kf-upper");
console.log(locale.caseFirst); // Prints "upper"
```

### Setting the caseFirst value via the configuration object argument

The `Intl.Locale()` constructor has an optional configuration object argument, which can be used to pass extension types. Set the `caseFirst` property of the configuration object to your desired `caseFirst` value, and then pass it into the constructor.


```js
const locale = new Intl.Locale("en-Latn-US", { caseFirst: "lower" });
console.log(locale.caseFirst); // Prints "lower"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.caseFirst |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* Unicode case first collation spec
Intl.Locale.prototype.getWeekInfo()
===================================

The **`getWeekInfo()`** method of `Intl.Locale` instances returns a `weekInfo` object with the properties `firstDay`, `weekend` and `minimalDays` for this locale.

**Note:** In some versions of some browsers, this method was implemented as an accessor property called `weekInfo`. However, because it returns a new object on each access, it is now implemented as a method to prevent the situation of `locale.weekInfo === locale.weekInfo` returning `false`. Check the browser compatibility table for details.

Syntax
------


```js
getWeekInfo()
```

### Parameters

None.

### Return value

An object representing week information associated with the Locale data specified in UTS 35's Week Elements. It has the following properties:

`firstDay`

An integer indicating the first day of the week for the locale. Can be either `1` (Monday) or `7` (Sunday).

`weekend`

An array of integers indicating the weekend days for the locale, where `1` is Monday and `7` is Sunday.

`minimalDays`

An integer between 1 and 7 indicating the minimal days required in the first week of a month or year, for calendar purposes.

Examples
--------

### Obtaining the Week Information

Return the week information for a given `Locale`.


```js
const he = new Intl.Locale("he");
console.log(he.getWeekInfo()); // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }

const af = new Intl.Locale("af");
console.log(af.getWeekInfo()); // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }

const enGB = new Intl.Locale("en-GB");
console.log(enGB.getWeekInfo()); // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }

const msBN = new Intl.Locale("ms-BN");
console.log(msBN.getWeekInfo()); // { firstDay: 7, weekend: [5, 7], minimalDays: 1 }
// Brunei weekend is Friday and Sunday but not Saturday
```

Specifications
--------------

| Specification |
| --- |
| Intl Locale Info Proposal # sec-Intl.Locale.prototype.getWeekInfo |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
Intl.Locale.prototype.region
============================

The **`region`** accessor property of `Intl.Locale` instances returns the region of the world (usually a country) associated with this locale.

Description
-----------

The region is an essential part of the locale identifier, as it places the locale in a specific area of the world. Knowing the locale's region is vital to identifying differences between locales. For example, English is spoken in the United Kingdom and the United States of America, but there are differences in spelling and other language conventions between those two countries. Knowing the locale's region helps JavaScript programmers make sure that the content from their sites and applications is correctly displayed when viewed from different areas of the world.

Examples
--------

### Setting the region in the locale identifier string argument

The region is the third part of a valid Unicode language identifier string, and can be set by adding it to the locale identifier string that is passed into the `Intl.Locale()` constructor. The region is a mandatory part of a


```js
const locale = new Intl.Locale("en-Latn-US");
console.log(locale.region); // Prints "US"
```

### Setting the region via the configuration object

The `Intl.Locale()` constructor takes a configuration object, which can be used to set the region subtag and property.


```js
const locale = new Intl.Locale("fr-Latn", { region: "FR" });
console.log(locale.region); // Prints "FR"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.region |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* Unicode region chart
Intl.Locale.prototype.numberingSystem
=====================================

The **`numberingSystem`** accessor property of `Intl.Locale` instances returns the numeral system for this locale.

Description
-----------

A numeral system is a system for expressing numbers. The `numberingSystem` property's value is set at construction time, either through the `nu` key of the locale identifier or through the `numberingSystem` option of the `Intl.Locale()` constructor. The latter takes priority if they are both present; and if neither is present, the property has value `undefined`.

For a list of supported numbering system types, see `Intl.Locale.prototype.getNumberingSystems()`.

Examples
--------

Like other locale subtags, the numbering system type can be added to the `Intl.Locale` object via the locale string, or a configuration object argument to the constructor.

### Adding a numbering system via the locale string

In the Unicode locale string spec, numbering system types are locale key "extension subtags". These subtags add additional data about the locale, and are added to locale identifiers by using the `-u` extension. Thus, the numbering system type can be added to the initial locale identifier string that is passed into the `Intl.Locale()` constructor. To add the numbering system type, first add the `-u` extension key to the string. Next, add the `-nu` extension to indicate that you are adding a numbering system. Finally, add the numbering system type to the string.


```js
const locale = new Intl.Locale("fr-Latn-FR-u-nu-mong");
console.log(locale.numberingSystem); // "mong"
```

### Adding a numbering system via the configuration object argument

The `Intl.Locale()` constructor has an optional configuration object argument, which can contain any of several extension types, including numbering system types. Set the `numberingSystem` property of the configuration object to your desired numbering system type, and then pass it into the constructor.


```js
const locale = new Intl.Locale("en-Latn-US", { numberingSystem: "latn" });
console.log(locale.numberingSystem); // "latn"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.numberingSystem |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.getNumberingSystems()`
* Details on the standard Unicode numeral systems
Intl.Locale.prototype.baseName
==============================

The **`baseName`** accessor property of `Intl.Locale` instances returns a substring of this locale's string representation, containing core information about this locale.

Description
-----------

An `Intl.Locale` object represents a parsed local and options for that locale. The `baseName` property returns basic, core information about the Locale in the form of a substring of the complete data string. Specifically, the property returns the substring containing the language, and the script and region if available.

`baseName` returns the `language ["-" script] ["-" region] *("-" variant)` subsequence of the unicode\_language\_id grammar.

Examples
--------

### Basic Example


```js
const myLoc = new Intl.Locale("fr-Latn-CA"); // Sets locale to Canadian French
console.log(myLoc.toString()); // Prints out "fr-Latn-CA-u-ca-gregory"
console.log(myLoc.baseName); // Prints out "fr-Latn-CA"
```

### Example with options in the input string


```js
// Sets language to Japanese, region to Japan,

// calendar to Gregorian, hour cycle to 24 hours
const japan = new Intl.Locale("ja-JP-u-ca-gregory-hc-24");
console.log(japan.toString()); // Prints out "ja-JP-u-ca-gregory-hc-h24"
console.log(japan.baseName); // Prints out "ja-JP"
```

### Example with options that override input string


```js
// Input string indicates language as Dutch and region as Belgium,

// but options object overrides the region and sets it to the Netherlands
const dutch = new Intl.Locale("nl-Latn-BE", { region: "NL" });

console.log(dutch.baseName); // Prints out "nl-Latn-NL"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.baseName |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
Intl.Locale.prototype.script
============================

The **`script`** accessor property of `Intl.Locale` instances returns the script used for writing the particular language used in this locale.

Description
-----------

A script, sometimes called writing system, is one of the core attributes of a locale. It indicates the set of symbols, or glyphs, that are used to write a particular language. For instance, the script associated with English is Latin, whereas the script typically associated with Korean is Hangul. In many cases, denoting a script is not strictly necessary, since the language (which is necessary) is only written in a single script. There are exceptions to this rule, however, and it is important to indicate the script whenever possible, in order to have a complete Unicode language identifier.

Examples
--------

### Setting the script in the locale identifier string argument

The script is the second part of a valid Unicode language identifier string, and can be set by adding it to the locale identifier string that is passed into the `Intl.Locale()` constructor. Note that the script is not a required part of a locale identifier.


```js
const locale = new Intl.Locale("en-Latn-US");
console.log(locale.script); // Prints "Latn"
```

### Setting the script via the configuration object

The `Intl.Locale()` constructor takes a configuration object, which can be used to set the script subtag and property.


```js
const locale = new Intl.Locale("fr-FR", { script: "Latn" });
console.log(locale.script); // Prints "Latn"
```

Specifications
--------------

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.Locale.prototype.script |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* Unicode script subtag in the Unicode locale data markup language spec
Intl.Locale.prototype.getTimeZones()
====================================

The **`getTimeZones()`** method of `Intl.Locale` instances returns a list of supported time zones for this locale.

**Note:** In some versions of some browsers, this method was implemented as an accessor property called `timeZones`. However, because it returns a new array on each access, it is now implemented as a method to prevent the situation of `locale.timeZones === locale.timeZones` returning `false`. Check the browser compatibility table for details.

Syntax
------


```js
getTimeZones()
```

### Parameters

None.

### Return value

An array of strings representing supported time zones for the associated `Locale`, where each value is an IANA time zone canonical name, sorted in alphabetical order. If the locale identifier does not contain a region subtag, the returned value is `undefined`.

Examples
--------

### Obtaining supported time zones

List supported time zones for a given `Locale`.


```js
const arEG = new Intl.Locale("ar-EG");
console.log(arEG.getTimeZones()); // ["Africa/Cairo"]
```



```js
const jaJP = new Intl.Locale("ja-JP");
console.log(jaJP.getTimeZones()); // ["Asia/Tokyo"]
```



```js
const ar = new Intl.Locale("ar");
console.log(ar.getTimeZones()); // undefined
```

Specifications
--------------

| Specification |
| --- |
| Intl Locale Info Proposal # sec-Intl.Locale.prototype.getTimeZones |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`
* IANA time zone database on Wikipedia
Intl.Locale.prototype.getTextInfo()
===================================

The **`getTextInfo()`** method of `Intl.Locale` instances returns the ordering of characters indicated by either `ltr` (left-to-right) or by `rtl` (right-to-left) for this locale.

**Note:** In some versions of some browsers, this method was implemented as an accessor property called `textInfo`. However, because it returns a new object on each access, it is now implemented as a method to prevent the situation of `locale.textInfo === locale.textInfo` returning `false`. Check the browser compatibility table for details.

Syntax
------


```js
getTextInfo()
```

### Parameters

None.

### Return value

An object representing text typesetting information associated with the Locale data specified in UTS 35's Layouts Elements. It has the following properties:

`direction`

A string indicating the direction of text for the locale. Can be either `"ltr"` (left-to-right) or `"rtl"` (right-to-left).

Examples
--------

### Obtaining text info

Return the supported text directions for a given `Locale`.


```js
const ar = new Intl.Locale("ar");
console.log(ar.getTextInfo()); // { direction: "rtl" }
console.log(ar.getTextInfo().direction); // "rtl"
```



```js
const es = new Intl.Locale("es");
console.log(es.getTextInfo()); // { direction: "ltr" }
console.log(es.getTextInfo().direction); // "ltr"
```

Specifications
--------------

| Specification |
| --- |
| Intl Locale Info Proposal # sec-Intl.Locale.prototype.getTextInfo |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Intl.Locale`