mozilla / remote-newtab

Remotely-hosted New Tab Page
https://mozilla.github.io/remote-newtab/src/
Mozilla Public License 2.0
15 stars 7 forks source link

[#162] Adds react localization with react-intl #178

Closed k88hudson closed 8 years ago

k88hudson commented 8 years ago

This uses react-intl@2.0.0-beta-2, which is still in beta, but is feature-complete and pretty close to a stable release.

Build step

bin/generate-html.js outputs a single html file to www. In a future patch this can be changed to output to multiple folders i.e. 1 per locale.

bin/generate-locale-data.js outputs a js file containing messages and react-intl locale-specific stuff such as pluralization functions. It attaches them to globals, i.e. window.reactIntlLocaleData and window.newTabLocaleInfo

Usage

Basic usage is as follows, where newtab-customize-cog-title2 is the key of a string:

const {FormattedMessage} = require('react-intl');
...
<FormattedMessage id="newtab-customize-cog-title2" />

There are also components and functions for rendering plurals, numbers, currencies, etc.