aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/global_objects/intl/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/intl/index.html')
-rw-r--r--files/pt-br/web/javascript/reference/global_objects/intl/index.html168
1 files changed, 168 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/intl/index.html b/files/pt-br/web/javascript/reference/global_objects/intl/index.html
new file mode 100644
index 0000000000..02e5b8f205
--- /dev/null
+++ b/files/pt-br/web/javascript/reference/global_objects/intl/index.html
@@ -0,0 +1,168 @@
+---
+title: Intl
+slug: Web/JavaScript/Reference/Global_Objects/Intl
+translation_of: Web/JavaScript/Reference/Global_Objects/Intl
+---
+<div>{{JSRef}}</div>
+
+<p>O objeto <strong><code>Intl</code></strong> é 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 {{jsxref("Collator")}}, {{jsxref("NumberFormat")}}, e {{jsxref("DateTimeFormat")}} são propriedades do objecto <code>Intl</code>. Esta página documenta essas propriedades, bem como funcionalidades comuns aos construtores de internacionalização e outras funções sensíveis de linguagem.</p>
+
+<h2 id="Propriedades">Propriedades</h2>
+
+<dl>
+ <dt>{{jsxref("Global_Objects/Collator", "Intl.Collator")}}</dt>
+ <dd>Construtor para <em>collators</em>, objetos que permitem comparação de string sensível a linguagem.</dd>
+ <dt>{{jsxref("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}}</dt>
+ <dd>Construtor para objetos que permitem formatação de data e hora sensível a linguagem.</dd>
+ <dt>{{jsxref("Global_Objects/NumberFormat", "Intl.NumberFormat")}}</dt>
+ <dd>Construtor para objetos que permitem formatação de número sensível a linguagem.</dd>
+</dl>
+
+<h2 id="Métodos">Métodos</h2>
+
+<dl>
+ <dt>{{jsxref("Intl.getCanonicalLocales()")}}</dt>
+ <dd>Retorna os nomes canônicos de local (ex.: en-US, pt-BR).</dd>
+</dl>
+
+<h2 id="Identificação_e_negociação_de_local">Identificação e negociação de local</h2>
+
+<p>Os construtores de internacionalização, assim como diversos métodos de outros construtores que são sensíveis a idioma (listados em {{anch("See_also", "Veja também")}}) usam um padrão comum para identificar locais e determinar qual será utilizado: todos aceitam argumentos <code>locales</code> e <code>options</code> e negociam o(s) local(is) requisitado entre os locais suportados usando um algoritmo especificado na propriedade <code>options.localeMatcher</code>.</p>
+
+<h3 id="Argumento_locales">Argumento <code>locales</code></h3>
+
+<p>O argumento <code>locales</code> deve ser uma string contendo uma <a href="http://tools.ietf.org/html/rfc5646">tag de linguagem BCP 47</a> ou um array dessas tags. Se o argumento <code>locales</code> não for passado ou estiver indefinido, será utilizado o local padrão do runtime.</p>
+
+<p>Uma tag de linguagem BCP 47 identifica um idioma ou local (a diferença entre ambos neste caso é difusa). Em sua forma mais comum, ela pode conter, nesta ordem: um código de idioma, um código de escrita e um código de país, todos eparados por hífen. Exemplos:</p>
+
+<ul>
+ <li><code>"hi"</code>: Hindi.</li>
+ <li><code>"de-AT"</code>: Alemão como usado na Áustria.</li>
+ <li><code>"zh-Hans-CN"</code>: Chinês com escrita simplificada como usado na China.</li>
+</ul>
+
+<p>As subtags identificando idiomas, escritas, países (regiões) e (raramente utilizadas) variantes nas tags de linguagem BCP 47 podem ser consultadas no <a href="http://www.iana.org/assignments/language-subtag-registry">Registro de Subtags de Linguagem da IANA</a>.</p>
+
+<p>BCP 47 também permite extensões, e uma delas é relevante para as funções JavaScript de internacionalização: a extensão <code>"u"</code> (Unicode). Ela pode ser utilizada para requisitar uma customização do comportamento específico local de um objeto {{jsxref("Collator")}}, {{jsxref("NumberFormat")}}, ou {{jsxref("DateTimeFormat")}}. Exemplos:</p>
+
+<ul>
+ <li><code>"de-DE-u-co-phonebk"</code>: Use the phonebook variant of the German sort order, which expands umlauted vowels to character pairs: ä → ae, ö → oe, ü → ue.</li>
+ <li><code>"th-TH-u-nu-thai"</code>: Use Thai digits (๐, ๑, ๒, ๓, ๔, ๕, ๖, ๗, ๘, ๙) in number formatting.</li>
+ <li><code>"ja-JP-u-ca-japanese"</code>: Use the Japanese calendar in date and time formatting, so that 2013 is expressed as the year 25 of the Heisei period, or 平成25.</li>
+</ul>
+
+<h3 id="Locale_negotiation">Locale negotiation</h3>
+
+<p>The <code>locales</code> 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 <code>"lookup"</code> matcher follows the Lookup algorithm specified in <a href="http://tools.ietf.org/html/rfc4647#section-3.4">BCP 47</a>; the <code>"best fit"</code> 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 <code>locales</code> 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 <code>options</code> argument (see below).</p>
+
+<p>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 <code>"co"</code> key (collation) is only supported by {{jsxref("Collator")}}, and its <code>"phonebk"</code> value is only supported for German.</p>
+
+<h3 id="options_argument"><code>options</code> argument</h3>
+
+<p>The <code>options</code> argument must be an object with properties that vary between constructors and functions. If the <code>options</code> argument is not provided or is undefined, default values are used for all properties.</p>
+
+<p>One property is supported by all language sensitive constructors and functions: The <code>localeMatcher</code> property, whose value must be a string <code>"lookup"</code> or <code>"best fit"</code> and which selects one of the locale matching algorithms described above.</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES Int 1.0', '#sec-8', 'Intl')}}</td>
+ <td>{{Spec2('ES Int 1.0')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES Int 2.0', '#sec-8', 'Intl')}}</td>
+ <td>{{Spec2('ES Int 2.0')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES Int Draft', '#intl-object', 'Intl')}}</td>
+ <td>{{Spec2('ES Int Draft')}}</td>
+ <td>Added Intl.getCanonicalLocales in the 4th edition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome("24")}}</td>
+ <td>{{CompatGeckoDesktop("29")}}</td>
+ <td>{{CompatIE("11")}}</td>
+ <td>{{CompatOpera("15")}}</td>
+ <td>{{CompatSafari("10.0")}} [2]</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome("26")}}</td>
+ <td>{{CompatGeckoMobile("54")}} (nightly-only) [1]</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatSafari("10.0")}} [2]</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] Starting with Gecko 44 {{geckoRelease(44)}}, the Intl API is available on <a href="https://people.mozilla.org/~fdesre/b2gdroid/">b2gdroid</a>.<br>
+ [2] <a href="https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_0.html">Safari 10.0 Release Notes</a></p>
+
+<h2 id="Veja_também">Veja também</h2>
+
+<ul>
+ <li>Introduction: <a href="http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html">The ECMAScript Internationalization API</a></li>
+ <li>Constructors
+ <ul>
+ <li>{{jsxref("Collator", "Intl.Collator")}}</li>
+ <li>{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}</li>
+ <li>{{jsxref("NumberFormat", "Intl.NumberFormat")}}</li>
+ </ul>
+ </li>
+ <li>Methods
+ <ul>
+ <li>{{jsxref("String.prototype.localeCompare()")}}</li>
+ <li>{{jsxref("Number.prototype.toLocaleString()")}}</li>
+ <li>{{jsxref("Date.prototype.toLocaleString()")}}</li>
+ <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li>
+ <li>{{jsxref("Date.prototype.toLocaleTimeString()")}}</li>
+ </ul>
+ </li>
+</ul>