2015-11-02 11:23:46 +00:00
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
from collections import defaultdict
|
2017-03-07 11:50:14 +00:00
|
|
|
from io import open
|
2015-11-02 11:23:46 +00:00
|
|
|
|
2016-03-09 12:18:32 +00:00
|
|
|
from babel import Locale
|
|
|
|
|
2015-11-02 11:23:46 +00:00
|
|
|
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
|
2017-03-07 11:50:14 +00:00
|
|
|
locale = re.search(r'locale/(\w+)/LC_MESSAGES', str(filename)).group(1)
|
2015-11-02 11:23:46 +00:00
|
|
|
if locale == 'en':
|
|
|
|
continue
|
|
|
|
|
|
|
|
# read author list from each file
|
2017-03-07 11:50:14 +00:00
|
|
|
with open(filename, 'rt') as f:
|
2015-11-02 11:23:46 +00:00
|
|
|
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)
|
|
|
|
|
2019-04-08 20:55:03 +00:00
|
|
|
|
|
|
|
LANGUAGE_OVERRIDES = {
|
|
|
|
'tet': 'Tetum',
|
2020-04-21 13:36:25 +00:00
|
|
|
'ht': 'Haitian',
|
2019-04-08 20:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def get_language_name(locale_string):
|
|
|
|
try:
|
|
|
|
return LANGUAGE_OVERRIDES[locale_string]
|
|
|
|
except KeyError:
|
|
|
|
return Locale.parse(locale_string).english_name
|
|
|
|
|
2020-10-02 15:56:26 +00:00
|
|
|
|
2016-03-09 12:18:32 +00:00
|
|
|
language_names = [
|
2019-04-08 20:55:03 +00:00
|
|
|
(get_language_name(locale_string), locale_string)
|
2016-03-09 12:18:32 +00:00
|
|
|
for locale_string in authors_by_locale.keys()
|
|
|
|
]
|
|
|
|
language_names.sort()
|
|
|
|
|
|
|
|
for (language_name, locale) in language_names:
|
2017-03-07 11:50:14 +00:00
|
|
|
print(("%s - %s" % (language_name, locale)))
|
2015-11-02 11:23:46 +00:00
|
|
|
print("-----")
|
|
|
|
for author in sorted(authors_by_locale[locale]):
|
|
|
|
print(author)
|
|
|
|
print('')
|