Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved]Translation doesn't work.

[solved]Translation doesn't work.

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pavel_Osipyants
    wrote on last edited by
    #1

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

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

    in cpp file I am loading qm file
    @QTranslator tr;
    tr.load(QStringLiteral("debugWFG_ru"));
    qApp->installTranslator(&tr);@

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

    due to this file I get debugWFG_ru.qm by lrelease (http://yadi.sk/d/G1VDUYhjBEhre)

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

    p.s. whole project you can find here: http://yadi.sk/d/insf3sdRBEhtt

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pavel_Osipyants
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pavel_Osipyants
          wrote on last edited by
          #4

          P.S.
          tr.load(QStringLiteral("CollapsiblePanel_ru.qm"));
          and
          qApp->installTranslator(&tr);
          return true

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Did you had a look at the "online internationalization qml example":http://qt-project.org/doc/qt-4.8/declarative-i18n.html ? There's also a link to a complete example that might interest you.

            Hope it helps

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Pavel_Osipyants
              wrote on last edited by
              #6

              Yes, I've already seen it. But there is another project type and Qt version.
              I used these manuals:
              http://qt-project.org/doc/qt-5.0/qtlinguist/linguist-manager.html
              http://qt-project.org/doc/qt-5.0/qtlinguist/linguist-programmers.html
              It still doesn't work :(

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Pavel_Osipyants
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Pavel_Osipyants
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved