From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/intl/numberformat/index.html | 198 +++++++++++++++++++++ .../intl/numberformat/prototype/index.html | 85 +++++++++ 2 files changed, 283 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/intl/numberformat/index.html create mode 100644 files/ko/web/javascript/reference/global_objects/intl/numberformat/prototype/index.html (limited to 'files/ko/web/javascript/reference/global_objects/intl/numberformat') diff --git a/files/ko/web/javascript/reference/global_objects/intl/numberformat/index.html b/files/ko/web/javascript/reference/global_objects/intl/numberformat/index.html new file mode 100644 index 0000000000..6d306a0c77 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/intl/numberformat/index.html @@ -0,0 +1,198 @@ +--- +title: Intl.NumberFormat +slug: Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat +tags: + - Internationalization + - Intl + - JavaScript + - NumberFormat + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat +--- +
{{JSRef}}
+ +

Intl.NumberFormat은 언어에 맞는 숫자 서식을 지원하는 객체의 생성자입니다.

+ +
{{EmbedInteractiveExample("pages/js/intl-numberformat.html")}}
+ + + +

구문

+ +
new Intl.NumberFormat([locales[, options]])
+Intl.NumberFormat.call(this[, locales[, options]])
+
+ +

매개 변수

+ +
+
locales {{optional_inline}}
+
+

BCP 47 언어 태그를 포함하는 문자열이나 문자열의 배열. 로케일 매개변수의 일반적인 형식 및 해석은 {{jsxref("Intl", "Intl 문서", "#Locale_identification_and_negotiation", 1)}}를 참고하세요. 다음의 Unicode 확장 키를 사용할 수 있습니다.

+ +
+
nu
+
사용할 기수법. "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt" 등을 사용할 수 있습니다.
+
+
+
options {{optional_inline}}
+
+

다음 속성을 포함하는 객체.

+ +
+
localeMatcher
+
사용할 로케일 매칭 알고리즘. 가능한 값은 "lookup""best fit"이고, 기본값은 "best fit"입니다. 자세한 정보는 {{jsxref("Intl", "Intl 문서", "#로케일_조정", 1)}}를 참고하세요.
+
style
+
사용할 서식 스타일. 가능한 값은 평문 숫자 "decimal", 통화 서식 "currency", 백분율 서식 "percent"입니다. 기본값은 "decimal"입니다.
+
currency
+
통화 서식에 사용할 통화입니다. 가능한 값은 ISO 4217 통화 코드로 대한민국 원화 "KRW", 미국 달러화 "USD", 유럽 유로화 "EUR" 등을 포함합니다. 현재 통화 및 펀드 코드 목록을 참고하세요. 기본값은 없습니다. style 값을 "currency"로 지정했다면, currency 값도 반드시 지정해야 합니다.
+
currencyDisplay
+
통화 서식에서 통화를 표시하는 방법. 가능한 값은 €와 같이 현지 통화 기호를 사용하는 "symbol", ISO 통화 코드를 사용하는 "code", "dollar" 등 현지 통화 이름을 사용하는 "name"이 있습니다. 기본 값은 "symbol"입니다.
+
useGrouping
+
천 단위 구분자 혹은 천/라크/크로르 단위 구분자의 삽입 여부. 가능한 값은 truefalse입니다. 기본 값은 true입니다.
+
+ +

아래 속성은 두 가지 그룹으로 나뉩니다. minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits가 첫 번째 그룹이고, minimumSignificantDigitsmaximumSignificantDigits가 두 번째 그룹으로, 두 번째 그룹 중 하나라도 지정하면 첫 번째 그룹은 모두 무시합니다.

