Not scoped translations will be placed in a single file, called app.json
Configuration
Add the command in package.json, and provide at least the supported languages:
Available options:
supportedLangs Supported langs. Required
basePath The base path. Default to './'
sourceFilesPaths Paths to files to search for translations. Default to 'src'
excludedPaths Paths to exclude
assetsPath Path to translation files: [basePath]/[assetsPath]/[lang]/*.json. Default to 'i18n'
format The format of the translation files. Default to 'json'
filename Filename for not scoped translations. Default is 'app'
fallback Optional function to implement a fallback strategy
autoKeys Automatically handle keys for each string. Default is false
unusedKeys Automatically remove unused keys from assets, except in runtime assets
runtimeAssets Comma-separated list of runtime assets to preserve
keySeparator Separator of nested keys. Default is '.'
keyValueSeparator Key-value separator. Default is '@@'
Note. Currently, only json is supported as format
Running
Updating
If you add new translations in the components, or a new language, they will be merged into the existing files without losing the translations already made.
Using it programmatically
Rather than using the command, you can invoke qwikSpeakExtract function:
Translations fallback
By default, the extract command uses the default value of translations as the initial value when provided. You can extend this behavior, to complete the missing translations by taking them from another language, by implementing a custom function with this signature:
and pass the function to fallback option:
For example, if you want to use the default language translations for missing values in other languages:
Automatic removal of unused keys
To remove unused keys from json files, you need to enable the option and provide a comma-separated list of runtime file names: