This PHP function will convert the language code to the language name, using the Library of Congress data file:
function lang_code_to_name($code)
{
// init
$lines = array();
$line_items = array();
$language = '';
$code = strtolower($code);
// strip any possible sub-language
$pos = strpos($code, '-');
if ($pos) {$code = substr($code, 0, $pos);}
// get code list from Library of Congress
// format: five elements per line
// ISO 639-2 Alpha-3 bibliographic code|ISO 639-2 Alpha-3 terminology code|ISO 639-1 Alpha-2 code|English language name(s)|French language name(s)
$url = 'http://loc.gov/standards/iso639-2/ISO-639-2_utf-8.txt';
$list = file_get_contents($url);
if (!$list) {return $language;}
// read the file
$lines = explode("\n", $list);
for ($i; $i < sizeof($lines); $i++)
{
$line_item = explode("|", $lines[$i]);
if (($line_item[0] == $code) || ($line_item[1] == $code) || ($line_item[2] == $code))
{
$language = $line_item[3];
break;
}
}
// exit
return $language;
}