我希望這是提問這個問題的正確論壇。如果不是,請將我重定向到更合適的論壇。識別Qt Linguist翻譯文件中的消息(TS文件)
我想了解一個Qt Linguist TS文件的格式。我修改了一個文件,當我嘗試打開它時,我收到錯誤消息「在...中找到重複消息」。該文件包含確實與具有
- 相同的源
- 具有相同的文件名,但不同的行號
- 不同的翻譯
這裏的位置的兩個消息一個方面是源代碼最小的文件,讓這個錯誤:
<?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>
據我所知,每個消息是由上下文,來源和位置確定,所以這不應該成爲問題,因爲行號是不同的。還要注意,不能將兩個消息元素合併爲一個,因爲它們包含不同的翻譯文本。
所以我不清楚什麼會導致錯誤信息。我正在使用Qt版本4.6.2。 我查看了以下文檔:Qt Linguist Manual: Translator,Qt Linguist Manual: Programmers,Linguist TS file format,但是在他們中沒有一個我找到了我正在尋找的信息,即每個消息是如何識別的以及可能導致Qt Linguist中的錯誤消息的原因。
如果您不知道這個問題的答案,那麼有關TS格式的更詳細信息的鏈接也會有所幫助。
UPDATE
我們發現,通過使用可選的標籤TS /上下文/消息/評論也能夠 具有相同的上下文/消息/源,例如,不同的翻譯文本
<?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>
上面的文件可以打開沒有錯誤。
這似乎解決了我的問題,但最好有一些關於這種格式的精確文檔。
你的Qt版本? – menjaraz 2012-01-12 10:37:27
Qt 4.6.2。我會將這些信息添加到問題中。 – Giorgio 2012-01-12 10:44:57
您是否使用XML技術感覺舒適? – menjaraz 2012-01-12 10:52:59