JSON Import / Export for Mobile

Using the JSON file format to import/export content

Within the Localize dashboard we provide you with an ability to import and export phrases and translations in various file formats.

You can also import/export Glossary terms.

Importing / Exporting

To see a general explanation of how importing and exporting works in Localize, click here. Be sure to adhere to the file requirements below so that Localize will be able to successfully read your files.

File Requirements

🚧

UTF-8 Character Encoding

Be sure that you are using the UTF-8 character encoding when working with the external files you are creating for importing purposes, so that special characters like accents are encoded properly.

The formatting in the JSON file is very specific. Use the following sample for guidance.
The JSON parser expects an array of Objects in the dictionary object.

This file format does not support key:value pairs for source:target language content. Instead, you supply the source language phrase in the translation object followed by its translation in the value object.

The following data is required:

  • sourceLanguage the language code of the source language

The following data is required when importing translations, and optional when importing source language content:

  • targetLangage the language code of the target language

Most of the following data is optional for each phrase, unless otherwise specified.

  • id (optional) this internal ID will be seen in any files exported from Localize
  • context (optional) a string that provides context for your translators
  • labels (optional) An array of strings that are labels to apply to the phrase
    • Note that any pre-existing labels on the phrase will be replaced by the ones in the import file.
    • Any labels added to the phrase in the file being imported will be added to the Localize dashboard.
  • url (optional) an array of URL(s) where that phrase was found in your site
  • phraseKey (required) a string containing the key part of a key: value pair
  • translation (required) a string that contains the source language phrase
  • value (optional)
    • If present, this is the translation of the source text
    • If no translation is available, use empty {}
{
  "sourceLanguage": "en",
  "targetLanguage": "es",
  "dictionary": [
    {
      "id": "5e5c35e2a97f3f0e92f311f9",
      "context": "this is context one",
      "labels": [
        "label1", "label2"
      ],
      "url": [
        "example.com/projects"
      ],
      "phraseKey": "chose-localize",
      "translation": {
        "We’re happy that we chose Localize for our localization efforts!": {
          "value": "¡Estamos contentos de haber elegido Localizar para nuestros esfuerzos de localización!"
        }
      }
    },
    {
      "id": "5e20b74d73d6dc0e833f066a",
      "context": "this is context two",
      "labels": [
        "label3"
      ],
      "url": [
        "example.com/what-we-do",
        "example.com/about"
      ],
      "phraseKey": "adding-phrases",
      "translation": {
        "We’ve been able to add new phrases and have them translated.": {}
      }
    },
    {
      "id": "5e05ff60b5f2a4f81803b695",
      "phraseKey": "canyons",
      "translation": {
        "Many people like to drive through the canyons to view the natural beauty of the space.": {
          "value": "A mucha gente le gusta conducir por los cañones para ver la belleza natural del espacio."
        }
      }
    }
  ]
}

Troubleshooting

If your import fails an error message will be displayed. Later, you can also view the error here under Import History.