views:

153

answers:

3

Is there any python library to get a list of countries for a specific language code where it is an official or commonly used language?

For example, language code of "fr" is associated with 29 countries where French is an official language plus 8 countries where it's commonly used.

+1  A: 

pycountry (seriously). You can get it from the Package Index.

doug
I just had a look at the documentation for it, and it doesn't seem like you can provide a language code, and get a list of all the countries that use that language
a_m0d
might be worth checking again--the reason i say that is because I used this package for a similar purpose (currencies)--*but* i wasn't able to use the interface. Instead i had to work directly with the five XML databases provided in the package.
doug
@a_m0d: You may need to write some code yourself.
John Machin
A: 

Look for the Babel package. It has a pickle file for each supported locale. See the list() function in the localedata module for getting a list of ALL locales. Then write some code to split the locales into (language, country) etc etc

John Machin
A: 

Check out Ethnologue: http://www.ethnologue.com/country_index.asp

Be careful though...

India has a lot of official languages: https://secure.wikimedia.org/wikipedia/en/wiki/Languages_with_official_status_in_India

NinjaCat