summaryrefslogtreecommitdiffstats
path: root/solenv/bin/uiex
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /solenv/bin/uiex
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xsolenv/bin/uiex38
1 files changed, 38 insertions, 0 deletions
diff --git a/solenv/bin/uiex b/solenv/bin/uiex
new file mode 100755
index 000000000..b9344c429
--- /dev/null
+++ b/solenv/bin/uiex
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+import polib
+import binascii
+import getopt
+import sys
+import os.path
+from subprocess import check_output
+
+try:
+ myopts, args = getopt.getopt(sys.argv[1:], "i:o:")
+except getopt.GetoptError as e:
+ print(" Syntax: uiex -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:
+ input = check_output(["xgettext", "--add-comments", "--no-wrap", ifile, "-o", "-"], encoding="UTF-8")
+ po = polib.pofile(input)
+ if len(po) != 0:
+ print("", file=output)
+ for entry in po:
+ # skip 'stock' entries like "cancel", "help", "ok", etc
+ # l10ntools/source/localize.cxx will insert one entry for each stock per .po
+ if entry.msgctxt == "stock":
+ continue
+ keyid = entry.msgctxt + '|' + entry.msgid
+ print('#. ' + polib.genKeyId(keyid), file=output)
+ for i, occurrence in enumerate(entry.occurrences):
+ entry.occurrences[i] = os.path.relpath(occurrence[0], os.environ['SRCDIR']), occurrence[1]
+ print(entry, file=output)