The download section defines where to store translated files.
There are a lot of variables for the download section that you can use for building the output path and file.
Single output rule 🔗
For each of the translated files, the output path is generated using the pattern /path/${lang}/${file}
.
{
// ... other parts omitted for brevity ...
"download": {
"files": "/path/${lang}/${file}"
}
}
Full output configuration 🔗
{
// ... other parts omitted for brevity ...
"download": {
"folder": "output/path",
"metadataFileJson": "meta.json",
"metadataFileJs": "meta.js",
"metadataFileTs": "meta.ts",
"includeSourceLang": false,
"excludedLangs": ["cs", "de"],
"langAliases": {
"zh-Hant-TW": "zh-TW"
},
"langExpansions": {
"de": ["de-DE", "de-CH"]
},
"files": {
"group": "all",
"conditions": [ ... ],
"stop": true,
"changeExtension": "json",
"output": "path/${lang}/${file}"
}
}
}
Field | Default | Description |
---|---|---|
folder |
. | The base folder all operations are relative to. It can be a relative or absolute path. |
metadataFileJson |
— | The path/file to generate metadata in JSON format with the list of available languages |
metadataFileJs |
— | The path/file to generate metadata in Javascript format with the list of available languages and plural rules |
metadataFileTs |
— | The path/file to generate metadata in Typescript format with the list of available languages and plural rules |
includeSourceLang |
false | By default, the source language is not processed, only translated files are. |
excludedLangs |
[] | The list of languages to exclude from processing. |
langAliases |
— | Maps languages to different ones. |
langExpansions |
— | Adds additional languages to output; the same file will be saved several times. |
files |
[] | The rules to apply to all translated files. |
files.group |
— | Allows to filter rules using groups. See groups for more information. |
files.conditions |
[] | Allows for more complex filtering of rules. See conditions for more details. |
files.stop |
true | If true, no more rules are processed for the given file. Only makes sense if more output rules are defined. By default, the first matching rule stops processing for the file. |
files.changeExtension |
— | If defined, change the extension of the output file. Applied to the final output after resolving all variables. |
files.output |
— | The pattern for generating output path and file. Use variables to build the pattern. |
Multiple output rules 🔗
You can use an array for files
and combine single output rules with full output configurations:
{
// ... other parts omitted for brevity ...
"download": {
// ..
"files": [
"path1/${lang}/${file}",
{
"conditions": [ ... ],
"stop": true,
"output": "path2/${lang}/${file}"
}
]
}
}
When more rules are defined, each of the translated files goes through all of them.
You can store all or some of the files in multiple locations. When using more rules, conditions and stop are useful concepts.
How download works 🔗
- Your files are downloaded from our servers.
- Each of the files goes through all the rules in the order defined in the
files
section. - Rules with conditions evaluated to false are skipped.
- When the rule is valid (conditions are evaluated to true) and stop is true, no more rules are processed.
Example with more output locations 🔗
{
// ... other parts omitted for brevity ...
"download": {
// ..
"files": [
{
"stop": false,
"output": "backup/${lang}/${file}"
},
{
"conditions": "!empty: ${scriptCode}",
"stop": true
},
{
"conditions": "!empty: ${regionCode}",
"stop": true,
"output": "withRegion/${langLsrUnderscore}/${file}"
},
"withLang/${lang}/${file}"
]
}
}
- All files are stored using
backup/${lang}/${file}
pattern, and the processing is not stopped and continue. - If the locale of the given file contains script code, the processing is stopped.
- If the locale of the given file contains region code, it’s saved using
withRegion/${langLsrUnderscore}/${file}
pattern, and the processing is stopped. - All other files are stored using
withLang/${lang}/${file}
Filtering untranslated strings 🔗
By default, when the output file is generated, Localazy uses texts from the source languages when the translation in the exported language is missing.
This approach is safeguarding you from missing keys that can lead to crashes in some solutions/frameworks.
This feature can be disabled by adding filter_untranslated
to features in the upload section and reuploading your source language file. It’s not available for all file formats, so please consult the documentation for more details.
Important note 🔗
Stored files overwrite any of existing files. Be careful!
Test before storing 🔗
Run the Localazy CLI with parameter -s
to output the list of files that are about to be written before you download and store translated files.
This way, you are sure everything is stored correctly, and you are not about to mess your project.
The parameter -s
switches CLI to the simulation mode - everything is processed as usual, but the actual storing is not performed.
Listing files on server 🔗
To list all files for the given project, you can run localazy list
with the minimal configuration:
{
"writeKey": "your-apps-write-key",
"readKey": "your-apps-read-key"
}