Saturday, May 14, 2011

Qt Designer texts: disambiguation vs comment

Qt Designer has two fields regarding translations for text properties (e.g. the text of a Label, or the tool tip of a Widget) disambiguation and comment (that unfortunately map to the comment (for disambiguation) and extracomment (for comment) XML attributes in the .ui file), let me give a bit of explanation of what they mean since I've found some errors on it's usage while fixing a bug we had in our translation scripts (aka scripty).

First some background on how translation works, when you ask for a string to be translated (e.g. "Run") you can give some context that acts as an extra key (e.g. "Verb" or "Noun") so translators can do different translations
(Run, Verb) -> Ejecutar
(Run, Noun) -> Ejecución
This extra key is what you write in the disambiguation field

On the other hand when you write something in the comment field, it only appears as a comment to the translator, so if you have two texts with the same text (e.g. "Run") and different comments (e.g. "Verb" or "Noun") it will not work, so only use the comment field to give extra information for fields whose text is unique but the meaning might not be easy to understand to the translator.

So there is no reason at all to do things like
<string extracomment="General information">General information of the identity.</string>
since you are giving less information in the comment field than in the text itself

Also just remember it makes no sense to add disambiguation or comment to a text property that is empty since at the moment we can not translate empty strings, so things like this are also not useful at all
<string extracomment="Open file dialog"/>

Finally if you use KUIT markers they need to be in the disambiguation field

2 comments:

Orestes Mas said...

Interesting. Let me say that this translator behaviour may be induced by two things:

1) The somewhat confusing labelling of "disambiguation" and "comment" fields in Qt Designer.

2) How this disambiguation fields appear in lokalize (under "unit metadata" window): Designer's disambiguation field appears under a boldface "Context:" label in lokalize, while Designer's comment field doesn't appear under any heading in lokalize. Worst, it appears under an unrelated "Add a comment..." link, which is confusing, and also the comment field is merged with other (auto-generated) context in the same line.

Hope some day lokalize's developers will fix it.

Orestes Mas said...

Sorry: for "translator behaviour" i meant "developer behaviour", obviously...