You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Localized Display Name APIs](#localized-display-name-apis)
32
+
-[`formatDisplayName`](#formatdisplayname)
31
33
-[React Intl Components](#react-intl-components)
32
34
33
35
<!-- tocstop -->
@@ -560,6 +562,47 @@ function formatHTMLMessage(
560
562
561
563
**Note:** This API is provided to format legacy string message that contain HTML, but is not recommended, use [`<FormattedMessage>`](./Components.md#formattedmessage) instead.
562
564
565
+
### Localized Display Name APIs
566
+
567
+
**This uses stage 3 [`Intl.DisplayNames`][displaynames-repo] API so [polyfill][displaynames-polyfill] is required.**
// ISO-4217 currency code to localized display name
601
+
formatDisplayName('CNY', {type: 'currency'}); //=> Chinese Yuan
602
+
// ISO-3166 two letters region code to localized display name
603
+
formatDisplayName('UN', {type: 'region'}); //=> United Nations
604
+
```
605
+
563
606
## React Intl Components
564
607
565
608
The React components provided by React Intl allow for a declarative, idiomatic-React way of providing internationalization configuration and format dates, numbers, and strings/messages in your app.
Copy file name to clipboardExpand all lines: docs/Components.md
+42
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,8 @@ React Intl has a set of React components that provide a declarative way to setup
30
30
-[Caveats](#caveats)
31
31
-[`FormattedHTMLMessage`](#formattedhtmlmessage)
32
32
-[Using React-Intl with React Native](#using-react-intl-with-react-native)
33
+
-[Localized Display Name Components](#localized-display-name-components)
34
+
-[`FormattedDisplayName`](#formatteddisplayname)
33
35
34
36
<!-- tocstop -->
35
37
@@ -710,3 +712,43 @@ This component uses the [`formatHTMLMessage`](API.md#formathtmlmessage) API and
710
712
Historically, it was required to provide a `textComponent` for React-Intl to work on React Native, because Fragments didn't exist at the time and React Native would break trying to render a `span` (the default `textComponent` in React-Intl V2).
711
713
712
714
Starting with [React Native v0.52](https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#0520---2018-01-07), which uses [React v16.2+](https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html), Fragments are supported. And since React-Intl V3's default `textComponent` is `<React.Fragment>`, such requirement no longer exists.
715
+
716
+
## Localized Display Name Components
717
+
718
+
### `FormattedDisplayName`
719
+
720
+
This component uses [`formatDisplayName`][formatdisplayname] and [`Intl.DisplayName`][intl-displayname]
721
+
has `props` that correspond to `DisplayNameOptions`. You might need a [polyfill][displaynames-polyfill].
Copy file name to clipboardExpand all lines: docs/Getting-Started.md
+16
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,11 @@ React Intl relies on these `Intl` APIs:
51
51
-[Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat): Available on IE11+
52
52
-[Intl.PluralRules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules): This can be polyfilled using [this package](https://www.npmjs.com/package/@formatjs/intl-pluralrules).
53
53
-[Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat): This can be polyfilled using [this package](https://www.npmjs.com/package/@formatjs/intl-relativetimeformat).
54
+
- (Optional) [Intl.DisplayNames][displaynames-spec]: Required if you use [`formatDisplayName`](API.md#formatdisplayname)
55
+
or [`FormattedDisplayName`](Components.md#formatteddisplayname). This can be polyfilled using [this package][displaynames-polyfill].
0 commit comments