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.
  • S Offline
    S Offline
    SeeLook
    wrote on 9 Dec 2015, 23:00 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?

    S 1 Reply Last reply 14 Dec 2015, 21:56
    0
    • S Offline
      S Offline
      SeeLook
      wrote on 12 Dec 2015, 17:45 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
      • S SeeLook
        9 Dec 2015, 23:00

        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?

        S Offline
        S Offline
        SeeLook
        wrote on 14 Dec 2015, 21:56 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

        1/3

        9 Dec 2015, 23:00

        • Login

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