Need to improve how to specify extractable parts in JSON file

Issue #359 resolved
Former user created an issue

Original issue 359 created by victor.jeanm... on 2013-08-14T14:39:10.000Z:

  1. Drag and Drop a JSON file
  2. Select "Translation Kit Creation"
  3. Choose "Generic XLIFF" and "Execute"

Here a sample
"description":"Localized strings in English",
"keys":{
"INDX_WELCOME":{
"value":"Welcome"
},
"INDX_LOGOUT":{
"value":"Logout"
}

The XLIFF is like:

<trans-unit id="7" resname="description">
<source xml:lang="en-us">Localized strings in English</source>
<target>Chaînes localisées en français</target>
</trans-unit>
<trans-unit id="8" resname="value">
<source xml:lang="en-us">Welcome</source>
<target>Bienvenue</target>
</trans-unit>
<trans-unit id="9" resname="value">
<source xml:lang="en-us">Logout</source>
<target>Déconnexion</target>
</trans-unit>

but it should be

<trans-unit id="7" resname="description">
<source xml:lang="en-us">Localized strings in English</source>
<target>Chaînes localisées en français</target>
</trans-unit>
<trans-unit id="8" resname="INDX_WELCOME">
<source xml:lang="en-us">Welcome</source>
<target>Bienvenue</target>
</trans-unit>
<trans-unit id="9" resname="INDX_LOGOUT">
<source xml:lang="en-us">Logout</source>
<target>Déconnexion</target>
</trans-unit>

The 2 last "resname" should not be "value".

Comments (8)

  1. Former user Account Deleted

    Comment 1. originally posted by @ysavourel on 2013-08-14T15:35:51.000Z:

    The JSON Filter is very basic. It extracts objects in the form name/value pairs and assumes the left side of the group is the resname.

    Depending on the type of structure in the JSON file that may or may not correspond to what you want.

    To support more complex structures, for example where the resname is the name of the parent object rather than the name of the object, like in your case, we would need to implement some options.
    It's certainly doable, along with other patterns (e.g. pairs of objects where the value of the first object is the resname and the value of the second object is the value to translate, etc.)

    I've changed the issue to a request for enhancement.

  2. Former user Account Deleted

    Comment 4. originally posted by @ysavourel on 2013-08-28T21:06:23.000Z:

    Looking at the javadoc for that implementation briefly, one sticking point is that we may need to do extra work to produce an implementation that can identify matching nodes, instead of just returning them. Otherwise it's going to be difficult to produce a proper skeleton. Although I suppose we could just write a custom merge that parses the JSON tree, applies the translation, and then re-flattens it from scratch.

  3. Former user Account Deleted

    Comment 5. originally posted by @ysavourel on 2013-11-13T23:36:17.000Z:

    Looked at it further this morning; I'm not even sure *that* works. The problem is that if you select a string value by path, you just the strings back, not any kind of pointer to the location. This makes even replacing the value (ie, with a reference) seemingly impossible.

    So we'd need to write our own implementation, maybe.

  4. Former user Account Deleted

    Comment 6. originally posted by victor.jeanm... on 2013-11-14T14:18:40.000Z:

    The JSON files were built with the same flexibility than XML. The best way I found to handle them, was to convert them to XML, and so, I was able to use regular XML process.

  5. Former user Account Deleted

    Comment 8. originally posted by @ysavourel on 2014-04-01T00:50:41.000Z:

    You can now enable full key names (off by default). The above key names would be:

    keys/INDX_WELCOME/value
    keys/INDX_LOGOUT/value

    You can write exception regex that will match on INDX_WELCOME|INDX_LOGOUT

    The table structure that Yves sites as an example is also supported by the new parser.

  6. Log in to comment