3 Extract _("...") strings for translation and convert to Qt4 stringdefs so that 4 they can be picked up by Qt linguist. 6 from subprocess
import Popen, PIPE
12 OUT_CPP=
"qt/dashstrings.cpp" 17 Parse 'po' format produced by xgettext. 18 Return a list of (msgid,msgstr) tuples. 26 for line
in text.split(
'\n'):
27 line = line.rstrip(
'\r')
28 if line.startswith(
'msgid '):
30 messages.append((msgid, msgstr))
36 elif line.startswith(
'msgstr '):
40 elif line.startswith(
'"'):
47 messages.append((msgid, msgstr))
54 XGETTEXT=os.getenv(
'XGETTEXT',
'xgettext')
55 child = Popen([XGETTEXT,
'--output=-',
'-n',
'--keyword=_'] + files, stdout=PIPE)
56 (out, err) = child.communicate()
60 f = open(OUT_CPP,
'w')
65 // Automatically generated by extract_strings.py 67 #define UNUSED __attribute__((unused)) 72 f.write(
'static const char UNUSED *dash_strings[] = {\n')
73 messages.sort(key=operator.itemgetter(0))
74 for (msgid, msgstr)
in messages:
76 f.write(
'QT_TRANSLATE_NOOP("dash-core", %s),\n' % (
'\n'.join(msgid)))