From a1a0c284d0c377960fb6f07104d080f4ded06279 Mon Sep 17 00:00:00 2001 From: Reinder Feenstra Date: Sat, 13 Dec 2025 23:34:12 +0100 Subject: [PATCH] [cleanup] removed old translation format utility scripts --- utils/formatlocale.py | 12 --------- utils/locale2json.py | 20 -------------- utils/localeaddmissing.py | 16 ----------- utils/localeremoveold.py | 15 ----------- utils/traintastic.py | 57 --------------------------------------- 5 files changed, 120 deletions(-) delete mode 100644 utils/formatlocale.py delete mode 100644 utils/locale2json.py delete mode 100644 utils/localeaddmissing.py delete mode 100644 utils/localeremoveold.py delete mode 100644 utils/traintastic.py diff --git a/utils/formatlocale.py b/utils/formatlocale.py deleted file mode 100644 index c29b7a7b..00000000 --- a/utils/formatlocale.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys -from traintastic import read_locale_file, write_locale_file - - -def format_locale(filename): - (strings, header, garbage) = read_locale_file(filename) - write_locale_file(filename, header, strings, garbage) - - -if __name__ == "__main__": - for f in sys.argv[1:]: - format_locale(f) diff --git a/utils/locale2json.py b/utils/locale2json.py deleted file mode 100644 index ef3f1334..00000000 --- a/utils/locale2json.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -import os -import json -import codecs -from traintastic import read_locale_file - - -def to_json(filename_txt, filename_json): - (strings, header, garbage) = read_locale_file(filename_txt) - out = [] - for s in strings: - if not s['hash']: - out.append({'term': s['id'], 'definition': s['value']}) - with codecs.open(filename_json, 'w', 'utf-8') as f: - json.dump(out, f, indent=' ') - - -if __name__ == "__main__": - for f in sys.argv[1:]: - to_json(f, os.path.splitext(f)[0] + '.json') diff --git a/utils/localeaddmissing.py b/utils/localeaddmissing.py deleted file mode 100644 index 8d86ffb2..00000000 --- a/utils/localeaddmissing.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from traintastic import read_locale_file, write_locale_file - - -def locale_add_missing(source, destination): - src_strings = read_locale_file(source)[0] - (strings, header, garbage) = read_locale_file(destination) - for src in src_strings: - if not any((s['id'] == src['id'] and s['ns'] == src['ns']) for s in strings): - src['hash'] = True - strings.append(src) - write_locale_file(destination, header, strings, garbage) - - -if __name__ == "__main__": - locale_add_missing(sys.argv[1], sys.argv[2]) diff --git a/utils/localeremoveold.py b/utils/localeremoveold.py deleted file mode 100644 index 17c89728..00000000 --- a/utils/localeremoveold.py +++ /dev/null @@ -1,15 +0,0 @@ -import sys -from traintastic import read_locale_file, write_locale_file - - -def locale_remove_old(source, destination): - src_strings = read_locale_file(source)[0] - (strings, header, garbage) = read_locale_file(destination) - - strings = list(filter(lambda s: any((s['id'] == src['id'] and s['ns'] == src['ns']) for src in src_strings), strings)) - - write_locale_file(destination, header, strings, garbage) - - -if __name__ == "__main__": - locale_remove_old(sys.argv[1], sys.argv[2]) diff --git a/utils/traintastic.py b/utils/traintastic.py deleted file mode 100644 index c9f4b5f6..00000000 --- a/utils/traintastic.py +++ /dev/null @@ -1,57 +0,0 @@ -import os -import re -import codecs - - -def read_locale_file(filename): - with codecs.open(filename, 'r', 'utf-8') as f: - lines = f.readlines() - - header = '' - for line in lines: - if line.startswith('##'): - header += line - else: - break - - r = re.compile(r'^(#|)(([a-z0-9_\.:]*):([a-z0-9_\.-]+|[DINWECF][0-9]{4}))=(.*)$') - strings = [] - garbage = '' - for line in lines: - m = r.match(line) - if m is not None: - strings.append({ - 'id': m.group(2), - 'ns': m.group(3), - 'value': m.group(5), - 'hash': m.group(1) == '#', - }) - elif line != '\n' and line != '\r\n' and not line.startswith('##'): - garbage += line - - return (strings, header, garbage) - - -def write_locale_file(filename, header, strings, garbage=''): - txt = header - ns = None - for s in sorted(strings, key=lambda k: k['id']): - if ns != s['ns']: - ns = s['ns'] - txt += '\n' - txt += ('#' if s['hash'] else '') + s['id'] + '=' + s['value'] + '\n' - - if garbage != '': - txt += '\n\n#! Garbage\n' + garbage - - i = 0 - while True: - backup = filename + '~' + str(i) - if not os.path.exists(backup): - break - i += 1 - - os.rename(filename, backup) - - with codecs.open(filename, 'w', 'utf-8') as f: - f.write(txt)