make language name translatable and fallback to language code if we dont have the language name

This commit is contained in:
Robin Appelman 2012-01-15 15:25:58 +01:00
parent 7cd809b286
commit 37c0b97b3c
1 changed files with 9 additions and 1 deletions

View File

@ -28,10 +28,18 @@ $languageCodes=OC_L10N::findAvailableLanguages();
//put the current language in the front
unset($languageCodes[array_search($lang,$languageCodes)]);
array_unshift($languageCodes,$lang);
$languageNames=include 'languageCodes.php';
$languages=array();
foreach($languageCodes as $lang){
$languages[]=array('code'=>$lang,'name'=>@$languageNames[$lang]);
$l=new OC_L10N('core',$lang);
if($l->t('__language_name__')!='__language_name__'){//first check if the language name is in the translation file
$languages[]=array('code'=>$lang,'name'=>$l->t('__language_name__'));
}elseif(isset($languageNames[$lang])){
$languages[]=array('code'=>$lang,'name'=>$languageNames[$lang]);
}else{//fallback to language code
$languages[]=array('code'=>$lang,'name'=>$lang);
}
}
// Return template