Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. System language in Harmattan?
Forum Updated to NodeBB v4.3 + New Features

System language in Harmattan?

Scheduled Pinned Locked Moved QML and Qt Quick
13 Posts 4 Posters 4.6k 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.
  • P Offline
    P Offline
    plcl
    wrote on last edited by
    #1

    Hi,

    I'm looking for a way to find out the system language from a Qt application in Harmattan (I mean the language set in the N950 System Settings) because QLocale::system() always returns en_US for me.

    Regards,
    Pedro

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      File a bug for Qt then, please, if your system language does not match what you get from QLocale.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        theoriginalgri
        wrote on last edited by
        #3

        You seem to be right about that:

        @
        QLocale test = QLocale::system();
        qDebug() << "System locale:" << test.name();

        MLocale locale;
        qDebug() << "MLocale:" << locale.name();
        @

        Output:
        @
        System locale: "en_US"
        MLocale: "de"
        @

        1 Reply Last reply
        0
        • P Offline
          P Offline
          plcl
          wrote on last edited by
          #4

          @Andre: yes, I thought about that, but then I've found this closed bug report: https://bugreports.qt.nokia.com/browse/QTBUG-15851

          @gri: thanks, looks like we need to use MLocale for this. One problem with this solution is that the header MLocale is only available in QtCreator when using the build configuration "Harmattan Platform API" and not in "Meego 1.2 Harmattan API". And of course, requires conditional compilation in multiplatform projects.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            Interesting reasoning in that bugreport. I would try to reopen it. Perhaps Harmattan doesn't work "the unix way" in this, but how is that the problem of the Qt user? What's more, isn't Harmattan a Nokia product as well? Such a conditional belongs, IMHO, in QLocale or the underlying platform plugins, not in the end users code.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              plcl
              wrote on last edited by
              #6

              @Andre: agreed. Windows doesn't follow POSIX either, but QLocale::system() returns in Windows the correct and expected results. I don't understand why we need to use a low level native approach on Harmattan.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                theoriginalgri
                wrote on last edited by
                #7

                Don't judge too fast here.

                If you use qt-components in harmattan, recent versions have a global "locale" context property. "locale.name" in qml should return the two letter code.

                See the exposed properties here: https://qt.gitorious.org/qt-components/qt-components/blobs/master/src/meego/i18n/mlocalewrapper.h#line197

                @plcl: I have not even installed the Meego 1.2 version of the SDK since it contains less libraries than the Harmattan Platform API (which is also missing many things that have to be copied from Scratchbox)

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  plcl
                  wrote on last edited by
                  #8

                  @gri: that will be nice for pure QML applications. Unfortunately, in latest Qt SDK 1.1.3 released on September 1st is not available.

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    theoriginalgri
                    wrote on last edited by
                    #9

                    It's not a problem of the SDK, more of the version on your device. Mine also doesn't seem to have this recent version of qt-components, though.

                    So you may change to "Harmattan Platform API", which contains almost the same APIs as the "Nokia Meego 1.2" thingy and use ifdefs which is not that evil :)

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andre
                      wrote on last edited by
                      #10

                      Hmmm.... I thought the point of Qt was "code once, deploy everywhere". This kind-of negates that, doesn't it?

                      I do appreciate that there are work-arounds, but that is not the point. IMHO, work-arounds, Harmattan-only solutions should not be needed. It is certainly not the direction Qt should go into. It will result in different flavours of Qt, that are not compatible with each other, with lots of pitfals in porting from the one to the other. IMO, that is not a desireable situation.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        theoriginalgri
                        wrote on last edited by
                        #11

                        Ever tried to write a software which runs on linux, mac, windows and some phones? I bet you can't do it without ifdefs. In most cases "code once" applies to your backend, but the gui has to be done for mobile and desktop platforms separately.
                        For example Qt Mobility does not even provide a native contact picker. Sometimes even behavior is different between the platforms. "code once" does not mean "don't code ifdefs" :)

                        I also read this some time ago that you should create your backend and the qml gui is throwaway for every platform.

                        EDIT: This doesn't mean I would not like to have QLocale working on harmattan :)

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

                          For GUI's, especially between desktop and the mobile, you are right. However, QLocale is not part of QtGui, it is in QtCore which is supposed to be working on all platforms.

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            ggiovanni88
                            wrote on last edited by
                            #13

                            I have successfully used QString locale = QLocale::system().name() to translate a mobile application for harmattan, n950 with latest firmware. Used meego 1.2 harmattan api and it returned it_IT with my current settings.

                            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