[Qt-qml] Creating single translation file from multiple qml files

Matti Mäki matti.maki at iki.fi
Tue Sep 13 13:00:07 CEST 2011


13.9.2011 12:37, Bo Thorsen kirjoitti:
> Den 13-09-2011 10:23, Matti Mäki skrev:
>> Hi,
>>
>> In a meego example of QML localisation[1] lupdate was run with *.qml
>> argument. I tried this on my Qt SDK on Win XP, lupdate.exe from Qt 4.7.3
>> Desktop:
>>
>> C:\development\Qt\myproject>
>> C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\lupdate.exe *.qml -ts
>> qml-translations.en.ts qml-translations.fi.ts
>>
>> which results in
>>
>> "lupdate error: File '*.qml' does not exist"
>>
>> Do I have to create ts-file for each qml separately (35+ files) or is
>> there A Better Way(TM)? It might be quite a mess to keep all those files
>> up to date during development. It is easy to setup a script for creating
>> the ts-files but managing the actual translation work would be a lot
>> easier with single file.
> You run lupdate with the .pro file as argument. lupdate grabs the list
> of files from the pro and pri files directly.
How do I tell in the .pro-file about the qml files? The files reside in 
a separate project with its own .qmlproject file and are included to the 
application in a qrc file. I tried listing them in OTHER_FILES but 
lupdate didn't process them.
>
> If you use cmake, you have to create a list of the files necessary for
> lupdate. You can see an example of doing this in my simple example
> application "fseditor" here: http://fioniasoftware.dk/fseditor.html.
As a workaround maybe I can create list of qml files with a custom 
script, run each through lupdate and then combine them into single .ts 
with lconvert.exe but then it would always lose the earlier 
translations. I think this is not quite viable in case there will be 
multiple translation rounds as the translator should start each round 
with empty file and copy paste older translations from previous 
.tm-file. Sounds a bit error-prone.

Another workaround would be moving all strings from qml files to C++ and 
adding them to root context. Then lupdate would indeed find them without 
any problems. Maybe this is the easier way although it will in turn make 
it more difficult to do pure pure qml development without the c++ engine.

/matti


More information about the Qt-qml mailing list