recursal/MDN huggingface dataset:
Intl.Locale.prototype.numeric
=============================

The **`numeric`** accessor property of `Intl.Locale` instances returns whether this locale has special collation handling for numeric characters.

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

Like `caseFirst`, `numeric` represents a modification to the collation rules utilized by the locale. `numeric` is a boolean value, which means that it can be either `true` or `false`. If `numeric` is set to `false`, there will be no special handling of numeric values in strings. If `numeric` is set to `true`, then the locale will take numeric characters into account when collating strings. This special numeric handling means that sequences of decimal digits will be compared as numbers. For example, the string "A-21" will be considered less than "A-123".

Examples
--------

### Setting the numeric value via the locale string

In the Unicode locale string spec, the values that `numeric` represents correspond to the key `kn`. `kn` is considered 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 `numeric` value can be added to the initial locale identifier string that is passed into the `Intl.Locale()` constructor. To set the `numeric` value, first add the `-u` extension key to the string. Next, add the `-kn` extension key to indicate that you are adding a value for `numeric`. Finally, add the `numeric` value to the string. If you want to set `numeric` to `true`, adding the `kn` key will suffice. To set the value to `false`, you must specify in by adding `"false"` after the `kn` key.


```js
const locale = new Intl.Locale("fr-Latn-FR-u-kn-false");
console.log(locale.numeric); // Prints "false"
```

### Setting the numeric 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 `numeric` property of the configuration object to your desired `numeric` value and pass it into the constructor.


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

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

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

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

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

See also
--------

* `Intl.Locale`
Intl.Locale.prototype.minimize()
================================

 The **`minimize()`** method of `Intl.Locale` instances attempts to
 remove information about this locale that would be added by calling
 `maximize()`.

Try it
------

Syntax
------


```js
minimize()
```

### Parameters

None.

### Return value

 A `Intl.Locale` instance whose `baseName` property returns
 the result of the Remove Likely Subtags algorithm
 executed against *`locale.baseName`*.

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

 This method carries out the reverse of `maximize()`,
 removing any language, script, or region subtags from the locale language identifier
 (essentially the contents of `baseName`). This is useful when there are
 superfluous subtags in the language identifier; for instance, "en-Latn" can be
 simplified to "en", since "Latn" is the only script used to write English.
 `minimize()` only affects the main subtags that comprise
 the language identifier:
 language, script, and region subtags. Other subtags after the "-u"
 in the locale identifier are called extension subtags and are not affected by the
 `minimize()` method. Examples of these subtags include
 `hourCycle`, `calendar`, and `numeric`.

Examples
--------

### Using minimize


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

const myLocMinimized = myLocale.minimize();

// Prints "fr", since French is only written in the Latin script
// and is most likely to be spoken in France.
console.log(myLocMinimized.baseName);

// Prints "fr-u-ca-gregory-hc-h12".
// Note that the extension tags (after "-u") remain unchanged.
console.log(myLocMinimized.toString());
```

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

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

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.maximize()
================================

 The **`maximize()`** method of `Intl.Locale` instances gets the
 most likely values for the language, script, and region of this locale based on
 existing values.

Try it
------

Syntax
------


```js
maximize()
```

### Parameters

None.

### Return value

 A `Intl.Locale` instance whose `baseName` property returns
 the result of the Add Likely Subtags algorithm executed against *`locale.baseName`*.

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

 Sometimes, it is convenient to be able to identify the most likely locale language
 identifier subtags based on an incomplete language ID. The Add Likely Subtags
 algorithm gives us this functionality. For instance, given the language ID "en", the
 algorithm would return "en-Latn-US", since English can only be written in the Latin
 script, and is most likely to be used in the United States, as it is the largest
 English-speaking country in the world. This functionality is provided to JavaScript
 programmers via the `maximize()` method. `maximize()` only
 affects the main subtags that comprise the language identifier: language, script, and region subtags.
 Other subtags after the "-u" in the locale identifier are called extension subtags and
 are not affected by the `maximize()` method. Examples of these subtags
 include `hourCycle`,
 `calendar`, and `numeric`.

Examples
--------

### Using maximize


```js
const myLocale = new Intl.Locale("fr", {
  hourCycle: "h12",
  calendar: "gregory",
});
console.log(myLocale.baseName); // Prints "fr"
console.log(myLocale.toString()); // Prints "fr-u-ca-gregory-hc-h12"
const myLocMaximized = myLocale.maximize();

// Prints "fr-Latn-FR". The "Latn" and "FR" tags are added,
// since French is only written in the Latin script and is most likely to be spoken in France.
console.log(myLocMaximized.baseName);

