18

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 :).

3

4 Answers 4

31

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.

0
2

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.)

0

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

https://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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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