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. Linguist support for QML files. (QML UI Language Translation)
QtWS25 Last Chance

Linguist support for QML files. (QML UI Language Translation)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 1.7k 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.
  • P Offline
    P Offline
    Pradeep P N
    wrote on 19 Apr 2017, 07:19 last edited by
    #1

    Hi All,

    I want to do language translation for my project the complete GUI is in QML, when i run lupdate on the project the x.ts file dose not contain any of the Context from QML files. Can any one please help me to translate the QML files using Qt Linguist.

    Thank You.

    Pradeep Nimbalkar.
    Upvote the answer(s) that helped you to solve the issue...
    Keep code clean.

    J 1 Reply Last reply 19 Apr 2017, 08:04
    0
    • P Pradeep P N
      19 Apr 2017, 07:19

      Hi All,

      I want to do language translation for my project the complete GUI is in QML, when i run lupdate on the project the x.ts file dose not contain any of the Context from QML files. Can any one please help me to translate the QML files using Qt Linguist.

      Thank You.

      J Offline
      J Offline
      Julien B
      wrote on 19 Apr 2017, 08:04 last edited by Julien B
      #2

      Hello @Pradeep-P-N,

      Does all your text in QML are inside qsTr () or others alternatives ?

      Did you add your QML files in your .pro ?
      Either via:

      lupdate_only{
      SOURCES = \
                file.qml
      }
      

      or

      DISTFILES += \
          file.qml
      

      in order for lupdate to process the texts to translate.

      Have a look in Internationalization and Localization with Qt Quick for more informations.

      1 Reply Last reply
      2
      • P Offline
        P Offline
        Pradeep P N
        wrote on 19 Apr 2017, 10:04 last edited by Pradeep P N 6 Apr 2019, 15:34
        #3

        Hi @Julien-B
        Thank you,
        Yes all my QML files contains qsTr(), and in .pro

        lupdate_only {
        SOURCES += 
                  qml/ * .qml \
                  qml/ * / * .qml \
                  qml/ * / * / * .qml \
                  qml/ * / * / * / *.qml \
                  qml/ * / * / * / *  / *.qml
        
        }
        

        on lupdate the .ts file generated does not contains all my QML file context.
        I have generated .qm file and included in resource qrc.

        if(language == DE){
                qDebug() << "App Is Available In German";
                qDebug() << lang_DE->load(":/t1_de.qm", ".");
                qApp->installTranslator(lang_DE);
            }else{
                qDebug() << "Default Language -- English" << endl;
                qApp->removeTranslator(lang_DE);
            }
        

        load is - TRUE

        but there is no change in UI, and also how can i load all QML file Context in .ts file.

        Pradeep Nimbalkar.
        Upvote the answer(s) that helped you to solve the issue...
        Keep code clean.

        J 1 Reply Last reply 19 Apr 2017, 11:33
        1
        • P Pradeep P N
          19 Apr 2017, 10:04

          Hi @Julien-B
          Thank you,
          Yes all my QML files contains qsTr(), and in .pro

          lupdate_only {
          SOURCES += 
                    qml/ * .qml \
                    qml/ * / * .qml \
                    qml/ * / * / * .qml \
                    qml/ * / * / * / *.qml \
                    qml/ * / * / * / *  / *.qml
          
          }
          

          on lupdate the .ts file generated does not contains all my QML file context.
          I have generated .qm file and included in resource qrc.

          if(language == DE){
                  qDebug() << "App Is Available In German";
                  qDebug() << lang_DE->load(":/t1_de.qm", ".");
                  qApp->installTranslator(lang_DE);
              }else{
                  qDebug() << "Default Language -- English" << endl;
                  qApp->removeTranslator(lang_DE);
              }
          

          load is - TRUE

          but there is no change in UI, and also how can i load all QML file Context in .ts file.

          J Offline
          J Offline
          Julien B
          wrote on 19 Apr 2017, 11:33 last edited by Julien B
          #4

          @Pradeep-P-N ,

          In QML the Context for a traduction is the name of the .qml file where it appears.

          What do you mean exactly when you say there is no Context in .ts file ?

          1 Reply Last reply
          1
          • P Offline
            P Offline
            Pradeep P N
            wrote on 19 Apr 2017, 12:12 last edited by
            #5

            @Julien-B

            Yes. There is no data related to all QML. I could only see few Qt Context. And only one QML FILE is available in Context of my .ts file.
            And even though after updating the .ts file with the single QML context in .ts file
            No language change in UI.

            Pradeep Nimbalkar.
            Upvote the answer(s) that helped you to solve the issue...
            Keep code clean.

            1 Reply Last reply
            1
            • P Offline
              P Offline
              Pradeep P N
              wrote on 24 Apr 2017, 10:42 last edited by
              #6

              Thank You @Julien-B .

              The problem was with loading SOURCES and its solved.

              Pradeep Nimbalkar.
              Upvote the answer(s) that helped you to solve the issue...
              Keep code clean.

              1 Reply Last reply
              1

              4/6

              19 Apr 2017, 11:33

              • Login

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