vcl: sfx2: LOK: Support per-view popup windows
[LibreOffice.git] / solenv / bin / hrcex
blob1c371a1ed48e5d13542ce40125e39af2915a9890
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, Popen, PIPE
10 try:
11 myopts, args = getopt.getopt(sys.argv[1:], "i:o:")
12 except getopt.GetoptError as e:
13 print(" Syntax: hrcex -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 xgettext = Popen(["xgettext", "-C", "--add-comments", "--keyword=NC_:1c,2", "--keyword=NNC_:1c,2,3", "--from-code=UTF-8", "--no-wrap", ifile, "-o", "-"], stdout=PIPE)
26 # while overall format is c++, all of the strings use custom placeholders and don't follow c-format
27 # esp. plain percent sign never is escaped explicitly
28 input = check_output(['sed', '-e', '/^#, c-format$/d'], stdin=xgettext.stdout)
29 xgettext.wait()
30 po = polib.pofile(input)
31 if len(po) != 0:
32 print >> output, ""
33 for entry in po:
34 keyid = entry.msgctxt + '|' + entry.msgid
35 print >> output, '#. ' + polib.genKeyId(keyid)
36 for i, occurrence in enumerate(entry.occurrences):
37 entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
38 print >> output, entry