1.1.1 • Published 7 years ago
react-globe-cli v1.1.1
:boom: Careful: This package is no longer maintained and is only here for historic reasons. This means you should very likely not use it. You have been warned. :boom:
react-globe-cli
A CLI tool for extracting a gettext POT file from multiple JS or TS source files using react-globe
Install
npm install react-globe-cli --saveUsage
# Go through all the files and extract the translations into the output file
react-globe-cli --files='./src/**/*.js' --output='templates.pot'Note: Make sure you are running this on unminified source code, since it requires the
tandtPluralfunction calls to keep their names. It should be fine with parsing es2015, jsx and TypeScript code, but if you are using bleeding edge (e.g. thestage-0babel plugin) you will have to pre-compile that.
Example
Input (JS)
// ...
t('Hello World')
// ...
<h1>{t('Sup!')}</h1>
// ...
tPlural({one: 'One potato', many: '{{count}} potatoes'}, {count: 10})Output (POT)
msgid "Hello World"
msgstr ""
msgid "Sup!"
msgstr ""
msgid "One potato"
msgid_plural "{{count}} potatoes"
msgstr[0] ""
msgstr[1] ""API
You can also use parts of this as programmatic APIs, if you wish so:
const extract = require('react-globe-cli/extract')
extract(string) // -> ['Text', 'Text2', ['Singular', 'Plural']]
const convert = require('react-globe-cli/convert')
convert(extractedArray) // -> gettext file as a string, ready for writingDebugging
This module uses debug.
DEBUG='react-globe-cli' react-globe-cli --files='./src/**/*.js' --output='templates.pot'Licence
MIT