Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Does anyone know of a list of countries with their associated official language codes? I haven't found anything by Googling yet.

What I'm looking for is something like this:

Country name/code              Language code
[...]
Bulgaria (BG)                  bg
Belgium (BE)                   nl, fr
[...]    

Some further clarifications:

How is there not a correlation between a country and its official language(s)?

In my application this is relevant because I want to redirect someone who accesses it from the US to ${path}/us/en/, so I need to get the official language tag. I get the country code from a geolocation web service and I need the associated (official) language code.

For example, I have everything on my computer set to english, but I live in Romania. When I access it I don't want to get redirected to the UK version, ro/en does not exist, so I want ro/ro.

I wanted to see if there was an already aggregated list so that I wouldn't have to do it manually. If there isn't, I'll build one :).

share|improve this question
    
This isn't really a question about GIS. –  Sean Jun 28 '11 at 13:20
    
See stackoverflow.com/questions/1876103/… –  Sean Jun 28 '11 at 13:29
add comment

4 Answers 4

up vote 11 down vote accepted

The countryInfo file from http://geonames.org (http://download.geonames.org/export/dump/countryInfo.txt) has names, country codes, languages and lots of other info. It is a tab separated list so awk or any text editor will let you select just the columns you need.

share|improve this answer
1  
+1 just for the reference to AWK! –  whuber Jun 28 '11 at 13:25
add comment

The information you are looking for is actually 2 separate pieces of information. I am not sure there is a direct correlation between the two.

Country codes are available at: www.iso.org/iso/english_country_names_and_code_elements

And language codes are available at: www.loc.gov/standards/iso639-2/php/code_list.php

Mixing the pieces of information together is something done in "locales". This seems to be something that is not real standardized. Lots of companies appear to be doing it on their own and even providing utilities for supporting this in things like Java (See http://java.sun.com/developer/technicalArticles/J2SE/locale/).

This site has more information on language tags: www.langtag.net/.

BTW, the relationship of country codes to language code is not usually that meaningful in a user application. There are lots of users in a country that use "non-native" languages. (IE: someone in the U.S. that uses Chinese, or vice-versa.)

share|improve this answer
add comment

Searching Stack Overflow for "locale list" resulted in this:

http://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes

Throw one of those lists into your Favorite Programming Language and then you can make a table like what you want.

share|improve this answer
add comment

Codes arranged alphabetically by alpha-3/ISO 639-2 Code

http://www.loc.gov/standards/iso639-2/php/code_list.php

via google> wiki> external site

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.