Documentation section

Download Reference

Learn about how to configure where to store your translated files.

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"],
    "files": {
      "group": "all",
      "conditions": [ ... ],
      "stop": true,
      "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.
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.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 download 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}

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 app, you can run localazy list with the minimal configuration:

{
  "writeKey": "your-apps-write-key", 
  "readKey": "your-apps-read-key"
}