aboutsummaryrefslogtreecommitdiff
path: root/share/qt/extract_strings_qt.py
diff options
context:
space:
mode:
Diffstat (limited to 'share/qt/extract_strings_qt.py')
-rwxr-xr-xshare/qt/extract_strings_qt.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/share/qt/extract_strings_qt.py b/share/qt/extract_strings_qt.py
index d4bd585138..2ba8bb9b3a 100755
--- a/share/qt/extract_strings_qt.py
+++ b/share/qt/extract_strings_qt.py
@@ -1,8 +1,9 @@
#!/usr/bin/python
'''
-Extract _("...") strings for translation and convert to Qt4 stringdefs so that
+Extract _("...") strings for translation and convert to Qt stringdefs so that
they can be picked up by Qt linguist.
'''
+from __future__ import division,print_function,unicode_literals
from subprocess import Popen, PIPE
import glob
import operator
@@ -31,7 +32,7 @@ def parse_po(text):
in_msgstr = False
# message start
in_msgid = True
-
+
msgid = [line[6:]]
elif line.startswith('msgstr '):
in_msgid = False
@@ -52,17 +53,21 @@ files = sys.argv[1:]
# xgettext -n --keyword=_ $FILES
XGETTEXT=os.getenv('XGETTEXT', 'xgettext')
+if not XGETTEXT:
+ print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)
+ print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr)
+ exit(1)
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
(out, err) = child.communicate()
-messages = parse_po(out)
+messages = parse_po(out.decode('utf-8'))
f = open(OUT_CPP, 'w')
f.write("""
#include <QtGlobal>
-// Automatically generated by extract_strings.py
+// Automatically generated by extract_strings_qt.py
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
@@ -70,6 +75,10 @@ f.write("""
#endif
""")
f.write('static const char UNUSED *bitcoin_strings[] = {\n')
+f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('PACKAGE_NAME'),))
+f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS'),))
+if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'):
+ f.write('QT_TRANSLATE_NOOP("bitcoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),))
messages.sort(key=operator.itemgetter(0))
for (msgid, msgstr) in messages:
if msgid != EMPTY: