
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@lettopia/extract-react-intl-messages
Advanced tools
This package will generate json or yaml files from a glob. It will generate one file per locale, with the ids of each message defined by the defineMessages
function of react-intl. The value of each of these keys will be an empty string, except for your defaultLocale
which will be populated with the defaultMessage
.
This project has a peer dependency on babel-core
.
To use this with Babel 6, run
$ npm install --save-dev extract-react-intl-messages babel-core
To use this with Babel 7, run
$ npm install --save-dev extract-react-intl-messages babel-core@bridge @babel/core
app/components/App/messages.js
import { defineMessages } from 'react-intl'
export default defineMessages({
hello: {
id: 'a.hello',
defaultMessage: 'hello'
},
world: {
id: 'a.world',
defaultMessage: 'world'
}
})
$ extract-messages -l=en,ja -o app/translations -d en --flat false 'app/**/!(*.test).js'
app/translations/en.json
{
"a": {
"hello": "hello",
"world": "world"
},
"b": {
"hello": "hello",
"world": "world"
}
}
app/translations/ja.json
{
"a": {
"hello": "",
"world": ""
},
"b": {
"hello": "",
"world": ""
}
}
Use with babel-plugin-react-intl-auto: i18n for the component age. Auto management react-intl ID.
$ extract-messages --help
Extract react-intl messages
Usage
$ extract-react-intl-messages <input>
$ extract-messages <input>
Options
-o, --output Output directory [require: true]
-l, --locales locales [require: true]
-f, --format json|yaml [default: json]
--flat json [default: true] | yaml [default: false]
--default-locale default locale [default: en]
--delimiter json | yaml [default: .]
Example
$ extract-messages --locales=ja,en --output app/translations 'app/**/*.js'
$ extract-messages -l=ja,en -o i18n 'src/**/*.js'
$ extract-messages -l=ja,en -o app/translations -f yaml 'app/**/messages.js'
create .babelrc
like this.
{
"presets": ["react-app"]
}
Run with NODE_ENV=development
.
$ NODE_ENV=development extract-messages ...
Type: Array<string>
Example: ['en', 'ja']
Type: Array<string>
Target files. glob.
Type: string
Export directory.
Type: string
Default: en
Type: json
| yaml
Default: json
Set extension to output.
Type: boolean
Default: true
If format is yaml
, set to false
.
Be careful if false
.
See this issue.
Thanks goes to these wonderful people (emoji key):
akameco 💻 ⚠️ 📖 🚇 | Hoan Tran 💻 ⚠️ | giantpinkwalrus 💻 | enrique-ramirez 📖 | Stefan Gojan 🐛 💻 ⚠️ |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © akameco
FAQs
Extract react-intl messages
We found that @lettopia/extract-react-intl-messages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.