JSON filter: Use select key-value pairs as notes in XLIFF2

Issue #751 resolved
Kuro Kurosaka created an issue

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.

Comments (3)

  1. Kuro Kurosaka reporter

    Additional request from this user: Have an option not to include ITS related namespace declaration in the top level <xliff> tag, as their system gets confused by that.

    I am adding 'includeIts" option with the default true (the current behavior), following the same option found in "Generic XLIFF" package writer.

  2. Kuro Kurosaka reporter

    This feature has been implemented and merged in pull request #271.

    A new config item added to JSON Filter:

    • noteProducingKeys: A comma separated list of keys that will be transferred to <note>
    • Comma-separated list of simple keys, values of which to appear as <note> in XLIFF on Rainbow

    A new config item added to XLIFF v2 package writer:

    • includeIts: Boolean. true (default) includes ITS related namespace declarations in <xliff> tag.
    • Include ITS markup when available on Rainbow for XLIFF v2 (Beta) Options dialog selectable for Rainbow Translation Kit Creation step
  3. Log in to comment