summaryrefslogtreecommitdiffstats
path: root/solenv/bin/hrcex
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /solenv/bin/hrcex
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'solenv/bin/hrcex')
-rwxr-xr-xsolenv/bin/hrcex38
1 files changed, 38 insertions, 0 deletions
diff --git a/solenv/bin/hrcex b/solenv/bin/hrcex
new file mode 100755
index 000000000..1c371a1ed
--- /dev/null
+++ b/solenv/bin/hrcex
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+import polib
+import binascii
+import getopt
+import sys
+import os.path
+from subprocess import check_output, Popen, PIPE
+
+try:
+ myopts, args = getopt.getopt(sys.argv[1:], "i:o:")
+except getopt.GetoptError as e:
+ print(" Syntax: hrcex -i FileIn -o FileOut")
+ print(" FileIn: Source files (*.ui)")
+ print(" FileOut: Destination file (*.*)")
+ sys.exit(2)
+
+for o, a in myopts:
+ if o == '-i':
+ ifile = a
+ elif o == '-o':
+ ofile = a
+
+with open(ofile, "a") as output:
+ 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)
+ # while overall format is c++, all of the strings use custom placeholders and don't follow c-format
+ # esp. plain percent sign never is escaped explicitly
+ input = check_output(['sed', '-e', '/^#, c-format$/d'], stdin=xgettext.stdout)
+ xgettext.wait()
+ po = polib.pofile(input)
+ if len(po) != 0:
+ print >> output, ""
+ for entry in po:
+ keyid = entry.msgctxt + '|' + entry.msgid
+ print >> output, '#. ' + polib.genKeyId(keyid)
+ for i, occurrence in enumerate(entry.occurrences):
+ entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
+ print >> output, entry