Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / solenv / bin / uiex
blobc9b00b2e062c7ab1688f13a0e3c799c5490f4811
1 #!/usr/bin/python
3 import polib
4 import binascii
5 import getopt
6 import sys
7 import os.path
8 from subprocess import check_output
10 try:
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 (*.*)")
16 sys.exit(2)
18 for o, a in myopts:
19 if o == '-i':
20 ifile = a
21 elif o == '-o':
22 ofile = a
24 with open(ofile, "a") as output:
25 input = check_output(["xgettext", "--add-comments", "--no-wrap", ifile, "-o", "-"])
26 po = polib.pofile(input)
27 if len(po) != 0:
28 print >> output, ""
29 for entry in po:
30 keyid = entry.msgctxt + '|' + entry.msgid
31 print >> output, '#. ' + polib.genKeyId(keyid)
32 for i, occurrence in enumerate(entry.occurrences):
33 entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
34 print >> output, entry