Tradução em progresso.

O objeto Intl é o namespace para a API de Internacionalização do ECMAScript , que fornece comparação de string sensível à línguagem, formatação de números, e formatação de data e hora. Os construtores para os objetos Collator, NumberFormat, e DateTimeFormat são propriedades do objecto Intl. Esta página documenta essas propriedades, bem como funcionalidades comuns aos construtores de internacionalização e outras funções sensíveis de linguagem.


Construtor para collators, objetos que permitem comparação de string sensível a linguagem.
Construtor para objetos que permitem formatação de data e hora sensível a linguagem.
Construtor para objetos que permitem formatação de número sensível a linguagem.


A method returning the canonical locale names.

Locale identification and negotiation

The internationalization constructors as well as several language sensitive methods of other constructors (listed under See also) use a common pattern for identifying locales and determing the one they will actually use: they all accept locales and options arguments, and negotiate the requested locale(s) against the locales they support using an algorithm specified in the options.localeMatcher property.

locales argument

The locales argument must be either a string holding a BCP 47 language tag, or an array of such language tags. If the locales argument is not provided or is undefined, the runtime's default locale is used.

A BCP 47 language tag identifies a language or locale (the difference between the two is fuzzy). In their most common form it can contain, in this order: a language code, a script code, and a country code, all separated by hyphens. Examples:

  • "hi": Hindi.
  • "de-AT": German as used in Austria.
  • "zh-Hans-CN": Chinese written in simplified characters as used in China.

The subtags identifying languages, scripts, countries (regions), and (rarely used) variants in BCP 47 language tags can be found in the IANA Language Subtag Registry.

BCP 47 also allows for extensions, and one of them matters to the JavaScript internationalization functions: the "u" (Unicode) extension. It can be used to request a customization of the locale-specific behavior of a Collator, NumberFormat, or DateTimeFormat object. Examples:

  • "de-DE-u-co-phonebk": Use the phonebook variant of the German sort order, which expands umlauted vowels to character pairs: ä → ae, ö → oe, ü → ue.
  • "th-TH-u-nu-thai": Use Thai digits (๐, ๑, ๒, ๓, ๔, ๕, ๖, ๗, ๘, ๙) in number formatting.
  • "ja-JP-u-ca-japanese": Use the Japanese calendar in date and time formatting, so that 2013 is expressed as the year 25 of the Heisei period, or 平成25.

Locale negotiation

The locales argument, after stripping off all Unicode extensions, is interpreted as a prioritized request from the application. The runtime compares it against the locales it has available and picks the best one available. Two matching algorithms exist: the "lookup" matcher follows the Lookup algorithm specified in BCP 47; the "best fit" matcher lets the runtime provide a locale that's at least, but possibly more, suited for the request than the result of the Lookup algorithm. If the application doesn't provide a locales argument, or the runtime doesn't have a locale that matches the request, then the runtime's default locale is used. The matcher can be selected using a property of the options argument (see below).

If the selected language tag had a Unicode extension substring, that extension is now used to customize the constructed object or the behavior of the function. Each constructor or function supports only a subset of the keys defined for the Unicode extension, and the supported values often depend on the language tag. For example, the "co" key (collation) is only supported by Collator, and its "phonebk" value is only supported for German.

options argument

The options argument must be an object with properties that vary between constructors and functions. If the options argument is not provided or is undefined, default values are used for all properties.

One property is supported by all language sensitive constructors and functions: The localeMatcher property, whose value must be a string "lookup" or "best fit" and which selects one of the locale matching algorithms described above.


Specification Status Comment
ECMAScript Internationalization API 1.0 (ECMA-402)
The definition of 'Intl' in that specification.
Padrão Initial definition.
ECMAScript Internationalization API 2.0 (ECMA-402)
The definition of 'Intl' in that specification.
ECMAScript Internationalization API 4.0 (ECMA-402)
The definition of 'Intl' in that specification.
Rascunho Added Intl.getCanonicalLocales in the 4th edition.

Browser compatibility

Estamos convertendo nossos dados de compatibilidade para o formato JSON. Esta tabela de compatibilidade ainda usa o formato antigo, pois ainda não convertemos os dados que ela contém. Descubra como você pode ajudar!
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 24 29 (29) 11 15 10.0 [2]
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support Não suportado 26 54.0 (54) (nightly-only) [1] Não suportado Não suportado 10.0 [2]

[1] Starting with Gecko 44 (Firefox 44 / Thunderbird 44 / SeaMonkey 2.41), the Intl API is available on b2gdroid.
[2] Safari 10.0 Release Notes

See also

Etiquetas do documento e colaboradores

Colaboradores desta página: alexandresn
Última atualização por: mdnwebdocs-bot,