Localization CLI and config


CommandDescription
extractExtract msg calls from all input files and create or update XLIFF (.xlf) files.
buildIncorporate translations back into your app using the configured mode.

FlagDescription
--helpDisplay help about usage.
--configPath to JSON config file. Defaults to ./lit-localize.json

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 specified

Array of filenames or glob patterns matching the JavaScript or TypeScript files to extract messages from.

If both tsConfig and inputFiles are specified, then inputFiles takes precedence.

tsConfig
string

Required unless inputFiles is specified

Path to a tsconfig.json or jsconfig.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 and inputFiles are specified, then inputFiles 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, and allLocales 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

output.outputDir
string

Required

Output directory for generated modules. A <locale>.[js|ts] file is generated for each targetLocale. 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" if tsConfig was specified.

Language to generate modules in.

output.outputDir
string

Required unless tsConfig is specified, in which case it defaults to that file's outDir. 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.

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.

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".