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. Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.

Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
18 Posts 5 Posters 4.2k 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.
  • A Akshay Singh
    5 May 2017, 09:27

    @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.Its lengthy but works. I applied and its working fine. Thanks mate. It helped a lot.

    Its just same as including a .ts and .qm file in project. There it automatically pics the lines you have to change and here You have to go through your project for getting the lines to be changed.

    E Offline
    E Offline
    Eeli K
    wrote on 5 May 2017, 11:29 last edited by
    #8

    @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

    @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

    Why it needs distinct property for each text?

    A S 3 Replies Last reply 8 May 2017, 07:28
    0
    • S sierdzio
      5 May 2017, 07:33

      There is a way to force each string to be updated when you change the language.

      Define "empty" property and attach it to all your strings.

      // C++ side. Expose this property to QML via root context, or QML singleton - whatever
      Q_PROPERTY(int empty READ empty NOTIFY emptyChanged)
      // QML side
      text: qsTr("Some translatable text") + empty
      

      Now, when you change the translation (.qm file), just emit EmptyChanged() signal. You don't need to change it's value, just emit the signal. All strings will be reloaded.

      E Offline
      E Offline
      ekkescorner
      Qt Champions 2016
      wrote on 5 May 2017, 14:57 last edited by
      #9

      @sierdzio curios:
      BlackBerry10 Cascades did something similar ;-)
      https://developer.blackberry.com/native/reference/cascades/bb__cascades__qmlretranslate.html

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      0
      • E Eeli K
        5 May 2017, 11:29

        @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

        @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

        Why it needs distinct property for each text?

        A Offline
        A Offline
        Akshay Singh
        wrote on 8 May 2017, 07:28 last edited by
        #10
        This post is deleted!
        1 Reply Last reply
        0
        • E Eeli K
          5 May 2017, 11:29

          @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

          @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

          Why it needs distinct property for each text?

          A Offline
          A Offline
          Akshay Singh
          wrote on 8 May 2017, 07:33 last edited by Akshay Singh 5 Aug 2017, 07:35
          #11

          @Eeli-K said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

          @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

          @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

          Why it needs distinct property for each text?

          Hey thanks for pointing out the mistake. Now everyone will find me fool....but anyway
          here is what I was doing->I was using QProperty as a String and using signal to change the text. Giving that string property a already translated text. And changing on a click of a button.

          Thanks for pointing out the mistake sir. Now only empty property is to be added for every qsTr() string. I used the changes and project is working fine.

          But on thing is remaining there. 0 number is added automatically at the end of the text,this is because I am using int property. Well I will do my own experiments and update when It will be working properly.

          Am sorry for my mistake.Thanks again

          A S 2 Replies Last reply 8 May 2017, 07:39
          0
          • A Akshay Singh
            8 May 2017, 07:33

            @Eeli-K said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

            @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

            @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

            Why it needs distinct property for each text?

            Hey thanks for pointing out the mistake. Now everyone will find me fool....but anyway
            here is what I was doing->I was using QProperty as a String and using signal to change the text. Giving that string property a already translated text. And changing on a click of a button.

            Thanks for pointing out the mistake sir. Now only empty property is to be added for every qsTr() string. I used the changes and project is working fine.

            But on thing is remaining there. 0 number is added automatically at the end of the text,this is because I am using int property. Well I will do my own experiments and update when It will be working properly.

            Am sorry for my mistake.Thanks again

            A Offline
            A Offline
            Akshay Singh
            wrote on 8 May 2017, 07:39 last edited by Akshay Singh 5 Aug 2017, 09:48
            #12

            Using QString in place of int for Q_PROPERTY, it worked. Thanks to all.

            1 Reply Last reply
            0
            • E Eeli K
              5 May 2017, 11:29

              @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

              @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

              Why it needs distinct property for each text?

              S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 8 May 2017, 11:40 last edited by
              #13

              @Eeli-K said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

              Why it needs distinct property for each text?

              It does not. You can use the same "empty" property for all strings.

              (Z(:^

              E 1 Reply Last reply 8 May 2017, 12:11
              0
              • A Akshay Singh
                8 May 2017, 07:33

                @Eeli-K said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

                @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

                @sierdzio Yeah.....But this simple method is very easy to implement. You just have to note that..every text in qml should change according to the corresponding property. Every distinct text should have distinct property.

                Why it needs distinct property for each text?

                Hey thanks for pointing out the mistake. Now everyone will find me fool....but anyway
                here is what I was doing->I was using QProperty as a String and using signal to change the text. Giving that string property a already translated text. And changing on a click of a button.

                Thanks for pointing out the mistake sir. Now only empty property is to be added for every qsTr() string. I used the changes and project is working fine.

                But on thing is remaining there. 0 number is added automatically at the end of the text,this is because I am using int property. Well I will do my own experiments and update when It will be working properly.

                Am sorry for my mistake.Thanks again

                S Offline
                S Offline
                sierdzio
                Moderators
                wrote on 8 May 2017, 11:41 last edited by
                #14

                @Akshay-Singh said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

                0 number is added automatically at the end of the text,this is because I am using int property.

                Yeah, I used int to save me some typing ;-) Using an empty string is much better, indeed, it won't give you an "0" appended to all texts.

                (Z(:^

                1 Reply Last reply
                0
                • S sierdzio
                  8 May 2017, 11:40

                  @Eeli-K said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

                  Why it needs distinct property for each text?

                  It does not. You can use the same "empty" property for all strings.

                  E Offline
                  E Offline
                  Eeli K
                  wrote on 8 May 2017, 12:11 last edited by
                  #15

                  @sierdzio said in Is it possible to Dynamically change the language of Qt Control 2 app using Linguistic, lupdate, .qm,.ts files.:

                  It does not. You can use the same "empty" property for all strings.

                  I knew that already, I just wondered why Akshay said so, and he then noticed it, too :)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sierdzio
                    Moderators
                    wrote on 8 May 2017, 12:13 last edited by
                    #16

                    Ah, ok, sorry :-)

                    (Z(:^

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Lorenz
                      wrote on 8 May 2017, 14:39 last edited by
                      #17

                      Hi,

                      For a simple tutorial on this issue, have a look at this: https://v-play.net/doc/howto-multi-language/

                      The tutorial uses the V-Play SDK, but it works the same way for standard Qt apps.

                      Cheers,
                      Lorenz

                      Developer @ V-Play Engine - http://v-play.net/qt

                      V-Play simplifies

                      • Game Development with Qt
                      • Mobile App Dev with Qt esp. iOS & Android

                      What others say
                      V-Play scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        Akshay Singh
                        wrote on 9 May 2017, 05:29 last edited by Akshay Singh 5 Sept 2017, 06:42
                        #18

                        Thanks Everyone for helping me out. Now am having a running project. This is a topic whose solution can not be found easily. So here I uploaded my project in Github. So the beginners can have a look at it. It is the most simplest project that I can make.

                        Sorry for the naming of the project and files. :p

                        https://github.com/AkshaySingh0294/QT-Language-Translation-with-QObject-class.git

                        Refer my .md file for understanding it more correctly

                        1 Reply Last reply
                        0

                        17/18

                        8 May 2017, 14:39

                        • Login

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