Intl.DisplayNames
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2021๋ 4์โฉ.
Intl.DisplayNames
๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ฉด ์ธ์ด, ์ง์ญ ๊ทธ๋ฆฌ๊ณ ๋ฌธ์ ์ฒด๊ณ ํ์ ์ด๋ฆ์ ์ผ๊ด๋๊ฒ ๋ฒ์ญํ ์ ์์ต๋๋ค.
์๋ํด ๋ณด๊ธฐ
const regionNamesInEnglish = new Intl.DisplayNames(["en"], { type: "region" });
const regionNamesInTraditionalChinese = new Intl.DisplayNames(["zh-Hant"], {
type: "region",
});
console.log(regionNamesInEnglish.of("US"));
// Expected output: "United States"
console.log(regionNamesInTraditionalChinese.of("US"));
// Expected output: "็พๅ"
์์ฑ์
Intl.DisplayNames()
-
์
Intl.DisplayNames
๊ฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค.
์ ์ ๋ฉ์๋
Intl.DisplayNames.supportedLocalesOf()
-
๋ฐํ์์ ๊ธฐ๋ณธ ๋ก์ผ์ผ๋ก ๋์ฒด๋์ง ์๊ณ , ์ ๊ณต๋ ๋ก์ผ์ผ ์ค ์ง์๋๋ ๋ก์ผ์ผ์ ํฌํจํ ๋ฐฐ์ด์ ๋ฐํํฉ๋๋ค.
์ธ์คํด์ค ์์ฑ
์ด ์์ฑ์ Intl.DisplayNames.prototype
์์ ์ ์๋๋ฉฐ ๋ชจ๋ Intl.DisplayNames
์ธ์คํด์ค์์ ๊ณต์ ๋ฉ๋๋ค.
Intl.DisplayNames.prototype.constructor
-
์ธ์คํด์ค ๊ฐ์ฒด๋ฅผ ๋ง๋ ์์ฑ์ ํจ์์ ๋๋ค.
Intl.DisplayNames
์ธ์คํด์ค์ ๊ฒฝ์ฐ ์ด๊ธฐ ๊ฐ์Intl.DisplayNames
์์ฑ์์ ๋๋ค. Intl.DisplayNames.prototype[Symbol.toStringTag]
-
Symbol.toStringTag
์์ฑ์ ์ด๊ธฐ ๊ฐ์ ๋ฌธ์์ด"Intl.DisplayNames"
์ ๋๋ค. ์ด ์์ฑ์Object.prototype.toString()
์์ ์ฌ์ฉ๋ฉ๋๋ค.
์ธ์คํด์ค ๋ฉ์๋
Intl.DisplayNames.prototype.of()
-
์ด ๋ฉ์๋๋
code
๋ฅผ ๋ฐ๊ณIntl.DisplayNames
์ธ์คํด์ค๋ฅผ ๋ง๋ค๋ ์ ๊ณต๋ฐ์ ๋ก์ผ์ผ๊ณผ ์ต์ ์ ๋ฐ๋ผ ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค. Intl.DisplayNames.prototype.resolvedOptions()
-
๊ฐ์ฒด ์ด๊ธฐํ ์ค์ ๊ณ์ฐ๋ ๋ก์ผ์ผ๊ณผ ์์ ์ต์ ์ ๋ฐ์ํ ์์ฑ์ด ์๋ ์ ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค.
์์
์ง์ญ ์ฝ๋ ํ์ ์ด๋ฆ
๋ก์ผ์ผ์ ๋ํ Intl.DisplayNames
๋ฅผ ์์ฑํ๊ณ , ์ง์ญ ์ฝ๋์ ๋ํ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
// ์์ด๋ก ์ง์ญ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
let regionNames = new Intl.DisplayNames(["en"], { type: "region" });
regionNames.of("419"); // "Latin America"
regionNames.of("BZ"); // "Belize"
regionNames.of("US"); // "United States"
regionNames.of("BA"); // "Bosnia & Herzegovina"
regionNames.of("MM"); // "Myanmar (Burma)"
// ํ๊ตญ์ด๋ก ์ง์ญ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
regionNames = new Intl.DisplayNames(["ko"], { type: "region" });
regionNames.of("419"); // "๋ผํด ์๋ฉ๋ฆฌ์นด"
regionNames.of("BZ"); // "๋ฒจ๋ฆฌ์ฆ"
regionNames.of("US"); // "๋ฏธ๊ตญ"
regionNames.of("BA"); // "๋ณด์ค๋์ ํค๋ฅด์ฒด๊ณ ๋น๋"
regionNames.of("MM"); // "๋ฏธ์๋ง"
์ธ์ด ํ์ ์ด๋ฆ
๋ก์ผ์ผ์ ๋ํ Intl.DisplayNames
๋ฅผ ์์ฑํ๊ณ , ์ธ์ด-๋ฌธ์ ์ฒด๊ณ-์ง์ญ ์ํ์ค์ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
// ์์ด๋ก ์ธ์ด ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
let languageNames = new Intl.DisplayNames(["en"], { type: "language" });
languageNames.of("fr"); // "French"
languageNames.of("de"); // "German"
languageNames.of("fr-CA"); // "Canadian French"
languageNames.of("ko"); // "Traditional Chinese"
languageNames.of("en-US"); // "American English"
languageNames.of("zh-TW"); // "Chinese (Taiwan)"]
// ํ๊ตญ์ด๋ก ์ธ์ด ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
languageNames = new Intl.DisplayNames(["ko"], { type: "language" });
languageNames.of("fr"); // "ํ๋์ค์ด"
languageNames.of("zh"); // "์ค๊ตญ์ด"
languageNames.of("de"); // "๋
์ผ์ด"
๋ฌธ์ ์ฝ๋ ํ์ ์ด๋ฆ
๋ก์ผ์ผ์ ๋ํ Intl.DisplayNames
๋ฅผ ์์ฑํ๊ณ ๋ฌธ์ ์ฝ๋์ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
// ์์ด๋ก ๋ฌธ์ ์ฒด๊ณ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
let scriptNames = new Intl.DisplayNames(["en"], { type: "script" });
// Get script names
scriptNames.of("Latn"); // "Latin"
scriptNames.of("Arab"); // "Arabic"
scriptNames.of("Kana"); // "Katakana"
// ํ๊ตญ์ด๋ก ๋ฌธ์ ์ฒด๊ณ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
scriptNames = new Intl.DisplayNames(["ko"], { type: "script" });
scriptNames.of("Latn"); // "๋ก๋ง์"
scriptNames.of("Arab"); // "์๋ ๋ฌธ์"
scriptNames.of("Kana"); // "๊ฐํ์นด๋"
ํตํ ์ฝ๋ ํ์ ์ด๋ฆ
๋ก์ผ์ผ์ ๋ํ Intl.DisplayNames
๋ฅผ ์์ฑํ๊ณ ํตํ ์ฝ๋์ ํ์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
// ์์ด๋ก ํตํ ์ฝ๋์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
let currencyNames = new Intl.DisplayNames(["en"], { type: "currency" });
// ํตํ ์ด๋ฆ ๊ฐ์ ธ์ค๊ธฐ
currencyNames.of("USD"); // "US Dollar"
currencyNames.of("EUR"); // "Euro"
currencyNames.of("TWD"); // "New Taiwan Dollar"
currencyNames.of("CNY"); // "Chinese Yuan"
// ํ๊ตญ์ด๋ก ํตํ ์ฝ๋์ ์ด๋ฆ์ ๊ฐ์ ธ์ต๋๋ค.
currencyNames = new Intl.DisplayNames(["ko"], { type: "currency" });
currencyNames.of("USD"); // "๋ฏธ๊ตญ ๋ฌ๋ฌ"
currencyNames.of("EUR"); // "์ ๋ก"
currencyNames.of("TWD"); // "์ ํ์ด์ ๋ฌ๋ฌ"
currencyNames.of("CNY"); // "์ค๊ตญ ์์ํ"
๋ช ์ธ์
Specification |
---|
ECMAScriptยฎ 2026 Internationalization API Specification # intl-displaynames-objects |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