0

What chances do I got in finding all QStrings that do miss a tr()-translate call in a very old and very huge Application?

I was thinking something like... make a special .ts file for debugging use only and add a static prefix to all translations. Then put Qt in some sort of debug mode and list all its QString to qDebug or whatever—with the chance of filtering for everything that's missing the static prefix from the debug translation file. Is this possible?

Or: is there a better way to find untranslated QString occurrences? Thanks

Hhut
  • 1,128
  • 1
  • 12
  • 24

1 Answers1

2

For a big old project, this is probably a lot of work, but one way is below:

First see here, you want this:

QT_NO_CAST_FROM_ASCII disables automatic conversions from C string literals and pointers to Unicode.

Define that for your project, and then you can't write C string literals where QString is expected. Then you will probably get a bunch of build errors, which you fix by doing explicit conversion, using tr where you want.

After that, or perhaps before that to avoid going through same strings twice, do find-in-files (Ctrl+Shift+F in Qt Creator) for regexps like QString.*", and check them all for need of tr.

hyde
  • 60,639
  • 21
  • 115
  • 176