[Qt-interest] Translating a xml file using lupdate

Constantin Makshin cmakshin at gmail.com
Tue Sep 13 18:28:09 CEST 2011


lupdate doesn't support generating translations for arbitrary files.

There are 2 serious problems:
1) arbitrary files are... arbitrary -- there're way too many file formats to
support them all. Moreover, even common and standartized formats like XML
define only general file structure/layout, but can store data in various
structures, making lupdate unable to determine what should be translateable
and what shouldn't.
2) any user can modify any external file, "destroying" translations and
making all such translation attempts nearly useless.
On Sep 13, 2011 2:48 PM, "Jordan Tcolov" <mazzzterz at gmail.com> wrote:
> Just after I posted I found another solution.
>
> <?xml version="1.0" encoding="UTF-8"?>
>> <buttons_definitions>
>> <buttons>
>>
>> <!-- Two state buttons -->
>> <button id="0" name="POS">
>> <text0>QT_TRANSLATE_NOOP("XML_Buttons", "Position")</text0>
>> </button>
>>
>> <button id="1" name="PROGRAM">
>> <text0>QT_TRANSLATE_NOOP("XML_Buttons", "Program")</text0>
>> </button>
>>
>> </buttons>
>> </buttons_definitions>
>>
>
> It's better than the previous and I just have to remove QT_TRANSLATE_NOOP
> from the string when reading it which isn't that much of work, but I want
to
> ask if there is anyway that I can point lupdate that I want to translate
> text between the tags <text0></text0>, <text1></text1>, <text2></text2>
and
> so ?
>
>
> On Tue, Sep 13, 2011 at 13:24, Jordan Tcolov <mazzzterz at gmail.com> wrote:
>
>> Hi !
>> I have some text that are located in XML file and in my project I use
these
>> texts to show them on buttons and I want to translate them, but I don't
know
>> how to do that. I managed to workaround it to generate a ts file with
>> translation, but... I don't like the approach. Here is how I did it:
>>
>> Original not translatable file: somename.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>> <buttons_definitions>
>>> <buttons>
>>>
>>> <!-- Two state buttons -->
>>> <button id="0" name="POS">
>>> <text0>Position</text0>
>>> </button>
>>>
>>> <button id="1" name="PROGRAM">
>>> <text0>Program</text0>
>>> </button>
>>>
>>> </buttons>
>>> </buttons_definitions>
>>>
>>
>>
>> File with which I got translation in ts file: somename.xml.ui
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>> <class>XML_Buttons</class>
>>> <buttons_definitions>
>>> <buttons>
>>>
>>> <!-- Two state buttons -->
>>> <button id="0" name="POS">
>>> <text0><string>Position</string></text0>
>>> </button>
>>>
>>> <button id="1" name="PROGRAM">
>>> <text0><string>Program</string></text0>
>>> </button>
>>>
>>> </buttons>
>>> </buttons_definitions>
>>>
>>
>> I don't want to change the extension to "ui" and I don't want <class> and
>> <string> tags floating around. Is there any other way I can do this ?
>>
>> Thanks in advace.
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110913/2fbe2fe6/attachment.html 


More information about the Qt-interest-old mailing list