Intl.DisplayNames

A polyfill for Intl.DisplayNames.

npm Version size

Installation

npm install @formatjs/intl-displaynames

Requirements

If you're supporting IE11-, this requires Intl.getCanonicalLocales.

Features

Everything in https://github.com/tc39/proposal-intl-displaynames.

Usage

To use this as a polyfill, override Intl.DisplayNames as below:

import '@formatjs/intl-displaynames/polyfill';
import '@formatjs/intl-displaynames/locale-data/en'; // locale-data for en
import '@formatjs/intl-displaynames/locale-data/zh'; // locale-data for zh
new Intl.DisplayNames('en').of('zh-Hans'); //=> "Simplified Chinese"
new Intl.DisplayNames('zh', {type: 'currency'}).of('USD'); //=> "美元"