Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41385

Locale not detected properly on Android

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.11.0 Beta 2
    • 5.3.2
    • Core: Locales (i18n)
    • None
    • Android 4.1.2
    • Android
    • 78e92997ed35ddc8bb6f7f6c0a4fffba026d5d8f

      The following problem occurs on my Android phone only, my Linux desktop is not affected.

      The translation of my application works only properly when I call QLocale::system().name() after construction of QApplication.

      int main(int argc, char *argv[]) {
          qDebug("locale 1=%s",qPrintable(QLocale::system().name()));
          QApplication app(argc, argv);
          qDebug("locale 2=%s",qPrintable(QLocale::system().name()));
      
          QTranslator myappTranslator;
          myappTranslator.load(":/i18n/translations");
          app.installTranslator(&myappTranslator);
      
          MainWindow w;
          w.show();
          return app.exec();
      }
      

      Locale 1 is always "C". Locale 2 is "de_DE" on my german phone.

      When I remove the second debug output (locale 2=...) then the translation does not work anymore. Then the GUI has english wording.

      So I see two related issues (on Android only):

      1) QLocale::system() returns the wrong locale "C" when called before construction of QApplication.

      2) QTranslator works only, when I call QLocale::system() AFTER construction of QApplication but BEFORE construction of the QTranslator.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            tsdgeos_kdab Albert Astals Cid
            s.frings74 Stefan Frings
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes