yahoo/babel-plugin-react-intl

Name: babel-plugin-react-intl

Owner: Yahoo Inc.

Description: Extracts string messages from React components that use React Intl.

Created: 2015-08-20 19:03:35.0

Updated: 2018-01-17 10:53:46.0

Pushed: 2017-12-11 13:26:43.0

Homepage: http://formatjs.io/react/

Size: 75

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

babel-plugin-react-intl

Extracts string messages for translation from modules that use React Intl.

Note: This Babel plugin works with React Intl v2.x, and 1.x of this plugin works with Babel 5, 2.x works with Babel 6.

Installation
m install babel-plugin-react-intl
Usage

This Babel plugin only visits ES6 modules which import React Intl.

The default message descriptors for the app's default language will be extracted from: defineMessages(), <FormattedMessage>, and <FormattedHTMLMessage>; all of which are named exports of the React Intl package.

If a message descriptor has a description, it'll be removed from the source after it's extracted to save bytes since it isn't used at runtime.

Via .babelrc (Recommended)

.babelrc


lugins": [
["react-intl", {
    "messagesDir": "./build/messages/"
}]


Options
Via Node API

The extract message descriptors are available via the metadata property on the object returned from Babel's transform() API:

ire('babel-core').transform('code', {
ugins: ['react-intl']
/ => { code, map, ast, metadata['react-intl'].messages };

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.