Skip to content

Commit 5e903a5

Browse files
committed
devtools: Handle Qt formatting characters edge-case in update-translations.py
If both numeric format specifiers and "others" are used, assume we're dealing with a Qt-formatted message. In the case of Qt formatting (see https://doc.qt.io/qt-5/qstring.html#arg) only numeric formats are replaced at all. This means "(percentage: %1%)" is valid (which was introduced in #9461), without needing any kind of escaping that would be necessary for strprintf. Without this, this function would wrongly detect '%)' as a printf format specifier.
1 parent 33f3b21 commit 5e903a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

contrib/devtools/update-translations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ def split_format_specifiers(specifiers):
6565
else:
6666
other.append(s)
6767

68+
# If both numeric format specifiers and "others" are used, assume we're dealing
69+
# with a Qt-formatted message. In the case of Qt formatting (see https://doc.qt.io/qt-5/qstring.html#arg)
70+
# only numeric formats are replaced at all. This means "(percentage: %1%)" is valid, without needing
71+
# any kind of escaping that would be necessary for strprintf. Without this, this function
72+
# would wrongly detect '%)' as a printf format specifier.
73+
if numeric:
74+
other = []
75+
6876
# numeric (Qt) can be present in any order, others (strprintf) must be in specified order
6977
return set(numeric),other
7078

0 commit comments

Comments
 (0)