summaryrefslogtreecommitdiffstats
path: root/share/palettes/i18n.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /share/palettes/i18n.py
parentInitial commit. (diff)
downloadinkscape-upstream.tar.xz
inkscape-upstream.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xshare/palettes/i18n.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/share/palettes/i18n.py b/share/palettes/i18n.py
new file mode 100755
index 0000000..5f0ab87
--- /dev/null
+++ b/share/palettes/i18n.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import sys
+import glob
+import re
+
+sys.stdout.write("char * stringlst = [")
+
+# Gimp palette format: R G B Label (255 0 0 Red)
+
+regex = re.compile(r'^\s*\d{1,3}\s+\d{1,3}\s+\d{1,3}\s+([^#\s].*)')
+regexnoc = re.compile(r'%')
+
+for filename in sys.argv[1:]:
+ file = open (filename, 'r')
+ for line in file:
+ match = regex.match(line)
+ if match:
+ sys.stdout.write('\n/* Palette: ' + filename + ' */')
+ search = regexnoc.search(match.group(1))
+ if search:
+ sys.stdout.write("/* xgettext:no-c-format */")
+ sys.stdout.write("NC_(\"Palette\", \"" + match.group(1) + "\"),")
+
+sys.stdout.write("];")