yahoo/react-intl

Name: react-intl

Owner: Yahoo Inc.

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

Created: 2014-04-24 17:28:36.0

Updated: 2018-01-18 21:26:01.0

Pushed: 2018-01-09 21:03:52.0

Homepage:

Size: 2045

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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.

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
Example

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

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

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


tDOM.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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.