|
1 | | -#!/usr/bin/python |
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2012-2017 The Syscoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
2 | 5 | ''' |
3 | | -Extract _("...") strings for translation and convert to Qt4 stringdefs so that |
| 6 | +Extract _("...") strings for translation and convert to Qt stringdefs so that |
4 | 7 | they can be picked up by Qt linguist. |
5 | 8 | ''' |
6 | 9 | from subprocess import Popen, PIPE |
7 | | -import glob |
8 | 10 | import operator |
9 | 11 | import os |
10 | 12 | import sys |
@@ -52,24 +54,32 @@ def parse_po(text): |
52 | 54 |
|
53 | 55 | # xgettext -n --keyword=_ $FILES |
54 | 56 | XGETTEXT=os.getenv('XGETTEXT', 'xgettext') |
| 57 | +if not XGETTEXT: |
| 58 | + print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr) |
| 59 | + print('Please install package "gettext" and re-run \'./configure\'.',file=sys.stderr) |
| 60 | + sys.exit(1) |
55 | 61 | child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE) |
56 | 62 | (out, err) = child.communicate() |
57 | 63 |
|
58 | | -messages = parse_po(out) |
| 64 | +messages = parse_po(out.decode('utf-8')) |
59 | 65 |
|
60 | 66 | f = open(OUT_CPP, 'w') |
61 | 67 | f.write(""" |
62 | 68 |
|
63 | 69 | #include <QtGlobal> |
64 | 70 |
|
65 | | -// Automatically generated by extract_strings.py |
| 71 | +// Automatically generated by extract_strings_qt.py |
66 | 72 | #ifdef __GNUC__ |
67 | 73 | #define UNUSED __attribute__((unused)) |
68 | 74 | #else |
69 | 75 | #define UNUSED |
70 | 76 | #endif |
71 | 77 | """) |
72 | 78 | f.write('static const char UNUSED *syscoin_strings[] = {\n') |
| 79 | +f.write('QT_TRANSLATE_NOOP("syscoin-core", "%s"),\n' % (os.getenv('PACKAGE_NAME'),)) |
| 80 | +f.write('QT_TRANSLATE_NOOP("syscoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS'),)) |
| 81 | +if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'): |
| 82 | + f.write('QT_TRANSLATE_NOOP("syscoin-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),)) |
73 | 83 | messages.sort(key=operator.itemgetter(0)) |
74 | 84 | for (msgid, msgstr) in messages: |
75 | 85 | if msgid != EMPTY: |
|
0 commit comments