-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathexample.py
More file actions
22 lines (19 loc) · 761 Bytes
/
example.py
File metadata and controls
22 lines (19 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import string
import langcodes
# Iterate through all 2- and 3-letter language codes, and for all languages
# that have enough data to represent their own name, show:
#
# - The original code
# - The code after normalization
# - The language's name in English
# - The language's name in that language (its autonym)
en = langcodes.get('en')
for let1 in string.ascii_lowercase:
for let2 in string.ascii_lowercase:
for let3 in [''] + list(string.ascii_lowercase):
code = let1 + let2 + let3
lcode = langcodes.get(code)
if lcode.has_name_data():
autonym = lcode.autonym()
name = lcode.language_name()
print('%-3s %-3s %-30s %s' % (code, lcode.language, name, autonym))