Plugin source location: <serge_root>/lib/Serge/Engine/Plugin/parse_json.pm
This plugin is used to parse arbitrary JSON data structures. It uses regular expressions as a configuration parameter to match translatable nodes in the JSON object tree, and to identify the nodes whose content needs to be treated as HTML which needs to be parsed additionally using the parse_php_xhtml parser.
If your JSON is a plain dictionary in "key" : "value"
format, where all keys need to be translated, use the parse_json_keyvalue plugin instead.
This is a validating parser, but it parses JSON in a relaxed mode. Specifically, it allows commas after the last element of the array or dictionary, and hash-style comments (see JSON.pm documentation for more information). In case JSON format validation fails, the plugin can send an error report to specified recipients. If no email settings are provided, it will simply report the error in the console output.
Please see the example configuration file below to learn why only title
and certain description
nodes are extracted here for translation.
When JSON document is parsed, each node in it is given its path, and this path is what path_matches
and path_doesnt_match
regular expressions should match against (see the example configuration file). This is how the paths are constructed, given the example JSON file above:
The constructed path to a node is also extracted as a hint along with the corresponding string.