diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-16 20:52:01 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-16 20:52:10 +0200 |
commit | 6f93176a4be21dcda1009d9cea052e5fdb50ae16 (patch) | |
tree | 91d694ed3060d9c36f7572160b8d442a256bff61 /lib/l10n.php | |
parent | 6e9cd63fa1af24781c981c5535876f22fdb17934 (diff) | |
download | nextcloud-server-6f93176a4be21dcda1009d9cea052e5fdb50ae16.tar.gz nextcloud-server-6f93176a4be21dcda1009d9cea052e5fdb50ae16.zip |
Be smarter when checking single app language availability
Diffstat (limited to 'lib/l10n.php')
-rw-r--r-- | lib/l10n.php | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/lib/l10n.php b/lib/l10n.php index 3596c992bae..ba4bf23780e 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -228,23 +228,29 @@ class OC_L10N{ return self::$language; } - $available = array(); - if(is_array($app)){ - $available = $app; - } - else{ - $available=self::findAvailableLanguages($app); - } if(OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')){ $lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang'); self::$language = $lang; - if(array_search($lang, $available) !== false){ + if(is_array($app)){ + $available = $app; + $lang_exists = array_search($lang, $available) !== false; + } + else { + $lang_exists = self::languageExists($app, $lang); + } + if($lang_exists){ return $lang; } } if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ $accepted_languages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + if(is_array($app)){ + $available = $app; + } + else{ + $available = self::findAvailableLanguages($app); + } foreach($accepted_languages as $i){ $temp = explode(';', $i); if(array_search($temp[0], $available) !== false){ @@ -296,4 +302,15 @@ class OC_L10N{ } return $available; } + + public static function languageExists($app, $lang){ + if ($lang == 'en'){//english is always available + return true; + } + $dir = self::findI18nDir($app); + if(is_dir($dir)){ + return file_exists($dir.'/'.$lang.'.php'); + } + return false; + } } |