Hi,

On 23/04/2010, at 8:43 PM, ext Pertti Kellomäki wrote:

> A further question on internationalization. I have translations for 
> test.qml in a file called test_fi_FI.qm, and I can verify that it works 
> by running the qml viewer as
> 
>    qml -translation test_fi_FI.qm test.qml
> 
> I tried to make my own qml viewer locale aware, and following the 
> arrowpad example I have this piece of code:
> 
>     QString locale = QLocale::system().name();
>     QString translationFile = 
> QString(QString(argv[1]).replace(QRegExp(".qml$"), "_") + locale);
>     std::cerr << "Translations in " << translationFile.toStdString() << 
> std::endl;
>     QTranslator translator;
>     if (translator.load(translationFile)) {
>       std::cerr << "Succesfully loaded translations." << std::endl;
>     } else {
>       std::cerr << "Error loading translations." << std::endl;
>     }
>     app.installTranslator(&translator);
> 
> When I run test.qml with my viewer, it reports that loading of 
> translations went ok, but it still shows the non-translated text.
> 
> I looked at the qml view code, and the only significant difference I 
> spotted is that I explicitly create the QDeclarativeEngine and use 
> QDeclarativeComponent::create(), whereas the qml viewer uses 
> QDeclarativeView. Could this make a difference as far as translation goes?

How are you loading the QML into the QDeclarativeComponent, via url or setData? 
One guess is that the translation context (which is based on the base file 
name) isn't being set correctly. For example if you are using setData and not 
passing in the actual base URL this might cause issues. I can look into it 
further if you can provide a simple example to reproduce (preferably attached 
to a report on bugreports.qt.nokia.com:-).

Regards,
Michael
_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to