// Prints "fr-Latn-FR-u-ca-gregory-hc-h12".
// Note that the extension tags (after "-u") remain unchanged.
console.log(myLocMaximized.toString());
```

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

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

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

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

See also
--------

* `Intl.Locale`
* `baseName`
* Likely Subtags in the Unicode locale data markup language spec
Intl.Locale.prototype.language
==============================

The **`language`** accessor property of `Intl.Locale` instances returns the language associated with this locale.

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

Language is one of the core features of a locale. The Unicode specification treats the language identifier of a locale as the language and the region together (to make a distinction between dialects and variations, e.g. British English vs. American English). The `language` property of a `Intl.Locale` returns strictly the locale's language subtag.

Examples
--------

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

In order to be a valid Unicode locale identifier, a string must start with the language subtag. The main argument to the `Intl.Locale()` constructor must be a valid Unicode locale identifier, so whenever the constructor is used, it must be passed an identifier with a language subtag.


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

### Overriding language via the configuration object

While the language subtag must be specified, the `Intl.Locale()` constructor takes a configuration object, which can override the language subtag.


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

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

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

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

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

See also
--------

* `Intl.Locale`
* Unicode language subtag in the Unicode locale data markup language spec
Intl.Locale.prototype.hourCycle
===============================

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

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

There are 2 main types of time keeping conventions (clocks) used around the world: the 12 hour clock and the 24 hour clock. The `hourCycle` property's value is set at construction time, either through the `hc` key of the locale identifier or through the `hourCycle` 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 hour cycle types, see `Intl.Locale.prototype.getHourCycles()`.

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

Examples
--------

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

### Adding an hour cycle via the locale string

In the Unicode locale string spec, hour cycle 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 hour cycle type can be added to the initial locale identifier string that is passed into the `Intl.Locale()` constructor. To add the hour cycle type, first add the `-u` extension key to the string. Next, add the `-hc` extension to indicate that you are adding an hour cycle. Finally, add the hour cycle type to the string.


```js
const locale = new Intl.Locale("fr-FR-u-hc-h23");
console.log(locale.hourCycle); // "h23"
```

### Adding an hour cycle via the configuration object argument

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


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

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

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

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

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

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.getHourCycles()`
* Unicode Hour Cycle Identifier in the Unicode locale data markup language spec
Intl.Locale.prototype.collation
===============================

The **`collation`** accessor property of `Intl.Locale` instances returns the collation type for this locale, which is used to order strings according to the locale's rules.

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

Collation is the process of ordering strings of characters. It is used whenever strings must be sorted and placed into a certain order, from search query results to ordering records in a database. While the idea of placing strings in order might seem trivial, the idea of order can vary from region to region and language to language. The `collation` property's value is set at construction time, either through the `co` key of the locale identifier or through the `collation` 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 collation types, see `Intl.Locale.prototype.getCollations()`.

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

Examples
--------

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

### Adding a collation type via the locale string

In the Unicode locale string spec, collation 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 collation type can be added to the initial locale identifier string that is passed into the `Intl.Locale()` constructor. To add the collation type, first add the `-u` extension to the string. Next, add the `-co` extension to indicate that you are adding a collation type. Finally, add the collation type to the string.


```js
const locale = new Intl.Locale("zh-Hant-u-co-zhuyin");
console.log(locale.collation); // "zhuyin"
```

### Adding a collation 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 collation types. Set the `collation` property of the configuration object to your desired collation type, and then pass it into the constructor.


