Type remapping allows uploading files and converting them to different file types.

If you need to convert between different file types on download, refer to Format Conversions.

Use Case #️⃣

Type remapping is useful when migrating from old file formats or uploading existing translations only available in a file with a different format.

How It Works #️⃣

The file is uploaded to Localazy servers using the type provided in the upload rule and is parsed using the corresponding parser.

Extracted keys are processed and adapted by type remapping and imported as a file with a different type.

The Configuration #️⃣

Type remapping is part of the upload’s file rule:

{
  "upload": {
    "files": {
      "type": "csv",
	  "file": "existing_file.json",
      "lang": "de",
      "remap": {
        "type": "json",
        "flatten": ".",
        "nest": ".",
        "plural": "object",
        "array": "array"
      }
    }
  
  }
}
Field Default Description
type - The target type the file is required to be converted to. Required property.
flatten - Text used as a separator for converting nested keys to flatten ones. Optional. If not provided, nested keys are not flattened.
nest - Text used as a separator for changing keys to nested ones. Optional. If not provided, keys are not changed in any way.
plural - Optional specification of plural type to be used. Must be supported by the target format. If not provided, plurals are converted to the type’s default format.
array - Optional specification of array type to be used. Must be supported by the target format. If not provided, arrays are converted to the type’s default format.

Available Types #️⃣

In Localazy, the file is identified not only by its path and file name, but also by its type, so you have to select the correct type if using type remapping to upload content to an existing file.

Available types:

  • android
  • json
  • json-multilingual
  • arb
  • require-js
  • json-mozzila
  • ios-strings
  • ios-plist
  • ios-stringsdict
  • resx
  • yaml
  • yaml-rails
  • yaml-multilingual
  • po
  • json5
  • json5-multilingual
  • hjson
  • hjson-multilingual
  • js
  • js-multilingual
  • properties
  • ini
  • ini-multilingual
  • php
  • php-multilingual
  • qt-ts
  • csv
  • csv-multilingual
  • neon
  • neon-multilingual
  • toml
  • toml-multilingual
  • excel
  • excel-multilingual
  • ods
  • ods-multilingual
  • tmx
  • xcstrings

Example #️⃣

Let’s assume that we have a simple JSON file en.json:

{ 
	"key_1": { 
		"key_11": { 
			"key_111": "Key 111 (nested)" 
		} 
	}, 
	"key2": "Key 2", 
	"key3": "Key 3" 
}

It can be easily uploaded by a simple CLI configuration:

{
	"writeKey": "---",
	"readKey": "---",
	"upload": {
		"files": {
			"type": "json",
			"pattern": "en.json", 
			"file": "remap_test_file.json", 
			"lang": "en", 
			"path": ""
		} 
	} 
}

We have old CSV-based translations to the Czech language:

key;cs
key_1->key_11->key_111;Klic 111 (vnořený)
key2;CS: Klic 2
key3;CS: Klic 3

With the following configuration, we can upload this CSV file and convert it to JSON. Localazy will correctly add content as translations to the JSON file we uploaded before.

As we defined nest property, the key key_1->key_11->key_111 will be correctly nested creating desired structure to match our JSON.

{
  "writeKey": "---",
  "readKey": "---",
  "upload": {
    "files": {
      "type": "csv",
      "features": ["delimiter_semicolon"],
      "pattern": "cs.csv",
      "file": "remap_test_file.json",
      "lang": "cs",
      "path": "",
      "remap": {
        "type": "json",
        "nest": "->"
      }
    }
  }
}