Extracts all react-intl
related messages in typescript based projects.
Install
yarn add @allthings/react-intl-extract-messages
Usage
API
Returns an array of messages gathered by @allthings/babel-plugin-react-intl
.
tsconfigFile
Type: string
Can be absolute or relative path to the tsconfig file, all information how to build the project is taken from there.
options
Type: object
An object of options which is handed over to @allthings/babel-plugin-react-intl
import { extractMessages } from '@allthings/react-intl-extract-messages'
const messages = extractMessages('../tsconfig.json', {
})
console.log(messages)
CLI
react-intl-extract-messages --tsconfig tsconfig.json --out messages.json --options-file opts.json
If --out
is omitted, the output will be written to stdout.
How
Basically it uses typescript to compile all the files to JS and then uses @allthings/babel-plugin-react-intl
to extract the messages.
Tests
Run tests with yarn test
.
This will extract messages from a fixture project and check it against a snapshot.