```js
const locale = new Intl.Locale("zh-Hant", { collation: "zhuyin" });
console.log(locale.collation); // "zhuyin"
```

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

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

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

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

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.getCollations()`
Intl.Locale.prototype.getHourCycles()
=====================================

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

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

Syntax
------


```js
getHourCycles()
```

### Parameters

None.

### Return value

An array of strings representing all hour cycle types commonly used for the `Locale`, sorted in descending preference. If the `Locale` already has an `hourCycle`, then the returned array contains that single value.

Below is a list of supported hour cycle types.

### Supported hour cycle types

`h12`

Hour system using 1–12; corresponds to 'h' in patterns. The 12 hour clock, with midnight starting at 12:00 am. As used, for example, in the United States.

`h23`

Hour system using 0–23; corresponds to 'H' in patterns. The 24 hour clock, with midnight starting at 0:00.

`h11`

Hour system using 0–11; corresponds to 'K' in patterns. The 12 hour clock, with midnight starting at 0:00 am. Mostly used in Japan.

`h24`

Hour system using 1–24; corresponds to 'k' in pattern. The 24 hour clock, with midnight starting at 24:00. Not used anywhere.

Examples
--------

### Obtaining supported hour cycles

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


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



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

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

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

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

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

See also
--------

* `Intl.Locale`
* `Intl.Locale.prototype.hourCycle`
* Unicode Hour Cycle Identifier in the Unicode locale data markup language spec
Intl.DurationFormat.supportedLocalesOf()
========================================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`Intl.DurationFormat.supportedLocalesOf()`** static method returns an array containing those of the provided locales that are supported in duration formatting without having to fall back to the runtime's default locale.

Syntax
------


```js
Intl.DurationFormat.supportedLocalesOf(locales)
Intl.DurationFormat.supportedLocalesOf(locales, options)
```

### Parameters

`locales`

A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the `locales` argument, see the parameter description on the `Intl` main page.

`options` Optional

An object that may have the following property:

`localeMatcher`

The locale matching algorithm to use. Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. For information about this option, see the Intl page.


### Return value

An array of strings representing a subset of the given locale tags that are supported in duration formatting without having to fall back to the runtime's default locale.

Examples
--------

### Using supportedLocalesOf()

Assuming a runtime that supports Indonesian and German but not Balinese in duration formatting, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to duration formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the `"lookup"` algorithm here — a `"best fit"` matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.


```js
const locales = ["ban", "id-u-co-pinyin", "de-ID"];
const options = { localeMatcher: "lookup" };
console.log(Intl.DurationFormat.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

| Specification |
| --- |
| Intl.DurationFormat # sec-Intl.DurationFormat.supportedLocalesOf |

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

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

See also
--------

* `Intl.DurationFormat`
Intl.RelativeTimeFormat.supportedLocalesOf()
============================================

The **`Intl.RelativeTimeFormat.supportedLocalesOf()`** static method returns an array containing those of the provided locales that are supported in relative time formatting without having to fall back to the runtime's default locale.

Try it
------

Syntax
------


```js
Intl.RelativeTimeFormat.supportedLocalesOf(locales)
Intl.RelativeTimeFormat.supportedLocalesOf(locales, options)
```

### Parameters

`locales`

A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the `locales` argument, see the parameter description on the `Intl` main page.

`options` Optional

An object that may have the following property:

`localeMatcher`

The locale matching algorithm to use. Possible values are `"lookup"` and `"best fit"`; the default is `"best fit"`. For information about this option, see the Intl page.


### Return value

An array of strings representing a subset of the given locale tags that are supported in relative time formatting without having to fall back to the runtime's default locale.

Examples
--------

### Using supportedLocalesOf()

Assuming a runtime that supports Indonesian and German but not Balinese in relative time formatting, `supportedLocalesOf` returns the Indonesian and German language tags unchanged, even though `pinyin` collation is neither relevant to relative time formatting nor used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the `"lookup"` algorithm here — a `"best fit"` matcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.


```js
const locales = ["ban", "id-u-co-pinyin", "de-ID"];
const options = { localeMatcher: "lookup" };
console.log(Intl.RelativeTimeFormat.supportedLocalesOf(locales, options));
// ["id-u-co-pinyin", "de-ID"]
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.RelativeTimeFormat.supportedLocalesOf |

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

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

See also
--------

* `Intl.RelativeTimeFormat`
Intl.RelativeTimeFormat.prototype.formatToParts()
=================================================

The **`formatToParts()`** method of `Intl.RelativeTimeFormat` instances returns an `Array` of objects representing the relative time format in parts that can be used for custom locale-aware formatting.

Try it
------

Syntax
------


```js
formatToParts(value, unit)
```

### Parameters

`value`

Numeric value to use in the internationalized relative time message.

`unit`

Unit to use in the relative time internationalized message. Possible values are: `"year"`, `"quarter"`, `"month"`, `"week"`, `"day"`, `"hour"`, `"minute"`, `"second"`. Plural forms are also permitted.

### Return value

An `Array` of objects containing the formatted relative time in parts.

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

The `Intl.RelativeTimeFormat.prototype.formatToParts` method is a version of the format method which it returns an array of objects which represent "parts" of the object, separating the formatted number into its constituent parts and separating it from other surrounding text. These objects have two properties: type a `NumberFormat` formatToParts type, and value, which is the String which is the component of the output. If a "part" came from `NumberFormat`, it will have a unit property which indicates the unit being formatted; literals which are part of the larger frame will not have this property.

Examples
--------

### Using formatToParts


```js
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });

// Format relative time using the day unit
rtf.formatToParts(-1, "day");
// [{ type: "literal", value: "yesterday"}]

rtf.formatToParts(100, "day");
// [
// { type: "literal", value: "in " },
// { type: "integer", value: "100", unit: "day" },
// { type: "literal", value: " days" }
// ]
```

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

| Specification |
| --- |
| ECMAScript Internationalization API Specification # sec-Intl.RelativeTimeFormat.prototype.formatToParts |

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

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

See also
--------

* `Intl.RelativeTimeFormat`