API Reference - CLI (@lingui/cli)¶
@lingui/cli manages locales, extracts messages from source files into
message catalogs and compiles message catalogs for production use.
Install¶
Install
@lingui/clias a development dependency:npm install --save-dev @lingui/cli @babel/core # yarn add --dev @lingui/cli @babel/coreAdd following scripts to your
package.json:{ "scripts": { "extract": "lingui extract", "compile": "lingui compile", } }
Global options¶
-
--config<config>¶
Path to LinguiJS configuration file. If not set, the default file is loaded as described in LinguiJS configuration reference.
Commands¶
extract¶
-
lingui extract [--clean] [--overwrite] [--format <format>] [--convert-from <format>] [--verbose]¶
This command extracts messages from source files and creates a message catalog for each language using the following steps:
Extract messages from all
*.jsx?files insidesrcPathDirsMerge them with existing catalogs in
localeDir(if any)Write updated message catalogs to
localeDir
-
--clean¶
Remove obsolete messages from catalogs. Message becomes obsolete when it’s missing in the source code.
-
--overwrite¶
Update translations for sourceLocale from source.
-
--format<format>¶
Format of message catalogs (see format option).
-
--convert-from<format>¶
Convert message catalogs from previous format (see format option).
-
--verbose¶
Prints additional information.
compile¶
-
lingui compile [--strict] [--format <format>] [--verbose] [--namespace <namespace>]¶
This command compiles message catalogs in localeDir and outputs
minified Javascript files. Each message is replaced with a function
that returns the translated message when called.
Also, language data (pluralizations) are written to the message catalog as well.
-
--strict¶
Fail if a catalog has missing translations.
-
--format<format>¶
Format of message catalogs (see format option).
-
--verbose¶
Prints additional information.
-
--namespace¶
Specify namespace for compiled message catalogs (also see compileNamespace for
global configuration).