From 76b12c4ae0ea9941b030f0a13786d0ac3fc32f76 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jun 2011 14:33:02 +0200 Subject: add settings option for language --- lib/l10n.php | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'lib/l10n.php') 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 -- cgit v1.2.3