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. strange behaviour of QLocale with QTranslator

strange behaviour of QLocale with QTranslator

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 2 Posters 953 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.
  • D Offline
    D Offline
    django.Reinhard
    wrote on last edited by django.Reinhard
    #4

    I use qt5.15.2 at debian 11 (bullseye)

    The solution sounds so unbelievable, that I did't check it earlier.
    But hey - the workaround does what I want, so ... :)

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

      Would it be possible for you to provide a minimal compilable example that triggers this ?

      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
      • D Offline
        D Offline
        django.Reinhard
        wrote on last edited by
        #6

        Hi,

        you could have a look at https://github.com/DjangoReinhard/QtUi
        Its not minimal, but compilable.

        You just need to look at main.cpp - current version is fixed to English.
        So add a few comments and it should run/fail as described.

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

          Did you check what sysLocale.name() returns ?

          I just tested with sysLocale on my system and it worked correctly (using a copy of your file renamed using my sysLocale name).

          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
          • D Offline
            D Offline
            django.Reinhard
            wrote on last edited by
            #8

            Result:

            current locale settings - lang:  QLocale::German 	country:  QLocale::Germany 	name:  "de_DE"
            syslocale.name:  "de_DE"
            locale messages found:  false
            

            from code:

            
            int main(int argc, char *argv[]) {
              QTranslator       translator;
              QApplication      a(argc, argv);
              QLocale           sysLocale;
              QLocale::Language lang    = sysLocale.language();
              QLocale::Country  country = sysLocale.country();
              QLocale           curLocale; // (lang, country);
              bool              ok = translator.load(curLocale
                                                   , "QtUi"
                                                   , "_"
                                                   , "../QtUi/src/i18n");
            
              qDebug() << "current locale settings - lang: " << curLocale.language()
                       << "\tcountry: " << curLocale.country()
                       << "\tname: " << curLocale.name();
              qDebug() << "syslocale.name: " << sysLocale.name();
              qDebug() << "locale messages found: " << ok;
              a.installTranslator(&translator);
              MainWindow w;
            
              w.show();
            
              return a.exec();
              }
            

            ... by the way: using Qt 6.2 works as expected :)

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

              5.15.2 from the online installer ?
              Did you try with the one provided with your distribution ?

              On my side it's 5.15.2 on macOS.

              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
              • D Offline
                D Offline
                django.Reinhard
                wrote on last edited by
                #10

                @SGaist said in strange behaviour of QLocale with QTranslator:

                Did you try with the one provided with your distribution ?

                Of cause, that was my first choice. Qt 5.15.2 on debian bullseye

                Then with increasing issues I was curious about newer qt releases, so i started to use the online installer ...

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

                  In that case, can you test the 5.15.2 from the installer ?

                  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
                  • D Offline
                    D Offline
                    django.Reinhard
                    wrote on last edited by
                    #12

                    Hi,

                    I wasn't sure about my memory, so I repeated the tests:

                    • 5.15.2 provided by debian bullseye: fail
                    • 5.15.2 online installer: fail
                    • 6.2 online installer: works as expected
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      Did you try to compare the system QLocale with the one you build by hand ?

                      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
                      • D Offline
                        D Offline
                        django.Reinhard
                        wrote on last edited by
                        #14

                        If you look at my post before your last 3 questions you see the code, I'm using.

                        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