From e868f47852ee814975861c61167b82243dc310ad Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 2 Nov 2015 11:23:46 +0000 Subject: [PATCH] add script for extracting a list of translators from the .po files --- scripts/get-translator-credits.py | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/get-translator-credits.py diff --git a/scripts/get-translator-credits.py b/scripts/get-translator-credits.py new file mode 100644 index 0000000000..2e9f5c1e25 --- /dev/null +++ b/scripts/get-translator-credits.py @@ -0,0 +1,40 @@ +import subprocess +import re +from collections import defaultdict + +authors_by_locale = defaultdict(set) + +file_listing = subprocess.Popen('find ../wagtail -iname *.po', shell=True, stdout=subprocess.PIPE) + +for file_listing_line in file_listing.stdout: + filename = file_listing_line.strip() + + # extract locale string from filename + locale = re.search(r'locale/(\w+)/LC_MESSAGES', filename).group(1) + if locale == 'en': + continue + + # read author list from each file + with file(filename) as f: + has_found_translators_heading = False + for line in f: + line = line.strip() + if line.startswith('#'): + if has_found_translators_heading: + author = re.match(r'\# (.*), [\d\-]+', line).group(1) + authors_by_locale[locale].add(author) + elif line.startswith('# Translators:'): + has_found_translators_heading = True + else: + if has_found_translators_heading: + break + else: + raise Exception("No 'Translators:' heading found in %s" % filename) + +locales = sorted(authors_by_locale.keys()) +for locale in locales: + print(locale) + print("-----") + for author in sorted(authors_by_locale[locale]): + print(author) + print('')