I hope this is the right forum to ask this question. If it is not, please redirect me to a more suitable forum.
I am trying to understand the format of a Qt Linguist TS file. I have modified a file and when I try to open it I get the error message "Duplicate messages found in ...". The file contains indeed one context with two messages that have
- the same source
- a location with the same file name but different line numbers
- different translation
Here is the source code of a minimal file that gives this error:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="es">
<context>
<name>MyContext</name>
<message>
<location filename="../../../../../MyFile.cpp" line="605"/>
<source>Delete</source>
<translatorcomment>Menu option</translatorcomment>
<translation type="unfinished">&Borrar</translation>
</message>
<message>
<location filename="../../../../../MyFile.cpp" line="1572"/>
<source>Delete</source>
<translation>Eliminar</translation>
</message>
</context>
</TS>
To my knowledge, each message is identified by context, source and location so this should not be a problem because the line numbers are different. Notice also that you cannot combine the two message elements into one, because they contain different translation texts.
So it is not clear to me what can cause the error message. I am using Qt version 4.6.2. I have looked in the following documents: Qt Linguist Manual: Translator, Qt Linguist Manual: Programmers, Linguist TS file format, but in none of them I have found the information I am looking for, namely how each message is identified and what could cause the error message in Qt Linguist.
If you do not know the answer to this question, a link to further, more detailed information on the TS format would also be helpful.
UPDATE
I have found out that by using the optional tag TS/context/message/comment it is possible to have different translation texts for the same context/message/source, e.g.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="es">
<context>
<name>MyContext</name>
<message>
<location filename="../../../../../MyFile.cpp" line="605"/>
<source>Delete</source>
<comment>Comment 1</comment>
<translatorcomment>Menu option</translatorcomment>
<translation type="unfinished">&Borrar</translation>
</message>
<message>
<location filename="../../../../../MyFile.cpp" line="1572"/>
<source>Delete</source>
<comment>Comment 2</comment>
<translation>Eliminar</translation>
</message>
</context>
</TS>
The above file can be opened without errors.
This seems to solve my problem but it would be good to have some precise documentation about this format.