diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-06-20 14:33:02 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-06-20 14:33:31 +0200 |
commit | 76b12c4ae0ea9941b030f0a13786d0ac3fc32f76 (patch) | |
tree | d46fff7789a676d1912fcbf65c5d94cf9b95d783 /lib/l10n.php | |
parent | a7b7f5a76ce7fe3fb371f008d5de9c749ac5c1c1 (diff) | |
download | nextcloud-server-76b12c4ae0ea9941b030f0a13786d0ac3fc32f76.tar.gz nextcloud-server-76b12c4ae0ea9941b030f0a13786d0ac3fc32f76.zip |
add settings option for language
Diffstat (limited to 'lib/l10n.php')
-rw-r--r-- | lib/l10n.php | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/l10n.php b/lib/l10n.php index f760d78c72b..729310825dd 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -198,19 +198,7 @@ class OC_L10N{ $available = $app; } else{ - $dir = self::findI18nDir( $app ); - if( file_exists($dir)){ - $dh = opendir($dir); - while(( $file = readdir( $dh )) !== false ){ - if( substr( $file, -4, 4 ) == '.php' ){ - $i = substr( $file, 0, -4 ); - if( $i != '' ){ - $available[] = $i; - } - } - } - closedir($dh); - } + $available=self::findAvailableLanguages( $app ); } if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); @@ -255,4 +243,27 @@ class OC_L10N{ } return $i18ndir; } + + /** + * @brief find all available languages for an app + * @param $app App that needs to be translated + * @returns array an array of available languages + */ + public static function findAvailableLanguages( $app=null ){ + $available=array('en');//english is always available + $dir = self::findI18nDir( $app ); + if( file_exists($dir)){ + $dh = opendir($dir); + while(( $file = readdir( $dh )) !== false ){ + if( substr( $file, -4, 4 ) == '.php' and strlen($file)==6 ){ + $i = substr( $file, 0, -4 ); + if( $i != '' ){ + $available[] = $i; + } + } + } + closedir($dh); + } + return $available; + } }
\ No newline at end of file |