Translate JSON files

What are JSON files?

JSON files are one of the language files used to localize Javascript applications. The file format is monolingual and contains pairs of keys and their translation usually represented as a Hash.

JSON files come in 5 different flavors, which are described further below in this document. The file extension can either be .js or .json.

WebTranslateIt is a software localization platform that can help localize JSON .js or .json files.

Flavour 1: Classic JSON files

These JSON files are a Hash of key and values, which can be nested. Pluralization is possible using the reserved sub-keys: zero, one, two, few, many, other. Plural values will be imported as plural segments.

{
  "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"
    }
  }
}

Flavour 2: JSON files containing arrays

JSON files containing arrays are also supported. Keys containing arrays will be imported as follow: string1.example[0].title and string1.example[0].text.

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

Flavour 3: i18next

We support JSON files used by i18next. Please refer to our documentation page about i18next.

Flavour 4: Format.JS (ex-React-intl) — partial support

We have partial support for Format.JS (previously known as react-intl) files. In Format.JS files, one segment is the combination of a description and a message. This hash will be imported as one segment:

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

However, Format.JS’s plural forms won’t be imported as plural segments, due to the fact that plural forms can be nested in Format.JS files. Our architecture allows 1 segment to contain 1 segment with plural rules, but not 1 segment with several plural rules

{
  "catsAndDogs": {
    "raining": "It’s raining {countCats} {countCats, plural, =0 {no cats} one {a cat} other {cats}} and {countDogs} {countDogs, plural, =0 {no dogs} one {a dog} other {dogs}}",
  }
}

The above example is capable of representing the following sentences:

  • It’s raining no cats and no dogs
  • It’s raining a cat and no dogs
  • It’s raining cats and no dogs
  • It’s raining no cats and a dog
  • It’s raining a cat and a dog
  • It’s raining cats and a dog
  • It’s raining no cats and dogs
  • It’s raining a cat and dogs
  • It’s raining cats and dogs

On the above example, the variable placeholders countCats and countDogs are modifiers for 2 different plural rules. Supporting this with WebTranslateIt’s architecture would mean having to edit 9 times the same text for English plural rules, so we thought that in this case, not importing the plural rule and letting users translate directly Format.JS’s plural rule would be much more efficient.

Flavour 5: Flutter .arb files — partial support

We have partial support for Flutter .arb languages files.

However, Flutter’s plural forms won’t be imported as plural segments, due to the fact that plural forms can be nested in .arb files. Our architecture allows 1 segment to contain 1 segment with plural rules, but not 1 segment with several plural rules

"nWombats": "{count,plural, =0{no wombats} other{{count} wombats}}",
"@nWombats": {
  "description": "A plural message",
  "placeholders": {
    "count": {

    }
  }
}

Related File Formats

Related Platforms