diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 21:34:15 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 21:34:15 +0100 |
commit | d2f34183a6c479aa4724598234a3dfcd3ed0eb1e (patch) | |
tree | cbe4b4c1f4fb0ccd0a6440f41f0743dd3961d9d4 /settings/personal.php | |
parent | a63f5ffa7582af4d3b285ab752e2c35b2ea00df9 (diff) | |
download | nextcloud-server-d2f34183a6c479aa4724598234a3dfcd3ed0eb1e.tar.gz nextcloud-server-d2f34183a6c479aa4724598234a3dfcd3ed0eb1e.zip |
sort languages based on display name not the iso code
Diffstat (limited to 'settings/personal.php')
-rw-r--r-- | settings/personal.php | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/settings/personal.php b/settings/personal.php index c2df8db1ccc..9bbc66c9b7f 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -19,26 +19,36 @@ $storageInfo=OC_Helper::getStorageInfo(); $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', ''); -$lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() ); +$userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() ); $languageCodes=OC_L10N::findAvailableLanguages(); -sort ($languageCodes); - -//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) { $l=OC_L10N::get('settings', $lang); if(substr($l->t('__language_name__'), 0, 1)!='_') {//first check if the language name is in the translation file - $languages[]=array('code'=>$lang, 'name'=>$l->t('__language_name__')); + $ln=array('code'=>$lang, 'name'=> (string)$l->t('__language_name__')); }elseif(isset($languageNames[$lang])) { - $languages[]=array('code'=>$lang, 'name'=>$languageNames[$lang]); + $ln=array('code'=>$lang, 'name'=>$languageNames[$lang]); }else{//fallback to language code - $languages[]=array('code'=>$lang, 'name'=>$lang); + $ln=array('code'=>$lang, 'name'=>$lang); + } + + if ($lang === $userLang) { + $userLang = $ln; + } else { + $languages[]=$ln; } } + +// sort now by displayed language not the iso-code +usort( $languages, function ($a, $b) { + return strcmp($a['name'], $b['name']); +}); + +//put the current language in the front +array_unshift($languages, $userLang); + //links to clients $clients = array( 'desktop' => OC_Config::getValue('customclient_desktop', 'http://owncloud.org/sync-clients/'), |