Transifex

  • Documentation
  • File formats
  • Structured JSON

Structured JSON

Associated file extensions: .json

i18n type : STRUCTURED_JSON

Structured JSON uses an JSON-based format for localization. There are five types of entries: string, context, developer_comment, character_limit and plurals.


Sample:

{
   "singular_key":{
      "string":"This is a regular string."
   },
   "total_files":{
      "string":"{ item_count, plural, one {You have {file_count} file.} other {You have {file_count}files.} }",
      "context":"Additional context:....."
   },
   "special_chars":{
      "string":"{ cnt, plural, one {This is Sam's book.} other {These are Sam's books.} }",
      "developer_comment":"This is a pluralized string with special character"
   },
   "gold_coins":{
      "string":"{ count, plural, one {You have one gold coin.} other {You have {cnt} gold coins.} \n}",
      "character_limit":150
   },
   "key_1":{
      "key_nested_1a":{
         "string":"localize"
      },
      "key_nested_1b":{
         "key_nested_1ba":{
            "string":"translation tools"
         },
         "key_nested_1bb":{
            "string":"{ sth, plural, one {minute} other {{minute_count} minutes} }"
         }
      }
   },
   "parent_key":{
      "child_key":{
         "string":"This is a key from a child",
         "context":"Noun",
         "developer_comment":"This is a comment.",
         "character_limit":150
      }
   }
}
  • string: Translatable string (Required)
  • context: Small segment of text used to differentiate from entries with the same string value
    (Optional)

Structured_JSON_Context_Image.JPG#asset:6293

  • developer_comment : Small description to give context to translators about how the string
    should be translated (Optional)

Structured_JSON_Developer_Notes_Image_small.JPG#asset:6295

  • character_limit : Maximum number of character the translation can have (Optional)

Structured_JSON_Character_Limit.JPG#asset:6296

Plurals Support

Transifex offers support for pluralized entries in JSON based on ICU's message format specifications (plural subset). For more details about how pluralized strings are handled by Transifex, please refer to our documentation guide.

Example:

"files" : "{count, plural, one {You have {count} file.} other {You have {count} files.}}"

For pluralized strings that follow a different structure like:

"string" : "{number, plural, =1 {1 New}, =2 {# New}}"

the Structured JSON parser will handle them as simple entries in the editor as follows:

Structured_JSON_Plurals_Support.JPG#asset:6297


Escape behavior

The way special characters are escaped by the Structured JSON parser is exactly the same as in the case of Key Value JSON parser.

Lists

JSON lists are not supported. So, if your file contains the following content:


{
   "singular_key":{
      "string":"This is a regular string."
   },
   "json_list":[
      "Item 1",
      "Item 2",
      "Item 3"
   ]
}```

then the parser will parse the file ignoring the json_list entry (this entry won’t be available in Transifex Web Editor). Once the translations are done, the generated file will look like this:

{
   "singular_key":{
      "string":"This is a regular string."
   },
   "json_list":[
      "Item 1",
      "Item 2",
      "Item 3"
   ]
}

i.e. the json_list entry will be included in the exported translation file in the source language.

Download Modes

  • Download file to translate: Any untranslated entries will be returned empty so that translators
    know which are the untranslated ones they need to work on.
  • Download for use: Any untranslated entries will be returned in the source language.
  • Download only reviewed translations: Any untranslated string or unreviewed translation will be
    returned in the source language.
  • Download for translation as XLIFF: The translation file will be generated in the .xliff format and
    include both translated and untranslated strings. The latter ones will be returned without containing target elements.
  • Download untranslated strings as XLIFF: The translation file will be generated in the .xliff
    format and include only the untranslated strings.