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. QTranslator and qtbase_en.qm
Qt 6.11 is out! See what's new in the release blog

QTranslator and qtbase_en.qm

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.1k Views
  • 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.
  • M Offline
    M Offline
    Mark58
    wrote on last edited by
    #1

    Hi,

    In my main.cpp I implemented the QTranslator like this:

    QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    QLocale locale(QLocale::English, QLocale::UnitedStates);
    
    QTranslator qtBaseTranslator;
        qtBaseTranslator.load(locale, "qtbase", "_", translationsPath);
            qDebug() << "load2:"<< a.installTranslator(&qtBaseTranslator);
    

    The Debug intormation is:
    load1 true
    load2: false

    The file "C:\Qt\5.13.0\mingw73_32\translations\qtbase_en.qm" exists, but the translator does not work.

    Now I found out that the size of my "qtbase_en.qm"-file is only 1 KB; other qtbase_xy.qm-files have a size of 150KB to 200KB.

    Where can I get a working "qtbase_en.qm"-file?
    Thanks.

    Christian EhrlicherC 1 Reply Last reply
    0
    • M Mark58

      Hi,

      In my main.cpp I implemented the QTranslator like this:

      QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
      QLocale locale(QLocale::English, QLocale::UnitedStates);
      
      QTranslator qtBaseTranslator;
          qtBaseTranslator.load(locale, "qtbase", "_", translationsPath);
              qDebug() << "load2:"<< a.installTranslator(&qtBaseTranslator);
      

      The Debug intormation is:
      load1 true
      load2: false

      The file "C:\Qt\5.13.0\mingw73_32\translations\qtbase_en.qm" exists, but the translator does not work.

      Now I found out that the size of my "qtbase_en.qm"-file is only 1 KB; other qtbase_xy.qm-files have a size of 150KB to 200KB.

      Where can I get a working "qtbase_en.qm"-file?
      Thanks.

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mark58 said in QTranslator and qtbase_en.qm:

      Where can I get a working "qtbase_en.qm"-file?

      When you want an english - english translation you have to do it by yourself I would guess.

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

      M 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @Mark58 said in QTranslator and qtbase_en.qm:

        Where can I get a working "qtbase_en.qm"-file?

        When you want an english - english translation you have to do it by yourself I would guess.

        M Offline
        M Offline
        Mark58
        wrote on last edited by
        #3

        @Christian-Ehrlicher
        Thanks, but that's not the problem. Maybe I tried to simplify my problem too much.

        The "qtbase_...qm" file should translate e.g. the buttonbox-Button.
        I start my app in Spanish. Therefore I have a QTranslator in my main.cpp like this:

        QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
            QLocale locale(QLocale::Spanish, QLocale::Spain);
            QTranslator qtBaseTranslator;
            qDebug() << "path" << qtBaseTranslator.load(locale, "qtbase", "_", translationsPath);
            qDebug() << "load:"<< a.installTranslator(&qtBaseTranslator);
        

        This works fine and the buttonbox-Button is shown in spanish:
        app_spanish_button.JPG

        In my mainwindow.cpp I have three slots to change the language into german, french or english.
        Generally, this works fine - e.g. for french:

        void MainWindow::on_pushButton_3_clicked()
        {
            //Francais
        
            QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
            QLocale locale(QLocale::French, QLocale::France);
        
            QTranslator *qtBaseTranslator = new QTranslator(this);
            qDebug() << "path francais:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath);
            qDebug() << "load francais:"<< qApp->installTranslator(qtBaseTranslator);
        }
        

        This works fine as well. The Debug-output is:
        path francais: true
        load francais: true

        The buttonbox-Button - language changes to french:
        app_french_buttons.JPG

        My problem is, that the translation to English does not work:

        void MainWindow::on_pushButton_4_clicked()
        {
            //English
            
            QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
            QLocale locale(QLocale::English, QLocale::UnitedKingdom);
        
            QTranslator *qtBaseTranslator = new QTranslator(this);
            qDebug() << "trans" <<translationsPath;
            qDebug() << "path English:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath);
            qDebug() << "translator empty?:" << qtBaseTranslator->isEmpty();
            qDebug() << "load English:"<< qApp->installTranslator(qtBaseTranslator);
        }
        

        The Debug - Output is:
        trans "C:/Qt/5.13.0/mingw73_32/translations"
        path English: true
        translator empty?: true
        load English: false

        As a consequence, the language changes back to Spanish, because this is the language in the main.cpp.

        In the directory "C:/Qt/5.13.0/mingw73_32/translations" I have a qtbase_en.qm with a size of 1KB only.
        translations_files.JPG

        Any help would be fine. Thanks.

        Christian EhrlicherC 1 Reply Last reply
        0
        • M Mark58

          @Christian-Ehrlicher
          Thanks, but that's not the problem. Maybe I tried to simplify my problem too much.

          The "qtbase_...qm" file should translate e.g. the buttonbox-Button.
          I start my app in Spanish. Therefore I have a QTranslator in my main.cpp like this:

          QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
              QLocale locale(QLocale::Spanish, QLocale::Spain);
              QTranslator qtBaseTranslator;
              qDebug() << "path" << qtBaseTranslator.load(locale, "qtbase", "_", translationsPath);
              qDebug() << "load:"<< a.installTranslator(&qtBaseTranslator);
          

          This works fine and the buttonbox-Button is shown in spanish:
          app_spanish_button.JPG

          In my mainwindow.cpp I have three slots to change the language into german, french or english.
          Generally, this works fine - e.g. for french:

          void MainWindow::on_pushButton_3_clicked()
          {
              //Francais
          
              QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
              QLocale locale(QLocale::French, QLocale::France);
          
              QTranslator *qtBaseTranslator = new QTranslator(this);
              qDebug() << "path francais:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath);
              qDebug() << "load francais:"<< qApp->installTranslator(qtBaseTranslator);
          }
          

          This works fine as well. The Debug-output is:
          path francais: true
          load francais: true

          The buttonbox-Button - language changes to french:
          app_french_buttons.JPG

          My problem is, that the translation to English does not work:

          void MainWindow::on_pushButton_4_clicked()
          {
              //English
              
              QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
              QLocale locale(QLocale::English, QLocale::UnitedKingdom);
          
              QTranslator *qtBaseTranslator = new QTranslator(this);
              qDebug() << "trans" <<translationsPath;
              qDebug() << "path English:" << qtBaseTranslator->load(locale, "qtbase", "_", translationsPath);
              qDebug() << "translator empty?:" << qtBaseTranslator->isEmpty();
              qDebug() << "load English:"<< qApp->installTranslator(qtBaseTranslator);
          }
          

          The Debug - Output is:
          trans "C:/Qt/5.13.0/mingw73_32/translations"
          path English: true
          translator empty?: true
          load English: false

          As a consequence, the language changes back to Spanish, because this is the language in the main.cpp.

          In the directory "C:/Qt/5.13.0/mingw73_32/translations" I have a qtbase_en.qm with a size of 1KB only.
          translations_files.JPG

          Any help would be fine. Thanks.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          If yoiu don't need a translator anymore, remove it.

          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
          • B Offline
            B Offline
            bokun
            wrote on last edited by
            #5

            @Christian-Ehrlicher Hello, I recently encountered this problem and would like to ask if you have a solution. I found that manually translating the generated qt_en.ts and translating it into qt_en.qm can solve the problem, but it is a bit time-consuming. It seems that Qt's mechanism is that when there is no translation text, it will use your system's local language (Spanish).

            J.HilkJ 1 Reply Last reply
            0
            • B bokun

              @Christian-Ehrlicher Hello, I recently encountered this problem and would like to ask if you have a solution. I found that manually translating the generated qt_en.ts and translating it into qt_en.qm can solve the problem, but it is a bit time-consuming. It seems that Qt's mechanism is that when there is no translation text, it will use your system's local language (Spanish).

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @bokun the OP's problem was most likely a lifetime issue of the stack allocated QTranslator, if I had to guess

              This topic is 2 years old, please create a new one for your specific issue.

              Closing this topic now


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • J.HilkJ J.Hilk locked this topic on

              • Login

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