computerline1z / okapi

Automatically exported from code.google.com/p/okapi
0 stars 0 forks source link

Need to improve how to specify extractable parts in JSON file #359

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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".

Original issue reported on code.google.com by victor.j...@gmail.com on 14 Aug 2013 at 2:39

GoogleCodeExporter commented 9 years ago
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.

Original comment by yves.sav...@gmail.com on 14 Aug 2013 at 3:35

GoogleCodeExporter commented 9 years ago
FYI: a new option to not use the key as the resname has been implemented.
See https://code.google.com/p/okapi/issues/detail?id=360
It'll be in the next snapshots.

It doesn't solve your issue, but may help getting you cleaner files.

Original comment by yves.sav...@gmail.com on 14 Aug 2013 at 4:37

GoogleCodeExporter commented 9 years ago
For the record:
json-path (https://code.google.com/p/json-path/) may be a good solution.
From Chase (http://tech.groups.yahoo.com/group/okapitools/message/3861)

Original comment by yves.sav...@gmail.com on 28 Aug 2013 at 8:22

GoogleCodeExporter commented 9 years ago
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.

Original comment by tingley on 28 Aug 2013 at 9:06

GoogleCodeExporter commented 9 years ago
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.

Original comment by tingley on 13 Nov 2013 at 11:36

GoogleCodeExporter commented 9 years ago
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.

Original comment by victor.j...@gmail.com on 14 Nov 2013 at 2:18

GoogleCodeExporter commented 9 years ago
Another example of structure requiring support:

 "table": [
 ["Petrol", "51 - 63 kW<br />(69 - 85 PS)"],
 ["Max. Speed", "171 km/h"],
 ["Engines", "1.0 or 1.2 litre"],
 ["Transmission", "4-Speed Automatic or 5-Speed Manual"],
 ["CO2 Emission", "as low as 95 g/km<br />(1.0 with ISG)"]
]

See email here: 
http://groups.yahoo.com/neo/groups/okapitools/conversations/messages/3853

Original comment by yves.sav...@gmail.com on 6 Jan 2014 at 11:12

GoogleCodeExporter commented 9 years ago
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.

Original comment by jhargrav...@gmail.com on 1 Apr 2014 at 12:50