Permalink
Browse files

Changed readme and hello-world example to use FormattedMessage to eli…

…minate string fragments
  • Loading branch information...
1 parent 33610e5 commit b1f2450128dea28f1a94cf0ca7336f0faa7ae481 @yangsu yangsu committed Aug 22, 2016
Showing with 18 additions and 14 deletions.
  1. +9 −7 README.md
  2. +9 −7 examples/hello-world/index.js
View
@@ -35,7 +35,7 @@ There are several [runnable examples][Examples] in this Git repo, but here's a H
```js
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
-import {IntlProvider, FormattedNumber, FormattedPlural} from 'react-intl';
+import {IntlProvider, FormattedMessage} from 'react-intl';
class App extends Component {
constructor(props) {
@@ -51,12 +51,14 @@ class App extends Component {
return (
<p>
- Hello <b>{name}</b>, you have {' '}
- <FormattedNumber value={unreadCount} /> {' '}
- <FormattedPlural value={unreadCount}
- one="message"
- other="messages"
- />.
+ <FormattedMessage
+ id="welcome"
+ defaultMessage={`Hello {name}, you have {unreadCount, number} {unreadCount, plural,
+ one {message}
+ other {messages}
+ }`}
+ values={{name: <b>{name}</b>, unreadCount}}
+ />
</p>
);
}
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
-import {IntlProvider, FormattedNumber, FormattedPlural} from 'react-intl';
+import {IntlProvider, FormattedMessage} from 'react-intl';
class App extends Component {
constructor(props) {
@@ -16,12 +16,14 @@ class App extends Component {
return (
<p>
- Hello <b>{name}</b>, you have {' '}
- <FormattedNumber value={unreadCount} /> {' '}
- <FormattedPlural value={unreadCount}
- one="message"
- other="messages"
- />.
+ <FormattedMessage
+ id="welcome"
+ defaultMessage={`Hello {name}, you have {unreadCount, number} {unreadCount, plural,
+ one {message}
+ other {messages}
+ }`}
+ values={{name: <b>{name}</b>, unreadCount}}
+ />
</p>
);
}

0 comments on commit b1f2450

Please sign in to comment.