tarrencev / babel-plugin-react-intl-to-properties

Extracts React Intl messages from React components into a .properties file
Other
5 stars 2 forks source link

babel-plugin-react-intl-to-properties

Extracts string messages for translation from modules that use React Intl into a .properties file.

Installation

$ npm install babel-plugin-react-intl-to-properties

Example

Formatted Message
  <FormattedMessage
        defaultMessage='React Intl to Properties'
        description='Title for React Intl to Properties'
        id='example.rectintltoprops'
    />
Outputted .properties
# Title for React Intl to Properties
example.rectintltoprops=React Intl to Properties

Usage

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

.babelrc
{
  "plugins": [
    ["react-intl-to-properties", {
        "enforceDescriptions": true,
        "fileName": "en-US",
        "messagesDir": "./build/messages/"
    }]
  ]
}
Options
Via CLI
$ babel --plugins react-intl-to-properties script.js

Credit

Forked from yahoo/babel-plugin-react-intl