Localization CLI and config
Commands
Permalink to “Commands”Command | Description |
---|---|
extract | Extract msg calls from all input files and create or update XLIFF (.xlf ) files. |
build | Incorporate translations back into your app using the configured mode. |
Flags
Permalink to “Flags”Flag | Description |
---|---|
--help | Display help about usage. |
--config | Path to JSON config file. Defaults to ./lit-localize.json |
Config file
Permalink to “Config file”General settings
Permalink to “General settings”All file paths are relative to the location of the config file.
- sourceLocale
string
Required
Locale code that templates in the source code are written in.
- targetLocales
string[]
Required (can be empty)
Locale codes that templates will be localized to.
- inputFiles
string[]
Required unless
tsConfig
is specifiedArray of filenames or glob patterns matching the JavaScript or TypeScript files to extract messages from.
If both
tsConfig
andinputFiles
are specified, theninputFiles
takes precedence.- tsConfig
string
Required unless
inputFiles
is specifiedPath to a
tsconfig.json
orjsconfig.json
file that describes the JavaScript or TypeScript files from which messages will be extracted, and also the compiler options that will be used when building for transform mode.If both
tsConfig
andinputFiles
are specified, theninputFiles
takes precedence.- output.mode
"transform" | "runtime"
Required
What kind of output should be produced. See modes.
- output.localeCodesModule
string
Optional
Filepath for a generated JavaScript or TypeScript module that exports
sourceLocale
,targetLocales
, andallLocales
using the locale codes from your config file. Use to keep your config file and client config in sync.This path should end with either
".js"
or".ts"
. If it ends with".js"
it will be emitted as a JavaScript module. If it ends with".ts"
it will be emitted as a TypeScript module.- interchange.format
"xliff" | "xlb"
Required
Data format to be consumed by your localization process. Options:
"xliff"
: XLIFF 1.2 XML format"xlb"
: Google-internal XML format
Runtime mode settings
Permalink to “Runtime mode settings”- output.outputDir
string
Required
Output directory for generated modules. A
<locale>.[js|ts]
file is generated for eachtargetLocale
. Each file is a module that exports the translations for that locale, keyed by message ID.- output.language
"js" | "ts"
Defaults to
"js"
, or"ts"
iftsConfig
was specified.Language to generate modules in.
Transform mode settings
Permalink to “Transform mode settings”- output.outputDir
string
Required unless
tsConfig
is specified, in which case it defaults to that file'soutDir
. If both are specified, this field takes precedence.Output directory for generated modules. A subdirectory is created for each locale within this directory, each containing a full build of the project for that locale.
XLIFF mode settings
Permalink to “XLIFF mode settings”- interchange.xliffDir
string
Required with
"mode": "xliff"
Directory on disk to read/write
.xlf
XML files. For each target locale, the path<xliffDir>/<locale>.xlf
will be used.- interchange.placeholderStyle
"x" | "ph"
Defaults to
"x"
How to represent placeholders containing HTML markup and dynamic expressions. Different localization tools and services have varying support for placeholder syntax.
XLB mode settings
Permalink to “XLB mode settings”- interchange.outputFile
string
Required with
"mode": "xlb"
Output path for XLB XML file that will be created containing all messages extracted from the source. E.g.
"data/localization/en.xlb".
- interchange.translationsGlob
string
Required with
"mode": "xlb"
Glob pattern of XLB XML files to read from disk containing translated messages. E.g.
"data/localization/*.xlb"
.