+ +
+
minimumIntegerDigits
+
정수부의 최소 자릿수. 가능한 값은 1부터 21까지의 수로, 기본값은 1입니다.
+
minimumFractionDigits
+
소수부의 최소 자릿수. 가능한 값은 0부터 20까지의 수로, 평문 숫자와 백분율 서식의 기본값은 0입니다. 통화 서식의 기본값은 ISO 4217 통화 코드 목록이 제공하는 보조 단위의 자릿수에 따라 다릅니다. (목록에 정보가 없을 경우 2)
+
maximumFractionDigits
+
소수부의 최대 자릿수. 가능한 값은 0부터 20까지의 수로, 평문 숫자 서식의 기본값은 minimumFractionDigits와 3 중 더 큰 값입니다. 통화 서식의 기본값은 minimumFractionDigits와, ISO 4217 통화 코드 목록이 제공하는 보조 단위의 자릿수(목록에 정보가 없을 경우 2) 중 더 큰 값입니다. 백분율 서식의 기본값은 minimumFractionDigits와 0 중 더 큰 값입니다.
+
minimumSignificantDigits
+
유효숫자의 최소 수. 가능한 값은 1부터 21까지의 수로, 기본값은 1입니다.
+
maximumSignificantDigits
+
유효숫자의 최대 수. 가능한 값은 1부터 21까지의 수로, 기본값은 21입니다.
+
+
+
+ +

설명

+ +

속성

+ +
+
{{jsxref("NumberFormat.prototype", "Intl.NumberFormat.prototype")}}
+
모든 인스턴스에 속성을 추가할 수 있습니다.
+
+ +

메서드

+ +
+
{{jsxref("NumberFormat.supportedLocalesOf", "Intl.NumberFormat.supportedLocalesOf()")}}
+
주어진 로케일 목록 중, 런타임이 지원하는 항목을 배열로 반환합니다.
+
+ +

NumberFormat 인스턴스

+ +

속성

+ +

NumberFormat 인스턴스는 프로토타입의 다음 속성을 상속합니다.

+ +
{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype', '속성')}}
+ +

메서드

+ +

NumberFormat 인스턴스는 프로토타입의 다음 메서드를 상속합니다.

+ +
{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/prototype', '메서드')}}
+ +

예제

+ +

기본적인 사용 방법

+ +

로케일을 지정하지 않고 사용하면 기본 로케일 및 기본 옵션 서식을 적용한 문자열을 반환합니다.

+ +
var number = 3500;
+
+console.log(new Intl.NumberFormat().format(number));
+// → 한국 로케일의 경우 '3,500' 표시
+
+ +

locales 사용하기

+ +

다음 예제는 지역화된 숫자 서식의 예시를 보입니다. 어플리케이션의 사용자 인터페이스 언어에 맞는 서식을 적용하려면 locales 매개변수로 적절한 언어(와, 필요한 경우 대체 언어)를 제공하는걸 잊지 마세요.

+ +
var number = 123456.789;
+
+// 독일은 소수점 구분자로 쉼표를 사용하고 천 단위 구분자로 마침표를 사용
+console.log(new Intl.NumberFormat('de-DE').format(number));
+// → 123.456,789
+
+// 대부분의 아랍어 사용 국가에서는 실제 아라비아 숫자를 사용
+console.log(new Intl.NumberFormat('ar-EG').format(number));
+// → ١٢٣٤٥٦٫٧٨٩
+
+// 인도는 천, 라크(십만), 크로르(천만) 단위에 구분자 사용
+console.log(new Intl.NumberFormat('en-IN').format(number));
+// → 1,23,456.789
+
+// nu 확장 키로 기수법 지정 (아래 예시는 중국식 숫자 표기)
+console.log(new Intl.NumberFormat('zh-Hans-CN-u-nu-hanidec').format(number));
+// → 一二三,四五六.七八九
+
+// 발리어와 같이 지원되지 않을 수도 있는 언어를 지정할 때는
+// 다음과 같이 대체 언어를 지정할 수 있음. 아래의 경우 대체 언어는 인도어
+console.log(new Intl.NumberFormat(['ban', 'id']).format(number));
+// → 123.456,789
+
+ +

options 사용

+ +

options 매개변수를 지정해 결과를 원하는 형태로 바꿀 수 있습니다.

+ +
var number = 123456.789;
+
+// 통화 서식
+console.log(new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number));
+// → 123.456,79 €
+
+// 한국 원화는 보조 통화 단위를 사용하지 않음
+console.log(new Intl.NumberFormat('ko-KR', { style: 'currency', currency: 'KRW' }).format(number));
+// → ₩123,457
+
+// 유효숫자를 세 개로 제한
+console.log(new Intl.NumberFormat('en-IN', { maximumSignificantDigits: 3 }).format(number));
+// → 1,23,000
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
명세상태Comment
{{SpecName('ES Int 1.0', '#sec-11.1', 'Intl.NumberFormat')}}{{Spec2('ES Int 1.0')}}초기 정의.
{{SpecName('ES Int 2.0', '#sec-11.1', 'Intl.NumberFormat')}}{{Spec2('ES Int 2.0')}}
{{SpecName('ES Int Draft', '#numberformat-objects', 'Intl.NumberFormat')}}{{Spec2('ES Int Draft')}}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("javascript.builtins.Intl.NumberFormat")}}

