TextUnit setName() instead of setId() for tuid attribute

Issue #188 wontfix
Former user created an issue

Original [issue 188](https://code.google.com/p/okapi/issues/detail?id=188) created by robert.va... on 2011-10-10T09:44:48.000Z:

Hi,

try this code:

TextUnit tu = new TextUnit("myId"); tu.setSourceContent(new TextFragment("Haho"));

TMXWriter writer = new TMXWriter("file\_path..."); writer.writeTUFull(tu);

The expected output would be:

<tu tuid="myId"> <tuv xml:lang="en-gb"> <seg>Haho</seg> </tuv> </tu>

instead I get:

<tu tuid="autoID1"> <tuv xml:lang="en-gb"> <seg>Haho</seg> </tuv> </tu>

The solution is to use setName():

TextUnit tu = new TextUnit(); tu.setSourceContent(new TextFragment("Haho")); tu.setName("myId");

I'm using the Java API of Okapi, v. 0.14

tuid means Translation Unit ID so I'd expect to use the ID (in the constructor for instance) instead of name.

However ID does work if I'm using:

writer.writeTU(new TextFragment("Haho"), new TextFragment("Hoha"), "myId", null);

Comments (5)

  1. Former user Account Deleted

    Comment [1.](https://code.google.com/p/okapi/issues/detail?id=188#c1) originally posted by @ysavourel on 2011-10-21T02:41:55.000Z:

    Actually the semantic of TMX tuid is different from the of of Okapi's resource id: a resource id is unique within its type of resource, while the value of TMX tuid is undefined, and there are sometimes duplicates. And since we have to read as well as write we can't match tuid with id.

    In that sense it corresponds more to the resource's name, which is based on XLIFF's resname: something that is usually a unique id, but depending on the original format can have duplicates (like in Win resource files (ID\_STATIC)).

    One thing we could do when writing out with TMXWriter is use the name first, like now, but if the name is not present, instead of generating some auto-value, we could fallback to the id.

    Would this sound a valid work around?

  2. Former user Account Deleted

    Comment [3.](https://code.google.com/p/okapi/issues/detail?id=188#c3) originally posted by @fliden on 2012-06-06T05:25:25.000Z:

    The tmx filter maps tmx tuid to okapi name as well so I suggest we keep the reader and writer consistent. I think it will get too confusing if we start mixing it up. The bottom line is that TextUnit id needs to be unique and Tmx tuid does not. Since there's no follow-up response I suggest we close this issue.

  3. Log in to comment