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. Successfully loaded .qm files, but translator remained empty
Forum Updated to NodeBB v4.3 + New Features

Successfully loaded .qm files, but translator remained empty

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 2.0k Views 2 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.
  • Q Offline
    Q Offline
    QTLeearn
    wrote on last edited by QTLeearn
    #1

    Hi,
    I used the following codes to load .qm files:

    success = mTranslator.load(mLangFilenames[index], mLangDirName);
    

    load function returns true, however when I tried to installTranslator:

     success = QGuiApplication::installTranslator(&mTranslator);
    

    the installation failed. I checked:

    mTranslator.isEmpty()
    

    it remained true after mTranslator.load, I also stepped into installTranslator in debugging, I found that it seemed that the isEmpty() returning true that caused the installTranslator to return false.
    So I assume that this caused the failure of installTranslator.
    Could you please kindly advise me on this issue? Should I provide more input arguments for the load function?

    Thank you!

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

      Hi,

      Did you check that your files are not empty ?

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

      Q 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you check that your files are not empty ?

        Q Offline
        Q Offline
        QTLeearn
        wrote on last edited by
        #3

        @SGaist I opened the .qm files in Qt creator, there are data displayed. Also I used the size() of QFile to check, it is 23 bytes, so I guess the .qm file is not empty

        Pablo J. RoginaP 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That seems pretty small for a translation file. Do you have any text translated ?

          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
          • Q QTLeearn

            @SGaist I opened the .qm files in Qt creator, there are data displayed. Also I used the size() of QFile to check, it is 23 bytes, so I guess the .qm file is not empty

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

            I opened the .qm files

            Please describe how do you created those .qm files.

            As @SGaist said, the size (23 bytes) seems pretty small.
            How many strings have you translated in the .ts files?

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            Q 2 Replies Last reply
            0
            • Pablo J. RoginaP Pablo J. Rogina

              @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

              I opened the .qm files

              Please describe how do you created those .qm files.

              As @SGaist said, the size (23 bytes) seems pretty small.
              How many strings have you translated in the .ts files?

              Q Offline
              Q Offline
              QTLeearn
              wrote on last edited by
              #6

              @Pablo-J-Rogina In QML text type I use qsTrID(), with //% //: etc. I used lupdate, lrelease to create .qm files. The program could successfully locate these qm files.
              Since I only have about 28 occurrences of text in QML so I don't think the .qm file is too small

              1 Reply Last reply
              0
              • Pablo J. RoginaP Pablo J. Rogina

                @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

                I opened the .qm files

                Please describe how do you created those .qm files.

                As @SGaist said, the size (23 bytes) seems pretty small.
                How many strings have you translated in the .ts files?

                Q Offline
                Q Offline
                QTLeearn
                wrote on last edited by
                #7

                @Pablo-J-Rogina Wait.... The project above is just an example, I also generated .qm files from another project( different amount of texts for sure), the weird thing was the qm file size was also 23 bytes.... I doubt whether the qm files were successfully generated?

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

                  I doubt whether the qm files were successfully generated?

                  As @Pablo-J-Rogina already asked - did you actually did some translations in your ts files?

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  Q 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

                    I doubt whether the qm files were successfully generated?

                    As @Pablo-J-Rogina already asked - did you actually did some translations in your ts files?

                    Q Offline
                    Q Offline
                    QTLeearn
                    wrote on last edited by QTLeearn
                    #9

                    @Christian-Ehrlicher We haven't implemented translations yet, as in .ts files:
                    <translation type="unfinished"></translation>
                    However there should be real texts displayed instead of the text IDs.

                    I first generated ts files by clicking Tools->External->Linguistic ->update in Qt creator, then by clicking release I created qm files. I also tried to use lupdate command to generate ts files, but errors occurred:
                    lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directory

                    I doubt there are kits related to language of Qt I didn't install? Thank you again for your help!

                    Pablo J. RoginaP 1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      How did you install Qt ?

                      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
                      • Q QTLeearn

                        @Christian-Ehrlicher We haven't implemented translations yet, as in .ts files:
                        <translation type="unfinished"></translation>
                        However there should be real texts displayed instead of the text IDs.

                        I first generated ts files by clicking Tools->External->Linguistic ->update in Qt creator, then by clicking release I created qm files. I also tried to use lupdate command to generate ts files, but errors occurred:
                        lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directory

                        I doubt there are kits related to language of Qt I didn't install? Thank you again for your help!

                        Pablo J. RoginaP Offline
                        Pablo J. RoginaP Offline
                        Pablo J. Rogina
                        wrote on last edited by
                        #11

                        @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

                        <translation type="unfinished"></translation>

                        To my understanding, "unfinished" translations don't prevent the process to go on and get the proper .qm files. Those "unfinished" strings will show up with a question mark in Linguist to let the translator now some attention in needed.

                        instead of the text IDs.

                        1. Could you elaborate what the text IDs are?
                        2. Could you please should a snippet of the source code with the qsTrID() entries

                        lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directory

                        Please remember that you can run lupdate manually (i.e. from command line). Although you need to locate a proper lupdate executable first.

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        Q 1 Reply Last reply
                        0
                        • Pablo J. RoginaP Pablo J. Rogina

                          @QTLeearn said in Successfully loaded .qm files, but translator remained empty:

                          <translation type="unfinished"></translation>

                          To my understanding, "unfinished" translations don't prevent the process to go on and get the proper .qm files. Those "unfinished" strings will show up with a question mark in Linguist to let the translator now some attention in needed.

                          instead of the text IDs.

                          1. Could you elaborate what the text IDs are?
                          2. Could you please should a snippet of the source code with the qsTrID() entries

                          lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directory

                          Please remember that you can run lupdate manually (i.e. from command line). Although you need to locate a proper lupdate executable first.

                          Q Offline
                          Q Offline
                          QTLeearn
                          wrote on last edited by
                          #12

                          @Pablo-J-Rogina I can show you an example of the qsTrId()

                          //% "LAST CASE
                          labelText: qsTrId("TEXT_BUTTON_LAST_CASE")
                          

                          In the .ts file there's:

                          <message id="TEXT_BUTTON_LAST_CASE">
                                  <location filename="../Resources/HomeScreen.qml" line="124"/>
                                  <source>LAST CASE</source>
                                  <translation type="unfinished"></translation>
                          </message>
                          

                          correspondingly

                          Pablo J. RoginaP 1 Reply Last reply
                          0
                          • Q QTLeearn

                            @Pablo-J-Rogina I can show you an example of the qsTrId()

                            //% "LAST CASE
                            labelText: qsTrId("TEXT_BUTTON_LAST_CASE")
                            

                            In the .ts file there's:

                            <message id="TEXT_BUTTON_LAST_CASE">
                                    <location filename="../Resources/HomeScreen.qml" line="124"/>
                                    <source>LAST CASE</source>
                                    <translation type="unfinished"></translation>
                            </message>
                            

                            correspondingly

                            Pablo J. RoginaP Offline
                            Pablo J. RoginaP Offline
                            Pablo J. Rogina
                            wrote on last edited by
                            #13

                            @QTLeearn it looks like your .qm file(s) are empty.
                            Even with no translations provided at all (no "LAST CASE") if the .qm file was properly built and loaded, you should see "TEXT_BUTTON_LAST_CASE" as the "translated" string

                            So you need to do the lupdate / translations (Linguist) / lrelease process properly.

                            Upvote the answer(s) that helped you solve the issue
                            Use "Topic Tools" button to mark your post as Solved
                            Add screenshots via postimage.org
                            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                            Q 1 Reply Last reply
                            0
                            • Pablo J. RoginaP Pablo J. Rogina

                              @QTLeearn it looks like your .qm file(s) are empty.
                              Even with no translations provided at all (no "LAST CASE") if the .qm file was properly built and loaded, you should see "TEXT_BUTTON_LAST_CASE" as the "translated" string

                              So you need to do the lupdate / translations (Linguist) / lrelease process properly.

                              Q Offline
                              Q Offline
                              QTLeearn
                              wrote on last edited by QTLeearn
                              #14

                              @Pablo-J-Rogina You are right, I guess some linguistic tools were not installed. When I tried to generate .qm files, Qt creator printed out messages:

                              Generated 0 translation(s) (0 finished and 0 unfinished)
                              Ignored 27 untranslated source text(s)
                              Updating '/TransDemo/languages/lang_de.qm'...

                              1 Reply Last reply
                              0
                              • Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                I don't see anything wrong with those messages - you did not yet translate any message in your ts file so the output is correct.

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                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