language-data/list-diff
Michal Čihař 05a1dc6333 Do not report obsolete code to be missing
Signed-off-by: Michal Čihař <michal@cihar.com>
2018-01-09 15:53:30 +01:00

39 lines
1.1 KiB
Python
Executable file

#! /usr/bin/env python3
#
# Copyright © 2018 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
OLDCODES = set(('in', 'iw', 'jw', 'ji', 'no'))
import csv
# Read the definitions
def parse_csv(name):
result = {}
with open(name, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
for data in reader:
if data[0] in result:
print('Duplicate {} in {}!'.format(data[0], name))
continue
result[data[0]] = data
return result
LANGUAGES = parse_csv('languages.csv')
CLDR = parse_csv('cldr.csv')
# Iterate over common languages
for code in sorted(set(CLDR) & set(LANGUAGES)):
if CLDR[code] != LANGUAGES[code]:
print('Defintion for {} differs:'.format(code))
print('Gettext:', LANGUAGES[code])
print('CLDR:', CLDR[code])
print()
# List missing ones
for code in sorted(set(CLDR) - set(LANGUAGES) - OLDCODES):
print('Defintion for {} missing in gettext:'.format(code))
print('CLDR:', CLDR[code])
print()