2018-08-13 18:07:52 +02:00
|
|
|
#!/usr/bin/env python3
|
2019-12-31 18:35:41 +01:00
|
|
|
# Copyright (c) 2012-2019 The Bitcoin Core developers
|
2016-09-19 17:02:23 +02:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2011-06-13 19:24:53 +02:00
|
|
|
'''
|
2016-03-29 17:22:38 +02:00
|
|
|
Extract _("...") strings for translation and convert to Qt stringdefs so that
|
2011-06-13 19:24:53 +02:00
|
|
|
they can be picked up by Qt linguist.
|
|
|
|
'''
|
|
|
|
from subprocess import Popen, PIPE
|
2012-06-13 18:17:28 +02:00
|
|
|
import operator
|
2013-09-14 17:48:27 +02:00
|
|
|
import os
|
2014-07-03 07:31:50 +02:00
|
|
|
import sys
|
2011-06-13 19:24:53 +02:00
|
|
|
|
2015-04-15 01:14:56 +02:00
|
|
|
OUT_CPP="qt/dashstrings.cpp"
|
2011-06-13 19:24:53 +02:00
|
|
|
EMPTY=['""']
|
|
|
|
|
|
|
|
def parse_po(text):
|
|
|
|
"""
|
|
|
|
Parse 'po' format produced by xgettext.
|
|
|
|
Return a list of (msgid,msgstr) tuples.
|
|
|
|
"""
|
|
|
|
messages = []
|
|
|
|
msgid = []
|
|
|
|
msgstr = []
|
|
|
|
in_msgid = False
|
|
|
|
in_msgstr = False
|
|
|
|
|
|
|
|
for line in text.split('\n'):
|
|
|
|
line = line.rstrip('\r')
|
|
|
|
if line.startswith('msgid '):
|
|
|
|
if in_msgstr:
|
|
|
|
messages.append((msgid, msgstr))
|
|
|
|
in_msgstr = False
|
|
|
|
# message start
|
|
|
|
in_msgid = True
|
2015-01-31 19:47:23 +01:00
|
|
|
|
2011-06-13 19:24:53 +02:00
|
|
|
msgid = [line[6:]]
|
|
|
|
elif line.startswith('msgstr '):
|
|
|
|
in_msgid = False
|
|
|
|
in_msgstr = True
|
|
|
|
msgstr = [line[7:]]
|
|
|
|
elif line.startswith('"'):
|
|
|
|
if in_msgid:
|
|
|
|
msgid.append(line)
|
|
|
|
if in_msgstr:
|
|
|
|
msgstr.append(line)
|
|
|
|
|
|
|
|
if in_msgstr:
|
|
|
|
messages.append((msgid, msgstr))
|
|
|
|
|
|
|
|
return messages
|
|
|
|
|
2014-07-03 07:31:50 +02:00
|
|
|
files = sys.argv[1:]
|
2011-06-13 19:24:53 +02:00
|
|
|
|
|
|
|
# xgettext -n --keyword=_ $FILES
|
2013-09-19 14:59:45 +02:00
|
|
|
XGETTEXT=os.getenv('XGETTEXT', 'xgettext')
|
2016-03-29 17:22:38 +02:00
|
|
|
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)
|
2017-08-28 22:53:34 +02:00
|
|
|
sys.exit(1)
|
Merge #6122: chore: translations 2024-07
85762dc633a6d427fee73967e77a3dd85642e3a2 60%+: bg, ro, vi (UdjinM6)
2d0e68dcd68a131c5be99e730a2cfaab2222189e 80%+: ar, de, es, fi, fr, it, ja, ko, nl, pl, pt, ru, sk, th, tr, zh_CN, zh_TW (UdjinM6)
f7992b0b030bdbca8dae6d4e98d61913beb8008e en (UdjinM6)
49fc976121a4708c83dc24962e3e49e13fcdd9c9 dashstrings (UdjinM6)
c8333a59c554426561035d2b31696f1f796ffc62 chore: replace remaining `...` with `…` in translated strings (UdjinM6)
ac2e9ea1e797808d9d6f867faa55a04c4d1885f9 qt: Extract translations correctly from UTF-8 formatted source (Hennadii Stepanov)
Pull request description:
## Issue being fixed or feature implemented
Mostly regular translation updates but with 2 additional fixes:
- ac2e9ea is a backport, without it `make translate` fails to update `dashstrings.cpp` properly (but I couldn't figure out which PR it belongs to 🤷♂️ )
- c8333a5 is needed to make it easier to replace all `...` with `…` in `*.ts` files locally to avoid annoying translators (`...` and `…` are visually the same in transifex interface)
## What was done?
## How Has This Been Tested?
## Breaking Changes
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
ACKs for top commit:
PastaPastaPasta:
utACK 85762dc633a6d427fee73967e77a3dd85642e3a2
Tree-SHA512: c3624d8e5b26b0fd4d488e6988e81000d05bdc66f9e126b5d3fe3c1f6bceaa846ee81dfc7c0d18613b0ac682a94e0b17007e86724e7cc02d9cfce87b22ce6916
2024-07-23 20:37:00 +02:00
|
|
|
child = Popen([XGETTEXT,'--output=-','--from-code=utf-8','-n','--keyword=_'] + files, stdout=PIPE)
|
2011-06-13 19:24:53 +02:00
|
|
|
(out, err) = child.communicate()
|
|
|
|
|
2016-03-29 17:22:38 +02:00
|
|
|
messages = parse_po(out.decode('utf-8'))
|
2011-06-13 19:24:53 +02:00
|
|
|
|
2018-06-16 15:21:01 +02:00
|
|
|
f = open(OUT_CPP, 'w', encoding="utf8")
|
2013-04-13 07:13:08 +02:00
|
|
|
f.write("""
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2016-05-25 15:49:57 +02:00
|
|
|
// Automatically generated by extract_strings_qt.py
|
2012-04-15 12:53:14 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define UNUSED __attribute__((unused))
|
|
|
|
#else
|
|
|
|
#define UNUSED
|
|
|
|
#endif
|
|
|
|
""")
|
2015-03-19 15:15:08 +01:00
|
|
|
f.write('static const char UNUSED *dash_strings[] = {\n')
|
2016-02-04 13:41:58 +01:00
|
|
|
f.write('QT_TRANSLATE_NOOP("dash-core", "%s"),\n' % (os.getenv('COPYRIGHT_HOLDERS'),))
|
2012-06-13 18:17:28 +02:00
|
|
|
messages.sort(key=operator.itemgetter(0))
|
2011-06-13 19:24:53 +02:00
|
|
|
for (msgid, msgstr) in messages:
|
|
|
|
if msgid != EMPTY:
|
2015-03-19 15:15:08 +01:00
|
|
|
f.write('QT_TRANSLATE_NOOP("dash-core", %s),\n' % ('\n'.join(msgid)))
|
2013-04-13 07:13:08 +02:00
|
|
|
f.write('};\n')
|
2011-06-13 19:24:53 +02:00
|
|
|
f.close()
|