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. Using Qt translated texts causes adding them to app ts
QtWS25 Last Chance

Using Qt translated texts causes adding them to app ts

Scheduled Pinned Locked Moved Solved General and Desktop
translationslupdatetranslate
3 Posts 1 Posters 1.6k 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.
  • SeeLookS Offline
    SeeLookS Offline
    SeeLook
    wrote on last edited by
    #1

    Hi all!

    When I'm using translations from qtbase file this way:
    QApplication::translate("QShortcut", "Help")
    or
    QShortcut::tr(""Help")
    All those texts go into myApp.ts files after invoke lupdate.

    Is there any way to avoid that?
    Or some method to remove such messages from ts file?

    SeeLookS 1 Reply Last reply
    0
    • SeeLookS Offline
      SeeLookS Offline
      SeeLook
      wrote on last edited by
      #2

      I think, the best way to achieve above is to make changes in lupdate.
      So I forked it, added small changes and there it is:
      https://github.com/SeeLook/lupdate

      Then simply way to have *.ts file without some context of tr() or translate() is to call:

      lupdate -skip-context QFileDialog,QMessageBox,QProgressDialog,QShortcut -recursive src -ts file.ts
      

      Write me if You find this usable or any another way.

      1 Reply Last reply
      0
      • SeeLookS SeeLook

        Hi all!

        When I'm using translations from qtbase file this way:
        QApplication::translate("QShortcut", "Help")
        or
        QShortcut::tr(""Help")
        All those texts go into myApp.ts files after invoke lupdate.

        Is there any way to avoid that?
        Or some method to remove such messages from ts file?

        SeeLookS Offline
        SeeLookS Offline
        SeeLook
        wrote on last edited by
        #3

        Another solution that not require hacking Qt is to alias QApplication::translate method:

        inline QString myTr(const char* context, const char* key, const char* disambiguation = 0, int n = -1) {
          return QApplication::translate(context, key, disambiguation, n);
        }
        

        and then get translated text with:

        myTr("QShortcut", "Help");
        

        Such texts are invisible for lupdate.

        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