Skip to content

Commit 41f04b6

Browse files
committed
docs(readme): update
1 parent 5f4d740 commit 41f04b6

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

readme.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $ npm install --save-dev extract-react-intl-messages
2626
app/components/App/messages.js
2727

2828
```js
29-
import { defineMessages } from 'react-intl'
29+
import { defineMessages, useIntl } from 'react-intl'
3030

3131
export default defineMessages({
3232
hello: {
@@ -38,6 +38,15 @@ export default defineMessages({
3838
defaultMessage: 'world'
3939
}
4040
})
41+
42+
export const SubmitButton = () => {
43+
const intl = useIntl()
44+
const label = intl.formatMessage({
45+
id: 'a.submit',
46+
defaultMessage: 'Submit Button'
47+
})
48+
return <button aria-label={label}>{label}</button>
49+
})
4150
```
4251

4352
### Run Script
@@ -54,11 +63,8 @@ app/translations/en.json
5463
{
5564
"a": {
5665
"hello": "hello",
57-
"world": "world"
58-
},
59-
"b": {
60-
"hello": "hello",
61-
"world": "world"
66+
"world": "world",
67+
"submit": "Submit Button"
6268
}
6369
}
6470
```
@@ -69,11 +75,8 @@ app/translations/ja.json
6975
{
7076
"a": {
7177
"hello": "",
72-
"world": ""
73-
},
74-
"b": {
75-
"hello": "",
76-
"world": ""
78+
"world": "",
79+
"submit": ""
7780
}
7881
}
7982
```

0 commit comments

Comments
 (0)