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. How to update the translation if the text is in a list and shown by model
Forum Updated to NodeBB v4.3 + New Features

How to update the translation if the text is in a list and shown by model

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 414 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.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by
    #1

    Hi

    I found my text list can not update the translations.

    e.g.

    # I'm using tr() to append the text into the stringlist
    append(QString(tr( )));
    
    # then I think the list will be like this:
    (english),(english),(english), ...... ,(chinese),(chinese),(chinese)
    *...... : change the translation
    

    Must I replace the text in the list when I change the translation?

    JonBJ 1 Reply Last reply
    0
    • MihanM Mihan

      Hi

      I found my text list can not update the translations.

      e.g.

      # I'm using tr() to append the text into the stringlist
      append(QString(tr( )));
      
      # then I think the list will be like this:
      (english),(english),(english), ...... ,(chinese),(chinese),(chinese)
      *...... : change the translation
      

      Must I replace the text in the list when I change the translation?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Mihan said in How to update the translation if the text is in a list and shown by model:

      Must I replace the text in the list when I change the translation?

      Yes.

      MihanM 1 Reply Last reply
      1
      • JonBJ JonB

        @Mihan said in How to update the translation if the text is in a list and shown by model:

        Must I replace the text in the list when I change the translation?

        Yes.

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by
        #3

        @JonB Thanks
        Do you have a convenient way to do that?

        JonBJ J.HilkJ 2 Replies Last reply
        0
        • MihanM Mihan

          @JonB Thanks
          Do you have a convenient way to do that?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Mihan
          If you are maintaining your own QStringList by appending texts you must alter it for the appropriate language.
          If when your question title mentions "the text is in a list and shown by model" you get the texts from the model's data() method you can do the translation in what that returns.

          1 Reply Last reply
          0
          • MihanM Mihan

            @JonB Thanks
            Do you have a convenient way to do that?

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

            @Mihan if you're working with a class, that has QWidget at it's core, you can listen the language changed event and use the signal to recreate your list


            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
            2

            • Login

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