Options
Configuration Options for Transloco Keys Manager
CLI Options
--help -h
--help -h
Displays the help menu for the Transloco Keys Manager.
Extract Command
--config -c
--config -c
Defines the root search directory for the Transloco configuration file. The default is process.cwd()
.
--project
--project
Specifies the targeted project. Defaults to defaultProject
. The sourceRoot
of this project, retrieved from the angular.json
file, prefixes the default input
, output
, and translationsPath
properties. Ensure full paths are provided when overriding these options. The Transloco configuration file is also searched in the project's sourceRoot
unless the config
option is explicitly provided.
If no angular.json
file is present, sourceRoot
defaults to src
.
--input -i
--input -i
Specifies the source directory for all files using translation keys. Defaults to [${sourceRoot}/app']
.
If a project is provided, the default input value is determined by projectType
. For libraries, the default is ['${sourceRoot}/lib']
.
--output -o
--output -o
Specifies the target directory for generated translation files. Defaults to ${sourceRoot}/assets/i18n
.
--fileFormat -f
--fileFormat -f
Sets the translation file format (json
or pot
). Defaults to json
.
--langs -l
--langs -l
Defines the languages for which translation files are generated. Defaults to [en]
.
--marker -m
--marker -m
Specifies the marker sign for dynamic values. Defaults to t
.
--sort
--sort
Sort the keys using JavaScriptโs sort()
method. Defaults to false
.
--unflat -u
--unflat -u
Determines whether to unflatten keys. Defaults to flat
.
When using unflattened files, "parent" keys cannot hold separate translation values. For example, if you have first
and first.second
, the translation file will represent this as:
{ "first": { "second": "โฆ" } }
.
During extraction, warnings will highlight keys requiring attention.
--defaultValue -d
--defaultValue -d
Defines the default value for generated keys. Defaults to Missing value for {{key}}
.
Supported replaceable placeholders:
{{key}}
: Complete key, including the scope.{{keyWithoutScope}}
: Key value without the scope.{{scope}}
: The key's scope.{{params}}
: Parameters used for the key.
--replace -r
--replace -r
Replaces the contents of a translation file if it already exists. Defaults to false
(merges files instead).
--removeExtraKeys -r
--removeExtraKeys -r
Removes extra keys from existing translation files. Defaults to false
.
--addMissingKeys -a
--addMissingKeys -a
Adds missing keys identified by the detective
. Defaults to false
.
Find Command
--emitErrorOnExtraKeys -e
--emitErrorOnExtraKeys -e
It emits an error and exits the process if extra keys are found. Defaults to false
.
Extra keys are those present in translations but not used in the code.
--translationsPath -p
--translationsPath -p
Defines the root directory path for translation files. Defaults to ${sourceRoot}/assets/i18n
.
Transloco Config File
If you installed transloco via the schematics, a transloco.config.ts
should have been created. Otherwise, you can just create a transloco.config.ts
in the project's root folder and add the configuration in it:
Last updated