+
+ +

같이 보기

+ +
{{page('/ko/docs/Web/JavaScript/Reference/Global_Objects/Intl', '같이_보기')}}
diff --git a/files/ko/web/javascript/reference/global_objects/intl/numberformat/prototype/index.html b/files/ko/web/javascript/reference/global_objects/intl/numberformat/prototype/index.html new file mode 100644 index 0000000000..19b0b8e0e6 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/intl/numberformat/prototype/index.html @@ -0,0 +1,85 @@ +--- +title: Intl.NumberFormat.prototype +slug: Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/prototype +tags: + - Internationalization + - Intl + - JavaScript + - NumberFormat + - Property + - Prototype +translation_of: Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat +--- +
{{JSRef}}
+ +

Intl.NumberFormat.prototype 속성은 {{jsxref("NumberFormat", "Intl.NumberFormat")}} 생성자의 프로토타입을 나타냅니다.

+ +
{{js_property_attributes(0, 0, 0)}}
+ +

설명

+ +

Intl.NumberFormat 인스턴스에 대한 설명은 {{jsxref("NumberFormat")}} 문서를 참고하세요.

+ +

{{jsxref("NumberFormat", "Intl.NumberFormat")}} 인스턴스는 Intl.NumberFormat.prototype을 상속합니다. 프로토타입 객체를 변형하면 모든 {{jsxref("NumberFormat", "Intl.NumberFormat")}} 인스턴스가 영향을 받습니다.

+ +

속성

+ +
+
Intl.NumberFormat.prototype.constructor
+
Intl.NumberFormat에 대한 참조입니다.
+
+ +

메서드

+ +
+
{{jsxref("NumberFormat.format", "Intl.NumberFormat.prototype.format()")}}
+
주어진 숫자에 {{jsxref("NumberFormat")}} 객체의 로케일과 서식 설정을 적용해 반환합니다.
+
+ +
+
{{jsxref("NumberFormat.formatToParts", "Intl.NumberFormat.prototype.formatToParts()")}}
+
서식을 적용한 숫자의 각 부분을 객체로 표현해서 {{jsxref("Array")}}로 반환합니다. 반환 값은 로케일별 커스텀 서식에 사용할 수 있습니다.
+
{{jsxref("NumberFormat.resolvedOptions", "Intl.NumberFormat.prototype.resolvedOptions()")}}
+
객체 인스턴스 생성 때 주어진 로케일과 콜레이션 설정이 어떻게 반영되었나 나타내는 새로운 객체를 반환합니다.
+
+ +

명세

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES Int 1.0', '#sec-11.2.1', 'Intl.NumberFormat.prototype')}}{{Spec2('ES Int 1.0')}}Initial definition.
{{SpecName('ES Int 2.0', '#sec-11.2.1', 'Intl.NumberFormat.prototype')}}{{Spec2('ES Int 2.0')}}
{{SpecName('ES Int Draft', '#sec-Intl.NumberFormat.prototype', 'Intl.NumberFormat.prototype')}}{{Spec2('ES Int Draft')}}
+ +

브라우저 호환성

+ +
+ + +

{{Compat("javascript.builtins.Intl.NumberFormat.prototype")}}

+
+ +

같이 보기

+ + -- cgit v1.2.3-54-g00ecf