Using Qt translated texts causes adding them to app ts



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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.