December 13, 2010

SimonJudge SimonJudge
Lab Rat
70 posts

Qt Creator, localization and work flow

 

I have been looking at the instructions at http://doc.qt.nokia.com/4.7/declarative-i18n-i18n-qml.html to localize some qml. The workflow seems to be…

1) Under Ubuntu (as that’s only where I have mobility 1.1 working ok), in QT Creator IDE, I write code that needs a string
2) I surround the string with qsTr()
3) I run lupdate from the command line
4) I copy the file to Windows and create the translation in Qt Linguist (it only runs under Windows and Mac)
5) I copy the file back to Ubuntu
6) I run lrelease from the command line

This is a long workflow if I have to do this regularly. Is it possible to invoke lupdate and lrelease from Qt Creator and edit the .ts in Qt creator? (it doesn’t show up when I try to add the file to the project). If I drag the .ts file into Qt Creator I can edit it but it’s not obvious where to put the language pairs.

Thanks

Simon

5 replies

December 13, 2010

stuk stuk
Ant Farmer
545 posts

I use this on windows, i don’t know that linguist not work on linux.

December 13, 2010

QtK QtK
Lab Rat
1140 posts
stuk wrote:
I use this on windows, i don’t know that linguist not work on linux.

It does run on linux. Here [qt.nokia.com] is a screenshot of the same.

December 13, 2010

SimonJudge SimonJudge
Lab Rat
70 posts

I’ll answer my own question. Maybe some people can suggest an even simpler workflow.
First of all, http://doc.qt.nokia.com/4.7/declarative-i18n-i18n-qml.html is a bit misleading/simplisitic as it’s a one file project and the naming conflicts with what I found at http://doc.trolltech.com/stable/qmlviewer.html

Here’s what I am doing now….

Aggregate all your file string instances (that are in all QML files) in one file per language and name like qml_en.ts (for English). There’s no need to run lupdate (it just finds qsTr for you which you probably already know as you added the string – you might like to run it once though to get the .ts file syntax).

Manually edit qml_en.ts (drag and drop into Qt creator). You then only have to run lrelease i18n/*.ts every time you change the file (good if QT Creator could do this automatically!). Change the QT Creator project settings (Project icon) to use the translation you wish to test e.g. add -translation qml_en.qm as QML viewer arguments.

Also, I found that qsTr() doesn’t work in a listmodel. You will get a run time error “cannot use script for property value parameter”. Use QT_TR_NOOP() rather than qsTr().

In my opinion QT Creator should be doing a lot more for us… including detecting invalid uses of qsTr().

Simon

December 13, 2010

SimonJudge SimonJudge
Lab Rat
70 posts
QtK wrote:
stuk wrote:
I use this on windows, i don’t know that linguist not work on linux.

It does run on linux. Here [qt.nokia.com] is a screenshot of the same.

Interesting. Do you know where to find the download for this? The Windows and Mac downloads are at…
http://qt-apps.org/content/show.php/Qt+Linguist+Download?content=89360

Thanks

Simon

December 13, 2010

stuk stuk
Ant Farmer
545 posts

Are this link update to the latest version of linguist?
Last version is 4.7.1 here is 4.6.0.

SimonJudge wrote:
QtK wrote:
stuk wrote:
I use this on windows, i don’t know that linguist not work on linux.

It does run on linux. Here [qt.nokia.com] is a screenshot of the same.

Interesting. Do you know where to find the download for this? The Windows and Mac downloads are at…
http://qt-apps.org/content/show.php/Qt+Linguist+Download?content=89360

Thanks

Simon

 
  ‹‹ How to Assing an id property for dynamically created element.      How to extend the JavaScript environment in QML, reading a text file from js? ››

You must log in to post a reply. Not a member yet? Register here!