Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. **cool functionality** Can the user translate the application at runtime?
Forum Updated to NodeBB v4.3 + New Features

**cool functionality** Can the user translate the application at runtime?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 472 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.
  • A Offline
    A Offline
    addebito
    wrote on 27 Mar 2020, 10:16 last edited by
    #1

    Hello to everyone,
    I'd like to add a (IMHO) cool functionality to give at my customer a possibility to translate the application at runtime!

    I'd like to reproduce the same behavior of Qt Creator, so double click on a QLabel, or a QPushButton or any widgets to bring up a white line edit where the user can write the best text in his language.

    Do you have any idea... how to do it?
    Thank you, as always.

    J 1 Reply Last reply 27 Mar 2020, 11:40
    0
    • A addebito
      27 Mar 2020, 10:16

      Hello to everyone,
      I'd like to add a (IMHO) cool functionality to give at my customer a possibility to translate the application at runtime!

      I'd like to reproduce the same behavior of Qt Creator, so double click on a QLabel, or a QPushButton or any widgets to bring up a white line edit where the user can write the best text in his language.

      Do you have any idea... how to do it?
      Thank you, as always.

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 27 Mar 2020, 11:40 last edited by
      #2

      @addebito hi,

      take a look into the documentation, with this example

      https://doc.qt.io/qt-5/qtlinguist-hellotr-example.html

      it should get you started :)


      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
      • A Offline
        A Offline
        addebito
        wrote on 27 Mar 2020, 13:01 last edited by addebito
        #3

        Hi @J-Hilk ,
        thank you for your kind reply however I know how Qt translation works.
        I already have an application with the GUI runtime translation and without restarting, but now I'd like to give at my customers the possibility to translate the GUI directly with itself.

        As mentioned before, the user should be able to enter in this "runtime translation" with a double click on a widget (as the same behavior of Qt Creator) write the best word in his language and press Return to confirm it.
        Under the wood I'll update the .ts file, rebuild the .qm file and reload it.

        It might work?
        But my first question was... how to do the functionality "double click" on all widgets (like QtCreator GUI side) to translate the text at runtime?

        Thank you.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MajidKamali
          wrote on 27 Mar 2020, 18:00 last edited by MajidKamali
          #4

          you can either:

          1. subclass each QWidget subclass (QLabel, QPushButton, etc.), which you'd like to apply this double-click feature on it, implement mouseDoubleClickEvent and show a QLineEdit on top of that widget, and so on.
          2. create a QObject-based class and implement eventFilter. then for every QWidget-based widget, installEventFilter on that class' instance. (Im not sure about this to work, actually :) )

          But I don't know how to modify ts and qm files. I think It's better to embed lupdate and lrelease in your application, or take a look at their source code

          A 1 Reply Last reply 31 Mar 2020, 13:20
          1
          • M MajidKamali
            27 Mar 2020, 18:00

            you can either:

            1. subclass each QWidget subclass (QLabel, QPushButton, etc.), which you'd like to apply this double-click feature on it, implement mouseDoubleClickEvent and show a QLineEdit on top of that widget, and so on.
            2. create a QObject-based class and implement eventFilter. then for every QWidget-based widget, installEventFilter on that class' instance. (Im not sure about this to work, actually :) )

            But I don't know how to modify ts and qm files. I think It's better to embed lupdate and lrelease in your application, or take a look at their source code

            A Offline
            A Offline
            addebito
            wrote on 31 Mar 2020, 13:20 last edited by
            #5

            Thank you at all.

            J 1 Reply Last reply 31 Mar 2020, 13:36
            1
            • A addebito
              31 Mar 2020, 13:20

              Thank you at all.

              J Offline
              J Offline
              J.Hilk
              Moderators
              wrote on 31 Mar 2020, 13:36 last edited by
              #6

              @addebito if you plan to update your ts file by hand, take a look at my phrasebook utility tool
              https://github.com/DeiVadder/QtPhrasebookUtilityTool

              I use it to update/patch my ts files, should help you getting started.


              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
              3

              1/6

              27 Mar 2020, 10:16

              • Login

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