Important: Please read the Qt Code of Conduct -

[solved]Translation doesn't work.

  • I am using qsTr in my qml file, e.g.

    @Text { text: qsTr("Location"); font.pointSize: 15; color: "white"; anchors.centerIn: parent; }@

    in cpp file I am loading qm file
    @QTranslator tr;

    this is part of tr file:
    @<?xml version="1.0" encoding="utf-8"?>
    <TS version="2.0" language="ru_RU">
    <location filename="qml/debugWFG/CollapsiblePanel.qml" line="85"/>
    <location filename="qml/debugWFG/CollapsiblePanel.qml" line="106"/>
    <source>Source list</source>
    <translation>Список источников</translation>
    <location filename="qml/debugWFG/CollapsiblePanel.qml" line="127"/>
    <source>Add new source</source>
    <translation>Добавить источник</translation>
    <location filename="qml/debugWFG/CollapsiblePanel.qml" line="148"/>
    <source>Ranking management</source>
    <translation>Управление ранжировкой</translation>
    <location filename="qml/debugWFG/CollapsiblePanel.qml" line="169"/>
    <source>Extra settings</source>
    <translation>Дополнительные настройки</translation>
    <location filename="qtquick2applicationviewer/mylogic.cpp" line="109"/>

    due to this file I get debugWFG_ru.qm by lrelease (

    translation doesn't work. help please, what's wrong?

    p.s. whole project you can find here:

  • Lifetime Qt Champion


    Are you sure the file can be found ? Is it in your source directory ? If so and you are using shadow build, it won't find it. Copy the translation file next to your executable and try again.

  • Oops, thanks - I really forgot to put qm file next to the exe. But in general, initially I had problem with translation in another project - information about this problem is in the post above.

  • P.S.
    return true

  • Lifetime Qt Champion

    Did you had a look at the "online internationalization qml example": ? There's also a link to a complete example that might interest you.

    Hope it helps

  • Yes, I've already seen it. But there is another project type and Qt version.
    I used these manuals:
    It still doesn't work :(

  • Lifetime Qt Champion

    What do you mean by other project type and Qt version ?

  • I use Qt 5.1 and QtQuick2ApplicationViewer instead of QmlApplicationViewer

    But I've already tried to put my translation files(qm & ts) into subdirectory of the root QML file, as it said in article you posted. Unfortunately it didn't help

  • It turned out that it's not allowed to setMainQmlFile before installing QTranslator

Log in to reply