1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2025-05-08 14:16:00 +02:00

More ISO 639-1 and ISO 639-3 fixes

ISO 639-1 uses two-letter codes and ISO 639-3 uses three-letter codes.
Technically there ISO 639-2/T and ISO 639-2/B, which also uses three
letter codes, but those are not supported by the pycountry library
so I won't even worry about them.

See: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
This commit is contained in:
2019-09-26 07:44:39 +03:00
parent ddbe970342
commit 86d4623fd3
2 changed files with 10 additions and 10 deletions

View File

@ -165,7 +165,7 @@ def suspicious_characters(field, field_name):
def language(field):
"""Check if a language is valid ISO 639-1 or ISO 639-2.
"""Check if a language is valid ISO 639-1 (alpha 2) or ISO 639-3 (alpha 3).
Prints the value if it is invalid.
"""
@ -182,7 +182,7 @@ def language(field):
for value in field.split("||"):
# After splitting, check if language value is 2 or 3 characters so we
# can check it against ISO 639-1 or ISO 639-2 accordingly.
# can check it against ISO 639-1 or ISO 639-3 accordingly.
if len(value) == 2:
if not languages.get(alpha_2=value):
print(f"Invalid ISO 639-1 language: {value}")
@ -190,7 +190,7 @@ def language(field):
pass
elif len(value) == 3:
if not languages.get(alpha_3=value):
print(f"Invalid ISO 639-2 language: {value}")
print(f"Invalid ISO 639-3 language: {value}")
pass
else: