Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
6.4.0, 6.5.0
-
None
Description
This stems from an entry in the Qt forum:
LUpdate not adding entry to .ts file
The gist is, for the following code:
int main() { auto strText = QCoreApplication::translate("context", "%n cats", nullptr, 123); auto strText = QCoreApplication::translate("context", "%n dogs", nullptr, (int)123); auto strText = QCoreApplication::translate("context", "%n monkeys", nullptr, static_cast<int>(123)); }
Only one translation is produced:
$ ~/dev/qt/dev-native/qtbase/bin/lupdate foo.cpp -ts foo_de.ts Updating 'foo_de.ts'... Found 1 source text(s) (1 new and 0 already existing)
The content of the .ts file:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="de_DE"> <context> <name>context</name> <message numerus="yes"> <location filename="foo.cpp" line="2"/> <source>%n cats</source> <translation type="unfinished"> <numerusform></numerusform> <numerusform></numerusform> </translation> </message> </context> </TS>
Work-around: store the number in a variable and refer to that:
int x = static_cast<int>(123); auto strText = QCoreApplication::translate("context", "%n monkeys", nullptr, x);
Attachments
Issue Links
- duplicates
-
QTBUG-98919 static_cast<> throws off lupdate's parsing of QCoreApplication::translate()
-
- Closed
-