JSON filter: Use select key-value pairs as notes in XLIFF2
*Created by: Kuro Kurosaka *
Use case: in this localization workflow, a system generates an array of JSON object that looks like this:
{
"strings": [
{
"key": "xyz/contrib/title",
"value": "WHAT IS OKAPI MEMBERSHIP?",
"description": "This is a title of the contribution page",
"descriptionForStringsFile": "/contrib/title",
"valueForStringsFile": "WHAT IS OKAPI MEMBERSHIP?"
},
{
"key": "xyz/contrib/body",
"value": "Contribute to <a href=\"http://okapiframework.org\">Okapi project</a> and make the world a better place!",
"description": "The main body of the contrib page.",
"descriptionForStringsFile": "/contrib/body",
"valueForStringsFile": "WHAT IS OKAPI MEMBERSHIP?"
},
...
]}
Here the value for the key "value" contains the string to be localized and all others don't. But we want the values for the keys "key" and "description" to appear in XLIFF2 as a notes like:
<notes>
<note appliesTo="source" category="key">xyz/contrib/title</note>
<note appliesTo="source" category="description">This is a title of the contribution page</note>
</notes>
This enhancement should also support Okapi's default XLIFF 1.2. When XLIFF 1.2 is used, there won't be the surrounding <notes> element and the attribute names would be annotates and from.
Notes will be appear as a subelement of the <unit> (or trans-unit in XLIFF 1.2) normally. But when the subfilter is enabled, it should appear as a subelement of the <group> that contains one ore more <unit> elements that the subfilter generates.
JSON Filter already has a way to specify the keys where the values should be extracted for translation. To support the above use case, we need to add a new configuration item where a list of keys which should be transferred to the <note> element in XLIFF2 along with the values.
Also implement a configuration item "includeIts", available in XLIFF 1.2 package writer, for XLIFF 2.0 package writer.