Skip to content
Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Template for GitHub Issues (#1017) Sep 1, 2017
examples Merge pull request #893 from jeremyyap/timezone-prop Sep 10, 2018
scripts Upgrade rollup to v0.50.0 (#1034) Sep 23, 2017
src Make react-intl react 16 compatible (#1201) Oct 23, 2018
test Fixes the ability to pass onError through IntlProvider (#1195) Oct 5, 2018
.babelrc
.eslintignore Add functional tests for builds and locale-data Jan 25, 2016
.eslintrc Integrate prettier for code formatting (#1022) Sep 3, 2017
.gitignore
.npmignore
.travis.yml
CONTRIBUTING.md
LICENSE.md Add license information Jun 27, 2014
README.md Added new Slack workspace to README (#1146) Sep 6, 2018
package.json Bump version to 2.8.0 (#1232) Jan 16, 2019
rollup.config.dist.js Upgrade rollup to v0.50.0 (#1034) Sep 23, 2017
rollup.config.lib.js Upgrade rollup to v0.50.0 (#1034) Sep 23, 2017
yarn.lock Update to CLDR 34 (#1230) Jan 15, 2019

README.md

React Intl

Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.

npm Version Build Status Dependency Status

Overview

React Intl is part of FormatJS. It provides bindings to React via its components and API.

Slack: Join us on Slack at react-intl.slack.com for help, general conversation and more 💬🎊🎉 You can sign-up using this invitation link.

Documentation

React Intl's docs are in this GitHub repo's Wiki, Get Started. There are also several runnable example apps which you can reference to learn how all the pieces fit together.

(If you're looking for React Intl v1, you can find it here.)

Features

  • 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.js.
  • Built on standards.

Example

There are several runnable examples in this Git repo, but here's a Hello World one:

import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {IntlProvider, FormattedMessage} from 'react-intl';

class App extends Component {
    constructor(props) {
        super(props);
        this.state = {
            name       : 'Eric',
            unreadCount: 1000,
        };
    }

    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>
        );
    }
}

ReactDOM.render(
    <IntlProvider locale="en">
        <App />
    </IntlProvider>,
    document.getElementById('container')
);

This example would render: "Hello Eric, you have 1,000 messages." into the container element on the page.

Pluralization rules: In some languages you have more than one and other. For example in ru there are the following plural rules: one, few, many and other. Check out the official Unicode CLDR documentation.

Contribute

Let's make React Intl and FormatJS better! If you're interested in helping, all contributions are welcome and appreciated. React Intl is just one of many packages that make up the FormatJS suite of packages, and you can contribute to any/all of them, including the Format JS website itself.

Check out the Contributing document for the details. Thanks!

License

This software is free to use under the Yahoo Inc. BSD license. See the LICENSE file for license text and copyright information.

You can’t perform that action at this time.