diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-15 12:43:07 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-15 12:43:07 +0200 |
commit | e292b1fcdbe15d3a048c89f1825cb9ae8831edbb (patch) | |
tree | a310b840389eff1f324b68c3ed3a002b0bb963e7 /lib/l10n.php | |
parent | e256ac8791eedcb3dcab1ade0927f1831e24d2e2 (diff) | |
parent | a6a8e2c553bd2ba82c3d50f147a49793ed62b6f5 (diff) | |
download | nextcloud-server-e292b1fcdbe15d3a048c89f1825cb9ae8831edbb.tar.gz nextcloud-server-e292b1fcdbe15d3a048c89f1825cb9ae8831edbb.zip |
fix merge conflicts
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 636326f9864..c0ecdbd1b70 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -25,6 +25,11 @@ */ class OC_L10N{ /** + * cached instances + */ + protected static $instances=array(); + + /** * cache */ protected static $cache = array(); @@ -46,6 +51,21 @@ class OC_L10N{ 'date' => 'd.m.Y', 'datetime' => 'd.m.Y H:i:s', 'time' => 'H:i:s'); + + /** + * get an L10N instance + * @return OC_L10N + */ + public static function get($app,$lang=null){ + if(is_null($lang)){ + if(!isset(self::$instances[$app])){ + self::$instances[$app]=new OC_L10N($app); + } + return self::$instances[$app]; + }else{ + return new OC_L10N($app,$lang); + } + } /** * @brief The constructor @@ -261,17 +281,14 @@ class OC_L10N{ 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 || strlen($file) == 9)){ + if(is_dir($dir)){ + $files=scandir($dir); + foreach($files as $file){ + if(substr($file, -4, 4) == '.php'){ $i = substr($file, 0, -4); - if($i != ''){ - $available[] = $i; - } + $available[] = $i; } } - closedir($dh); } return $available; } |