Skip to main content

Rigi Documentation

JSON parser
  • Parser ID: json.

  • Use cases: All source and target languages are available in one Excel file.

  • Key features:

    • Auto-encoding. The JSON parser supports UTF-8 encoding with or without BOM. The generated target files will have the same encoding as the source file.

    • Ignore duplicate entries. All Objects in a JSON Object shall have a unique Name. Duplicates are considered to be an error. The parser will skip duplicates without a warning.

    • Specify keys within objects that are to be used as string identifiers (keyPatterns).

    • Specify an exclusive list of keys that must be translated (selectKeys).

    • Specify a list of keys that must be ignored (skipKeys).

    • Specify a list of texts that must be ignored (skipSource).

    • Specify the field that represents the locale (selectLocale).

Parser settings

  • unixNewline

    If set, the parser will generate a Unix newline (\n). Otherwise, it will generate a Windows newline (\r\n).

  • writeUntranslated / writeTranslated / writeReviewed / writeValidated

    Specifies the strings that are to be written to the generated target json file (default: all true).

    If a value is set to false, the strings with those status values will not be written to the json file.

    writeTransatedReviewed (deprecated since version 0.9)

    Until version 0.8, it was impossible to write Translated or Reviewed strings to the generated JSON file separately. The same single setting (writeTransatedReviewed) specified whether strings with either of those states (Translated or Reviewed) should be written to the target JSON file or not. This setting is no longer in use.

    Warning

    If the writeTransatedReviewed setting is deselected, this can prevent the Translated and Reviewed strings from being written to the generated JSON file.

    If the following configuration is present, the Translated and Reviewed strings will not be written to the JSON file.

    1. Legacy setting writeTransatedReviewed is deselected.

    2. writeTranslated is selected.

    3. writeReviewed is selected.

  • keyPatterns

    Use keyPatterns to specify elements within objects that are to be used as part of the string identifier.

    This setting is best explained by an example. Assume that we have a JSON file that contains an array with a large number of objects.

    1.png

    If no keyPatterns have been specified, the parser will create the following string identifiers:

    0.post.title Product one
    0.post.object_id 52379
    0.details.menu_object_id.0 52379
    0.details.menu_object_id.1 Other
    0.details.settings.0.content   This is translatable content
    0.details.more_content.0 Blue door
    0.details.more_content.1 Blue roof
    0.details.more_content.2 Blue Window
    1.post.title Product two
    1.post.object_id 424242
    1.details.menu_object_id.0 424242
    1.details.menu_object_id.1 Other
    1.details.settings.0.content   This is translatable content for product 2.
    1.details.more_content.0 Red door
    1.details.more_content.1 Red roof
    1.details.more_content.2 Red window

    There are a few challenges here:

    1. The identifiers start with a number that indicates the position of the object. This causes issues if, after the next update, products are inserted, removed, reordered, etc.

    2. Entries are created for keys that should not be translated.

    Use the keyPatterns setting to specify regular expressions for strings in objects:

    ^post\.object_id$
    ^details\.menu_object_id\.0$

    Important

    If keyPatterns are defined, then objects in an array will not be auto-numbered.

    This results in the following string identifiers:

    post.52379.title                             Product one
    details.52379.settings.0.content   This is translatable content
    details.52379.more_content.0       Blue door
    details.52379.more_content.1       Blue roof
    details.52379.more_content.2       Blue Window
    post.424242.title                             Product two
    details.424242.settings.0.content  This is translatable content for product 2.
    details.424242.more_content.0       Red door
    details.424242.more_content.1       Red roof
    details.424242.more_content.2       Red Window
  • selectKeys

    Use selectKeys to specify elements within objects that are to be used as part of the string identifier.

    2.png

    Use the same settings from the keyPatterns example, but now the file is extended with some more attributes. 

    3.png

    Use the selectKeyssetting to specify regular expressions to only select the highlighted strings in the example:

    ^post\.\d+\.title$
    ^details\.\d+\.settings\.\d+\.content$
    ^details\.\d+\.more_content.\d+$

    The regular expressions include the identifiers (\d+)\.) that were introduced by the keyPatterns.

    This results in the following string identifiers:

    4.png

  • skipKeys

    Use skipKeys to ignore keys in the JSON file.

    skipKeys does not have any effect if selectKeys is defined.

    Specify the keys with regular expressions, similar to selectKeys.

  • skipSource

    Use skipSource to ignore texts that match specific patterns.

    Specify the patterns with regular expressions, similar to selectKeys.

  • selectLocale

    The JSON file can contain the locale of the language.

    Use selectLocale to specify the regular expression for the key that contains the locale.

    Keep this setting empty if it is not applicable.

  • processDuplicates

    The same key can occur multiple times.

    If this variable is set, each occurrence will be assigned a unique identifier. The parser will then extend the string identifiers of the duplicates by adding .NR1, .NR2, etc.

    If this variable is not set, the parser will only add one instance to the string list. When targets are generated, all instances will contain the same target text.

  • writeEntities

    Use writeEntities to write entities instead of the characters. The following entities will be written:

    <
    >
    &
    "
    '