Skip to content

Instantly share code, notes, and snippets.

@ritiek

ritiek/get_language.py

Last active Aug 13, 2019
Embed
What would you like to do?
Get official spoken languages in a country
# This data has been compiled from
# https://en.m.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory
country_languages = {
'Abkhazia': ['Abkhaz', 'Russian'],
'Afghanistan': ['Pashto', 'Dari'],
'Albania': ['Albanian'],
'Algeria': ['Arabic', 'Tamazight'],
'Andorra': ['Catalan'],
'Angola': ['Portuguese'],
'Antigua and Barbuda': ['English (de facto)'],
'Argentina': ['Spanish (de-facto)'],
'Armenia': ['Armenian'],
'Artsakh': ['Armenian'],
'Australia': ['English (de facto)'],
'Austria': ['German', 'Croatian (parts of Burgenland)', 'Hungarian (parts of Burgenland)', 'Slovene (parts of Carinthia)'],
'Azerbaijan': [''],
'Bahamas': ['English'],
'Bahrain': ['Arabic'],
'Bangladesh': ['Bengali'],
'Barbados': ['English'],
'Belarus': ['Belarusian', 'Russian'],
'Belgium': [''],
'Belize': ['English'],
'Benin': ['French'],
'Bhutan': ['Dzongkha'],
'Bolivia': ['Castilian', '(37 other languages)'],
'Bosnia and Herzegovina': ['Bosnian(de facto)'],
'Botswana': ['English', 'Tswana'],
'Brazil': ['Portuguese'],
'Brunei': ['Malay', 'English'],
'Bulgaria': ['Bulgarian'],
'Burkina Faso': ['French'],
'Burundi': ['French', 'Kirundi', 'English'],
'Cambodia': ['Khmer'],
'Cameroon': ['English', 'French'],
'Canada': ['English (Federal)', 'French (Federal)'],
'Cape Verde': ['Portuguese'],
'Central African Republic': ['French'],
'Chad': ['Arabic', 'French'],
'Chile': ['Spanish (de facto)'],
'China': ['Mandarin'],
'Colombia': ['Spanish'],
'Comoros': ['Arabic', 'Comorian', 'French'],
'Democratic Republic of the Congo': ['French'],
'Republic of the Congo': ['French'],
'Costa Rica': ['Spanish'],
'Croatia': ['Croatian'],
'Cuba': ['Spanish'],
'Cyprus': ['Greek'],
'Czech Republic': ['Czech'],
'Denmark': ['Danish'],
'Djibouti': ['Arabic', 'French'],
'Dominica': ['English'],
'Dominican Republic': ['Spanish'],
'East Timor': ['Portuguese'],
'Ecuador': ['Spanish', 'Quechua (official language of intercultural relation)'],
'Egypt': ['Arabic'],
'El Salvador': ['Spanish'],
'Equatorial Guinea': ['French', 'Portuguese', 'Spanish'],
'Eritrea': ['Tigrinya'],
'Estonia': ['Estonian'],
'Eswatini': ['English', 'Swazi'],
'Ethiopia': ['Amharic'],
'Fiji': ['English', 'Fijian', 'Fiji Hindi'],
'Finland': ['Finnish', 'Swedish'],
'France': ['French'],
'Gabon': ['French'],
'Gambia': ['English'],
'Georgia': ['Georgian'],
'Germany': ['German'],
'Ghana': ['English'],
'Greece': ['Greek'],
'Grenada': ['English'],
'Guatemala': ['Spanish'],
'Guinea': ['French'],
'Guinea-Bissau': ['Portuguese'],
'Guyana': ['English'],
'Haiti': ['French', 'Haitian Creole'],
'Honduras': ['Spanish'],
'Hong Kong': ['Cantonese (de facto)', 'English'],
'Hungary': ['Hungarian'],
'Iceland': ['Icelandic'],
'India': ['Hindi', 'English'],
'Indonesia': ['Indonesian'],
'Iran': ['Persian'],
'Iraq': ['Arabic'],
'Ireland': ['English', 'Irish'],
'Israel': ['Hebrew'],
'Italy': ['Italian'],
'Ivory Coast': ['French'],
'Jamaica': ['English'],
'Japan': ['Japanese'],
'Jordan': ['Arabic'],
'Kazakhstan': ['Russian'],
'Kenya': ['English'],
'Kiribati': ['English'],
'North Korea': ['Korean'],
'South Korea': ['Korean', 'Korean Sign Language'],
'Kosovo': ['Albanian', 'Serbian'],
'Kuwait': ['Standard Arabic'],
'Kyrgyzstan': ['Russian'],
'Laos': ['Lao'],
'Latvia': ['Latvian'],
'Lebanon': ['Arabic'],
'Lesotho': ['English'],
'Liberia': ['English'],
'Libya': ['Arabic'],
'Liechtenstein': ['German'],
'Lithuania': ['Lithuanian'],
'Luxembourg': ['French', 'German'],
'Macau': ['Cantonese (de facto)', 'Portuguese'],
'Madagascar': ['French', 'Malagasy'],
'Malawi': ['English', 'Chichewa'],
'Malaysia': ['Malay'],
'Maldives': ['Dhivehi'],
'Mali': ['French'],
'Malta': ['English'],
'Sovereign Military Order of Malta': ['Italian'],
'Marshall Islands': ['English'],
'Mauritania': ['Arabic'],
'Mauritius': ['English'],
'Mexico': ['Spanish (de facto)'],
'Federated States of Micronesia': ['Woleaian'],
'Moldova': ['Romanian'],
'Monaco': ['French'],
'Mongolia': ['Mongolian'],
'Montenegro': ['Albanian (in Ulcinj)', 'Croatian (in Tivat)', 'Serbian (in Herceg Novi)'],
'Morocco': ['Arabic', 'Berber'],
'Mozambique': ['Portuguese'],
'Myanmar (Burma)': ['Burmese'],
'Namibia': ['English'],
'Nauru': ['English', 'Nauruan'],
'Nepal': [''],
'Netherlands': ['Dutch (de facto)'],
'New Zealand': ['English (de facto)', 'Māori', 'New Zealand Sign Language'],
'Nicaragua': ['Spanish'],
'Niger': ['French'],
'Nigeria': ['English'],
'North Macedonia': ['Macedonian', 'Albanian'],
'Northern Cyprus': ['Turkish'],
'Norway': ['Norwegian'],
'Oman': ['Arabic'],
'Pakistan': ['English', 'Urdu'],
'Palau': ['English', 'Palauan'],
'Palestine': ['Arabic (de facto)'],
'Panama': ['Spanish'],
'Papua New Guinea': ['English', 'Hiri Motu', 'PNG Sign Language', 'Tok Pisin'],
'Paraguay': ['Spanish', 'Guaraní'],
'Peru': ['Spanish', 'Aymara', 'Quechua'],
'Philippines': ['English', 'Filipino', 'Filipino Sign Language'],
'Poland': ['Polish'],
'Portugal': ['Portuguese'],
'Qatar': ['Arabic'],
'Romania': ['Romanian'],
'Russia': ['Russian', 'Ukrainian'],
'Rwanda': ['English', 'French', 'Kinyarwanda', 'Swahili'],
'Sahrawi Arab Democratic Republic': ['Tamazight', 'Arabic', 'Spanish'],
'Saint Kitts and Nevis': ['English'],
'Saint Lucia': ['English'],
'Saint Vincent and the Grenadines': ['English'],
'Samoa': ['English'],
'San Marino': ['Italian'],
'São Tomé and Príncipe': ['Portuguese'],
'Saudi Arabia': ['Arabic'],
'Senegal': ['French'],
'Serbia': ['Serbian'],
'Seychelles': ['English', 'French', 'Seychellois Creole'],
'Sierra Leone': ['English'],
'Singapore': ['English', 'Malay', 'Mandarin', 'Tamil'],
'Slovakia': ['Bulgarian', 'Czech', 'German', 'Polish', 'Romani', 'Rusyn', 'Serbian', 'Slovak', 'Ukrainian'],
'Slovenia': ['Slovene'],
'Solomon Islands': ['English'],
'Somalia': ['Arabic'],
'Somaliland': ['Arabic', 'English', 'Somali'],
'South Africa': ['Afrikaans', 'English', 'Southern Ndebele', 'Sotho', 'Northern Sotho', 'Swazi', 'Tsonga', 'Tswana', 'Venda', 'Xhosa', 'Zulu'],
'South Ossetia': ['Ossetian', 'Russian'],
'South Sudan': ['English'],
'Spain': ['Spanish'],
'Sri Lanka': ['Sinhala', 'Tamil'],
'Sudan': ['Arabic', 'English'],
'Suriname': ['Dutch'],
'Sweden': ['Swedish'],
'Switzerland': ['French (Bern, Fribourg, Geneva, Jura, Neuchâtel, Valais, Vaud)', 'German (Aargau, Appenzell Ausserrhoden, Appenzell Innerrhoden, Basel-Landschaft, Basel-Stadt, Bern, Fribourg, Glarus, Graubünden, Lucerne, Nidwalden, Obwalden, Saint Gallen, Schaffhausen, Schwyz, Solothurn, Thurgau, Uri, Valais, Zug, Zürich)', 'Italian (Ticino, Graubünden)', 'Romansh (Graubünden)'],
'Syria': ['Arabic'],
'Taiwan': ['Mandarin (de facto)'],
'Tajikistan': [''],
'Tanzania': ['English'],
'Thailand': ['Thai'],
'Togo': ['French'],
'Tonga': ['English'],
'Transnistria': ['Moldovan', 'Russian', 'Ukrainian'],
'Trinidad and Tobago': ['English'],
'Tunisia': [''],
'Turkey': ['Turkish'],
'Turkmenistan': [''],
'Tuvalu': ['English (de facto)'],
'Uganda': ['English', 'Swahili'],
'Ukraine': ['Ukrainian'],
'United Arab Emirates': ['Arabic'],
'United Kingdom': ['English (de facto)'],
'United States': ['English (de facto)'],
'Uruguay': ['Spanish (de facto)'],
'Uzbekistan': [''],
'Vanuatu': ['English', 'French'],
'Vatican City': ['Italian'],
'Venezuela': ['Spanish', 'Venezuelan Sign Language'],
'Vietnam': [''],
'Yemen': ['Arabic'],
'Zambia': ['English'],
'Zimbabwe': ['Chewa', 'Chibarwe', 'English', 'Kalanga', 'Khoisan'],
}
country = input("Name a country: ")
languages = country_languages[country]
print("The official languages of", country, "are", languages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.