React & Modern Frontend (445 Qs)•Part 3: React Internationalization (89 - 94)
What is React Intl?
The React Intl library makes internationalization in React straightforward, with off-the-shelf components and an API that can handle everything from formatting strings, dates, and numbers, to pluralization. React Intl is part of FormatJS which provides bindings to React via its components and API.
Practical Code Example
jsx
// React Intl: Internationalization library formatting dates, numbers, and strings
import { IntlProvider, FormattedMessage } from 'react-intl';
const messages = { 'app.welcome': 'Welcome to InterviewHub!' };
function App() {
return (
<IntlProvider locale="en" messages={messages}>
<FormattedMessage id="app.welcome" />
</IntlProvider>
);
}