1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
---
title: Intl
slug: Web/JavaScript/Reference/Global_Objects/Intl
tags:
- Internationalization
- Intl
- JavaScript
- Reference
- 국제화
translation_of: Web/JavaScript/Reference/Global_Objects/Intl
---
<div>{{JSRef}}</div>
<p><strong><code>Intl</code></strong> 객체는 각 언어에 맞는 문자비교, 숫자, 시간, 날짜비교를 제공하는, ECMAScript 국제화 API를 위한 이름공간입니다. {{jsxref("Collator")}}, {{jsxref("NumberFormat")}}, {{jsxref("DateTimeFormat")}}는 <code>Intl</code> 객체의 속성을 위한 생성자입니다. 이 페이지는 일반적인 국제화의 기능을 수행하는 객체의 생성자들과 언어를 구분하는 함수들 뿐만 아니라 이러한 속성들에 대해서도 다루고 있습니다.</p>
<h2 id="속성">속성</h2>
<dl>
<dt>{{jsxref("Collator", "Intl.Collator")}}</dt>
<dd>콜레이터 생성자입니다. 콜레이터 객체는 각 언어에 맞는 문자열 비교를 가능하게 해줍니다.</dd>
<dt>{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}</dt>
<dd>각 언어에 맞는 시간과 날짜 서식을 적용할 수 있는 객체의 생성자입니다.</dd>
<dt>{{jsxref("ListFormat", "Intl.ListFormat")}}</dt>
<dd>각 언어에 맞는 목록 서식을 적용할 수 있는 객체의 생성자입니다.</dd>
<dt>{{jsxref("NumberFormat", "Intl.NumberFormat")}}</dt>
<dd>각 언어에 맞는 숫자 서식을 적용할 수 있는 객체의 생성자입니다.</dd>
<dt>{{jsxref("PluralRules", "Intl.PluralRules")}}</dt>
<dd>각 언어에 맞는 복수형 규칙 및 단수 복수 구분 서식을 적용할 수 있는 객체의 생성자입니다.</dd>
<dt>{{jsxref("RelativeTimeFormat", "Intl.RelativeTimeFormat")}}</dt>
<dd>각 언어에 맞는 상대 시간 서식을 적용할 수 있는 객체의 생성자입니다.</dd>
</dl>
<h2 id="메서드">메서드</h2>
<dl>
<dt>{{jsxref("Intl.getCanonicalLocales()")}}</dt>
<dd>표준 로케일 이름 목록을 반환합니다.</dd>
</dl>
<h2 id="로케일_식별과_조정">로케일 식별과 조정</h2>
<p>The internationalization constructors as well as several language sensitive methods of other constructors (listed under {{anch("See_also", "See also")}}) use a common pattern for identifying locales and determing the one they will actually use: they all accept <code>locales</code> and <code>options</code> arguments, and negotiate the requested locale(s) against the locales they support using an algorithm specified in the <code>options.localeMatcher</code> property.</p>
<h3 id="locales_매개변수"><code>locales</code> 매개변수</h3>
<p>The <code>locales</code> argument must be either a string holding a <a href="http://tools.ietf.org/html/rfc5646">BCP 47 language tag</a>, or an array of such language tags. If the <code>locales</code> argument is not provided or is undefined, the runtime's default locale is used.</p>
<p>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:</p>
<ul>
<li><code>"hi"</code>: Hindi.</li>
<li><code>"de-AT"</code>: German as used in Austria.</li>
<li><code>"zh-Hans-CN"</code>: Chinese written in simplified characters as used in China.</li>
</ul>
<p>The subtags identifying languages, scripts, countries (regions), and (rarely used) variants in BCP 47 language tags can be found in the <a href="http://www.iana.org/assignments/language-subtag-registry">IANA Language Subtag Registry</a>.</p>
<p>BCP 47 also allows for extensions, and one of them matters to the JavaScript internationalization functions: the <code>"u"</code> (Unicode) extension. It can be used to request a customization of the locale-specific behavior of a {{jsxref("Collator")}}, {{jsxref("NumberFormat")}}, or {{jsxref("DateTimeFormat")}} object. Examples:</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="로케일_조정">로케일 조정</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_매개변수"><code>options</code> 매개변수</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="명세">명세</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="브라우저_호환성">브라우저 호환성</h2>
<p>{{Compat("javascript.builtins.Intl")}}</p>
<h2 id="같이_보기">같이 보기</h2>
<ul>
<li>소개글: <a href="http://norbertlindenberg.com/2012/12/ecmascript-internationalization-api/index.html">The ECMAScript Internationalization API</a></li>
<li>생성자
<ul>
<li>{{jsxref("Collator", "Intl.Collator")}}</li>
<li>{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}</li>
<li>{{jsxref("ListFormat", "Intl.ListFormat")}}</li>
<li>{{jsxref("NumberFormat", "Intl.NumberFormat")}}</li>
<li>{{jsxref("PluralRules", "Intl.PluralRules")}}</li>
<li>{{jsxref("RelativeTimeFormat", "Intl.RelativeTimeFormat")}}</li>
</ul>
</li>
<li>메서드
<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>
|