React Messages Generator
CLI for transforming json messages to react-intl
(https://github.com/yahoo/react-intl) format
Installation
npm install react-intl-messages-generator
Configuring
Create .rintlmgrc
in root of your project
{
"paths": [ "PATTERN_PATH_TO_YOUR_FILES" ]
}
Generating messages for react-intl
Command line tool
A common usage example is below.
rintlmg
Usage
A small example is below.
local_modules/notify/messages.json
{
"title": {
"defaultMessage": "Title"
},
"description": {
"defaultMessage": "Description"
}
}
shared/components/Sidebar/messages.json
{
"title": {
"defaultMessage": "The Site"
},
"togglerTooltip": {
"defaultMessage": "Show / Hide"
}
}
.rintlmgrc
{
"paths": [ "local_modules/**/messages.json", "shared/**/messages.json" ]
}
Running rintlmg
will output
File local_modules/notify/messages.js created
File shared/components/Sidebar/messages.js created
local_modules/notify/messages.js
import { defineMessages } from 'react-intl'
export default defineMessages({
"title": {
"defaultMessage": "Title",
"id": "notify.title"
},
"description": {
"defaultMessage": "Description",
"id": "notify.description"
}
})
shared/components/Sidebar/messages.js
import { defineMessages } from 'react-intl'
export default defineMessages({
"title": {
"defaultMessage": "The Site",
"id": "components.Sidebar.title"
},
"togglerTooltip": {
"defaultMessage": "Show / Hide",
"id": "components.Sidebar.togglerTooltip"
}
})