Changeset View
Changeset View
Standalone View
Standalone View
share/qt/extract_strings_qt.py
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if not XGETTEXT: | ||||
sys.exit(1) | sys.exit(1) | ||||
child = Popen([XGETTEXT, '--output=-', '-n', | child = Popen([XGETTEXT, '--output=-', '-n', | ||||
'--keyword=_'] + files, stdout=PIPE) | '--keyword=_'] + files, stdout=PIPE) | ||||
(out, err) = child.communicate() | (out, err) = child.communicate() | ||||
messages = parse_po(out.decode('utf-8')) | messages = parse_po(out.decode('utf-8')) | ||||
f = open(OUT_CPP, 'w', encoding="utf8") | f = open(OUT_CPP, 'w', encoding="utf8") | ||||
f.write('#include <QtGlobal>\n') | |||||
f.write('// Automatically @{} by extract_strings_qt.py\n'.format('generated')) | |||||
f.write(""" | f.write(""" | ||||
#include <QtGlobal> | |||||
// Automatically generated by extract_strings_qt.py | |||||
#ifdef __GNUC__ | #ifdef __GNUC__ | ||||
#define UNUSED __attribute__((unused)) | #define UNUSED __attribute__((unused)) | ||||
#else | #else | ||||
#define UNUSED | #define UNUSED | ||||
#endif | #endif | ||||
""") | """) | ||||
f.write('static const char UNUSED *bitcoin_strings[] = {\n') | f.write('static const char UNUSED *bitcoin_strings[] = {\n') | ||||
f.write('QT_TRANSLATE_NOOP("bitcoin-core", "{}"),\n'.format(os.getenv('PACKAGE_NAME'),)) | f.write('QT_TRANSLATE_NOOP("bitcoin-abc", "{}"),\n'.format(os.getenv('PACKAGE_NAME'),)) | ||||
f.write('QT_TRANSLATE_NOOP("bitcoin-core", "{}"),\n'.format(os.getenv('COPYRIGHT_HOLDERS'),)) | f.write('QT_TRANSLATE_NOOP("bitcoin-abc", "{}"),\n'.format(os.getenv('COPYRIGHT_HOLDERS'),)) | ||||
if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'): | if os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION') != os.getenv('PACKAGE_NAME'): | ||||
f.write('QT_TRANSLATE_NOOP("bitcoin-core", "{}"),\n'.format( | f.write('QT_TRANSLATE_NOOP("bitcoin-abc", "{}"),\n'.format( | ||||
os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),)) | os.getenv('COPYRIGHT_HOLDERS_SUBSTITUTION'),)) | ||||
messages.sort(key=operator.itemgetter(0)) | messages.sort(key=operator.itemgetter(0)) | ||||
for (msgid, msgstr) in messages: | for (msgid, msgstr) in messages: | ||||
if msgid != EMPTY: | if msgid != EMPTY: | ||||
f.write('QT_TRANSLATE_NOOP("bitcoin-core", {}),\n'.format('\n'.join(msgid))) | f.write('QT_TRANSLATE_NOOP("bitcoin-abc", {}),\n'.format('\n'.join(msgid))) | ||||
f.write('};\n') | f.write('};\n') | ||||
f.close() | f.close() |