aboutsummaryrefslogtreecommitdiff
path: root/contrib/devtools
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-02-10 08:49:04 +0000
committerWladimir J. van der Laan <laanwj@gmail.com>2017-02-10 08:56:27 +0000
commit5e903a5ed96809af31cdcf6037e6c284832a02a6 (patch)
tree79ca74509bdfd8b1a9a85091ae10af1b95b5f3da /contrib/devtools
parent33f3b21407a38faaaee2d72d16e8eb340fe74657 (diff)
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.
Diffstat (limited to 'contrib/devtools')
-rwxr-xr-xcontrib/devtools/update-translations.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/devtools/update-translations.py b/contrib/devtools/update-translations.py
index 78b9f9d179..2011841005 100755
--- a/contrib/devtools/update-translations.py
+++ b/contrib/devtools/update-translations.py
@@ -65,6 +65,14 @@ def split_format_specifiers(specifiers):
else:
other.append(s)
+ # 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, without needing
+ # any kind of escaping that would be necessary for strprintf. Without this, this function
+ # would wrongly detect '%)' as a printf format specifier.
+ if numeric:
+ other = []
+
# numeric (Qt) can be present in any order, others (strprintf) must be in specified order
return set(numeric),other