Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Linguist - Same Word but Different Context


  • Lifetime Qt Champion

    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.


  • Moderators

    @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?


  • Moderators

    @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?


  • Lifetime Qt Champion

    @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.


  • Lifetime Qt Champion

    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 :)


  • Moderators

    @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


Log in to reply