Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Linguist - Same Word but Different Context
Forum Update on Monday, May 27th 2025

Qt Linguist - Same Word but Different Context

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 1.8k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #1

    I must have missed that info in the manual so here we go.

    Say i have a Form1 with button "Print"
    I copy this button to Form2

    Then when i extract the texts (with lupdate)
    i get
    "Print" 2 times in different places. ( Contexts)

    I want Print" to only exists once but
    since it's on different forms, then its seems that the default is to
    include it 2 times but that not what we need at all.

    So how is one to handle this ?
    So same word is not translated over and over.

    J.HilkJ 1 Reply Last reply
    0
    • mrjjM mrjj

      I must have missed that info in the manual so here we go.

      Say i have a Form1 with button "Print"
      I copy this button to Form2

      Then when i extract the texts (with lupdate)
      i get
      "Print" 2 times in different places. ( Contexts)

      I want Print" to only exists once but
      since it's on different forms, then its seems that the default is to
      include it 2 times but that not what we need at all.

      So how is one to handle this ?
      So same word is not translated over and over.

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

      @mrjj I don't think you can force that, as tr() uses className() to determine the context.

      But, if you translate your main class and than run lupdate again, doesn't that fill in dublicated and similar translations - even across classes- , so you only have to press ctrl+Enter in those cases?


      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.

      mrjjM 1 Reply Last reply
      2
      • J.HilkJ J.Hilk

        @mrjj I don't think you can force that, as tr() uses className() to determine the context.

        But, if you translate your main class and than run lupdate again, doesn't that fill in dublicated and similar translations - even across classes- , so you only have to press ctrl+Enter in those cases?

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @J.Hilk

        Hi
        I was hoping for something like that - but from my first test, the other "Print" was not translated.
        and lookup up in one context, did not give the other contexts version.
        so Im not sure how Design is meant to be.
        Or maybe my trans was acting up so Im going to try again and
        see if translating once is enough.
        Else i will collapse the ts my self.

        Thank you for the input.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Update:
          After i ran lupdate a few times it suddenly said
          "Same-text heuristic provided 1 translation(s)"
          and then it worked.

          alt text

          So @J-Hilk, you were right. there was magic involved :)

          1 Reply Last reply
          0
          • J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @mrjj
            Great! To bad you have to run lupdate a couple of times instead of only 1 additional time.

            seems like the good old on/off approach never fails.... :-)

            alt text


            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

            • Login

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