summaryrefslogtreecommitdiffstats
path: root/share/palettes/i18n.py
blob: 5f0ab87c8aa792e522578f0ec76fb0b7c9b18072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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("];")