12. And more, we get big json file with all messages…
export default {
alerts: {
title: 'Alerts',
confirmDelete: "Are you sure you want to delete this Email alert?"
},
alertCreateModal: {
title: 'New Email Alert',
notificationFrequency: 'How often do you want to receive emails?',
save: 'Save Email Alert',
cancel: 'Cancel',
timeIntervals: {
immediately: 'immediately',
daily: 'daily',
weekly: 'weekly',
never: 'never'
}
},
...
13. Disadvantages
● It’s hard to work with it
● It’s hard to support it
● It’s hard to translate it
● Performace issue (smart components)
● Or hanging prop (msg)
● Formatting numbers, dates, and string messages?
14. Disadvantages
● It’s hard to work with it
● It’s hard to support it
● It’s hard to translate it
● Performace issue (smart components)
● Or hanging prop (msg)
● Formatting numbers, dates, and string messages?
React context?
15.
16. React Intl story begins
React Intl is part of FormatJS.
It provides bindings to React via its components and API.
17. Really easy to use
import React from 'react';
import {IntlProvider} from 'react-intl';
ReactDOM.render(
<IntlProvider locale="en">
<App />
</IntlProvider>,
document.getElementById('container')
);
18. We are ready to go
render() {
const {name, unreadCount} = this.state;
return (
<p>
<FormattedMessage
id="welcome"
defaultMessage={`Hello {name}, you have {unreadCount, number} {unreadCount, plural,
one {message}
other {messages}
}`}
values={{name: <b>{name}</b>, unreadCount}}
/>
</p>
);
}