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. How can I add language translation for dynamic text
Qt 6.11 is out! See what's new in the release blog

How can I add language translation for dynamic text

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 1.3k 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.
  • R Offline
    R Offline
    Rathore
    wrote on last edited by
    #1

    I am working on QT-5.6.3 based embedded qt application.
    The application supports multiple languages, default is English.
    In the application, I have added fixed text string translation for other languages.
    How can I add dynamic text string translations?

    J.HilkJ Pablo J. RoginaP 2 Replies Last reply
    0
    • R Rathore

      I am working on QT-5.6.3 based embedded qt application.
      The application supports multiple languages, default is English.
      In the application, I have added fixed text string translation for other languages.
      How can I add dynamic text string translations?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Rathore hi, can you be a bit more specific in your situation ?

      what exactly do you want to do ?

      You know about QObject::tr() and QTranslator?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      R 1 Reply Last reply
      0
      • R Rathore

        I am working on QT-5.6.3 based embedded qt application.
        The application supports multiple languages, default is English.
        In the application, I have added fixed text string translation for other languages.
        How can I add dynamic text string translations?

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Rathore said in How can I add language translation for dynamic text:

        How can I add dynamic text string translations?

        Have you checked the documentation about Writing Source Code for Translation?

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @Rathore hi, can you be a bit more specific in your situation ?

          what exactly do you want to do ?

          You know about QObject::tr() and QTranslator?

          R Offline
          R Offline
          Rathore
          wrote on last edited by
          #4

          @J-Hilk I have qml based application. I have array of Qstrings defined in .h file. I have used QObject::tr() is used to recognized these strings by lupdate and Qt Linguist. I have added the translation for these strings.
          When the language selected is other than english, these strings should be translated and displayed in selected language, as I have added the translations in Qt Linguist. But these strings are displayed in english only.

          J.HilkJ 1 Reply Last reply
          0
          • R Rathore

            @J-Hilk I have qml based application. I have array of Qstrings defined in .h file. I have used QObject::tr() is used to recognized these strings by lupdate and Qt Linguist. I have added the translation for these strings.
            When the language selected is other than english, these strings should be translated and displayed in selected language, as I have added the translations in Qt Linguist. But these strings are displayed in english only.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @Rathore
            ok, so far so good,

            you should I assume you have read the documentation @Pablo-J-Rogina linked?

            So how do you access the strings in QML ?

            IIRC than Qt 5.6.3 does not yet have the automatic QML binding reevaluation when a language changes. And you'll have to do some trickery here
            See this blog post as an example on how its done before 5.10 and after
            https://embeddeduse.com/2017/11/12/new-in-qt-5-10-dynamic-language-change-in-qml/

            if you assign a string instead of a binding, you can/have to recall the function, where the assignment happens, after the translation


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            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