Translate JSON files

WebTranslateIt supports JSON files as used by the i18next and i18n-node JS libraries, as well as JSONP files.

JSON file example

Classic JSON files

{
  "error": "A problem occurred.",
  "hello": "Hi",
  "greetings": "Hello there",
  "timeago": {
    "x_days": {
      "one": "1 day ago",
      "other": " days ago"
    },
    "x_seconds": {
      "one": "1 second ago",
      "other": " seconds ago"
    }
  }
}

JSON files containing arrays

JSON files containing arrays are also accepted:

{
  "string1": {
    "example": [
      {
        "title": "This is a test!",
        "text": "This is some text."
      },
      {
        "title": "This is a test.",
        "text": "This is some text."
      }
    ]
  }
} 

i18next

Plural forms as used by i18next are also accepted.

{
  "ar": {
    "translation": {
      "//": "i18next",
      "key": "singular",
      "key_plural_0": "zero",
      "key_plural_2": "two",
      "key_plural_3": "few",
      "key_plural_11": "many",
      "key_plural_100": "plural"
    }
  }
}
In order to best detect i18next files we’ll ask you to add a comment at the begining of your language file saying: `“//”: “i18next”`. i18next use many different plural forms which don’t mix well with normal keys ending with `_1`, `_2` and `_3` ☹️.

WebTranslateIt supports JSON files for i18next v1, v2 and v3. Projects set up before September 2018 are using i18next v1 by default. Projects set up after September 2018 are using i18next v3 by default. You can change the version of i18next you are using in the File Manager.

More information

i18next-style variables are recognized.

{
    "fr": {
        "ns.1": {
            "pluralTest": "singular",
            "pluralTest_plural": "plural",
            "pluralTestWithCount": "__count__item",
            "pluralTestWithCount_plural": "__count__items"
        }
    }
}

React-intl

react-intl files are also accepted and parsed in a particular way. Descriptions will be extracted out and displayed as a developer instruction.

{
    "key.confirmation.title": {
        "description": "{variable} Title for that dialog",
        "message": "Hello"
    }
}

Downloading JSON file with JSONP headers

You can download your files using the Show File API endpoint by appending the parameter ?callback=callbackName to the URL.

JSONP file example:

jsonCallback(
{
  "key1": "text1",
  "key2": "text2"
}
);