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. [solved] How to translate english to german language during runtime?
Forum Updated to NodeBB v4.3 + New Features

[solved] How to translate english to german language during runtime?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.7k Views 2 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.
  • vishnuV Offline
    vishnuV Offline
    vishnu
    wrote on last edited by vishnu
    #1

    hello,
    I would like to translate all my strings from english to german. I have create a translation file using cmd line as said here link here. lupdate myproject\ qml\ -ts translation\en_En.ts . Now a file en_EN.ts has been generated in a folder translation. I have opened this file in Qt linguist and i can see all the strings around 138. I have changed the translation file settings from source lang posix to english. These are my final settings:
    source language: English country: any country
    target language: German country: German
    Then release as it has generated me a file en_EN.qm
    Now, How should I make use of this file in my QML code to translate from english to german ?Also switch back to english.
    I am looking for the qml code.
    All my strings are defined like this qsTr("send")
    Thanks a lot :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      I don't know if you still need to do this but a starting points could be this article

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      vishnuV 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        I don't know if you still need to do this but a starting points could be this article

        vishnuV Offline
        vishnuV Offline
        vishnu
        wrote on last edited by vishnu
        #3

        @SGaist
        Thanks for the quick reply.
        lrelease t1_de.ts after this line it has generated t1_de.qm file. I have just included in pro file TRANSLATIONS = t1_de.ts . Should i include "t1._de.ts" in Resources ? where should i include t1_de.qm file ? because it is just mentioned that it is used by the application at runtime. I am wondering how does it happen if i don't include it.
        Thanks

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          I don't know if you still need to do this but a starting points could be this article

          vishnuV Offline
          vishnuV Offline
          vishnu
          wrote on last edited by
          #4

          @SGaist
          I can see that from qml this function is invoked but not translating. How do i know that it is loading t1_de.ts file ?i mean any debugging technique ?

            qDebug()<<"selectedLanguage";
              if(language == QString("de")) {
                translator->load("t1_de", ".");
                qApp->installTranslator(translator);
               }
               if(language == QString("en")) {
                qApp->removeTranslator(translator);
               }
               emit languageChanged();
          
          vishnuV 1 Reply Last reply
          0
          • vishnuV vishnu

            @SGaist
            I can see that from qml this function is invoked but not translating. How do i know that it is loading t1_de.ts file ?i mean any debugging technique ?

              qDebug()<<"selectedLanguage";
                if(language == QString("de")) {
                  translator->load("t1_de", ".");
                  qApp->installTranslator(translator);
                 }
                 if(language == QString("en")) {
                  qApp->removeTranslator(translator);
                 }
                 emit languageChanged();
            
            vishnuV Offline
            vishnuV Offline
            vishnu
            wrote on last edited by
            #5

            @vishnu
            works perfect. forgot to run qmake :)

            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