Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT Translate on Android
Forum Updated to NodeBB v4.3 + New Features

QT Translate on Android

Scheduled Pinned Locked Moved Mobile and Embedded
12 Posts 4 Posters 5.9k 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by
    #2

    Hi,

    I am using QTranslate in my Android app and it works perfectly. Do you load and install translation before you load your view?
    In my QML app I needed to load translation before loading main.qml file.

    BTW its Qt not QT(QuickTime)

    1 Reply Last reply
    0
    • D Offline
      D Offline
      digiloo
      wrote on last edited by
      #3

      Thank you for rapid answer!

      I load the translation (from a resource file) the first thing in my main C++ app (before loading main.qml)

      / Hakan

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kolegs
        wrote on last edited by
        #4

        So are you sure the file exists(the one with translation)? Can you check it @QFile::exists()@

        Are you installing translator properly?
        @QLocale::setDefault(QLocale::English);
        qtTranslator.load(":/tr/translations_en.qm");
        app.installTranslator(&qtTranslator);@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          digiloo
          wrote on last edited by
          #5

          Hi,

          I currently don't use Qlocale::setDefault() but still the translation works for Mac, Windows and IOS

          /Hakan

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kolegs
            wrote on last edited by
            #6

            can you check if the file with translations exists? using QFile::exists()?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              digiloo
              wrote on last edited by
              #7

              Absolutely. I do it later tonight. But it exist on Mac, Windows and IOS!

              Thanks

              /Hakan

              1 Reply Last reply
              0
              • D Offline
                D Offline
                digiloo
                wrote on last edited by
                #8

                Meanwhile ...

                My code in main looks like this;

                QTranslator translator;
                if(translator.load(":/xxx.qm") != 1) { ...}

                And my resource file like this:

                <RCC>
                <qresource>
                <file alias="xxx.qm">tr/xxx_en.qm</file>
                </qresource>
                <qresource lang="sv">
                <file alias="xxx.qm">tr/xxx_sv.qm</file>
                </qresource>
                <qresource lang="de">
                <file alias="xxx.qm">tr/xxx_de.qm</file>
                </qresource>
                </RCC>

                /Hakan

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  digiloo
                  wrote on last edited by
                  #9

                  QFile.exists() returns OK! And I think that translator.load() returns error if the given file/resource don't exist

                  / Hakan

                  1 Reply Last reply
                  0
                  • X Offline
                    X Offline
                    Xander84
                    wrote on last edited by
                    #10

                    did you check if the language detection works on android?
                    e.g. with
                    @QLocale::system().name()@
                    if not your have to set it manually like kolegs said, also you should try and set the file manually and see if that works on android first.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      digiloo
                      wrote on last edited by
                      #11

                      Yes the language detection works fine also on andriod

                      / Hakan

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Al__
                        wrote on last edited by
                        #12

                        Which Qt version do you use? There seems a buf in Qt 5.1 that may affect you (prevents to find the correct locale), see QTBUG-31651; referenced in https://blog.qt.digia.com/blog/2013/07/23/anatomy-of-a-qt-5-for-android-application/#comment-1103021

                        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