aboutsummaryrefslogtreecommitdiff
path: root/share/qt/extract_strings_qt.py
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2016-08-09 05:45:50 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2016-08-09 05:45:50 +0000
commitdf634908ba758232413c50e8f1f7a80d546d777b (patch)
tree92cccae378b192f5f70986d2167209cbfd24ae08 /share/qt/extract_strings_qt.py
parente98e3dde6a976a2c8f266ee963d6931fd4b37262 (diff)
parente4382fbef56a0e04b0ed834e8b3a3a16f81db149 (diff)
downloadbitcoin-df634908ba758232413c50e8f1f7a80d546d777b.tar.xz
Merge tag 'branch-0.13' into bugfix_gitdir
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: