React & Modern Frontend (445 Qs)•Part 3: React Internationalization (89 - 94)
What are the main features of React Intl?
Below are the main features of React Intl,
- Display numbers with separators.
- Display dates and times correctly.
- Display dates relative to "now".
- Pluralize labels in strings.
- Support for 150+ languages.
- Runs in the browser and Node.
- Built on standards.
Practical Code Example
jsx
// React Intl features: Pluralization, Currency, Relative Time formatting:
import { FormattedNumber, FormattedDate } from 'react-intl';
function Transaction({ amount, date }) {
return (
<div>
<FormattedNumber value={amount} style="currency" currency="USD" />
<FormattedDate value={date} year="numeric" month="long" day="numeric" />
</div>
);
}