8 from subprocess import check_output
11 myopts, args = getopt.getopt(sys.argv[1:], "i:o:")
12 except getopt.GetoptError as e:
13 print(" Syntax: uiex -i FileIn -o FileOut")
14 print(" FileIn: Source files (*.ui)")
15 print(" FileOut: Destination file (*.*)")
24 with open(ofile, "a") as output:
25 input = check_output(["xgettext", "--add-comments", "--no-wrap", ifile, "-o", "-"], encoding="UTF-8")
26 po = polib.pofile(input)
28 print("", file=output)
30 # skip 'stock' entries like "cancel", "help", "ok", etc
31 # l10ntools/source/localize.cxx will insert one entry for each stock per .po
32 if entry.msgctxt == "stock":
34 keyid = entry.msgctxt + '|' + entry.msgid
35 print('#. ' + polib.genKeyId(keyid), file=output)
36 for i, occurrence in enumerate(entry.occurrences):
37 entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
38 print(entry, file=output)