diff options
Diffstat (limited to 'lib/private/l10n/factory.php')
-rw-r--r-- | lib/private/l10n/factory.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php index 4424d014f47..a9ac4da42a2 100644 --- a/lib/private/l10n/factory.php +++ b/lib/private/l10n/factory.php @@ -25,29 +25,35 @@ namespace OC\L10N; +use OCP\L10N\IFactory; + /** - * TODO: Description + * A factory that generates language instances */ -class Factory { +class Factory implements IFactory { /** * cached instances */ protected $instances = array(); /** - * get an L10N instance + * Get a language instance * * @param string $app * @param string|null $lang - * @return \OC_L10N + * @return \OCP\IL10N */ public function get($app, $lang = null) { - if (!is_null($lang)) { - return new \OC_L10N($app, $lang); - } else if (!isset($this->instances[$app])) { - $this->instances[$app] = new \OC_L10N($app); + $key = $lang; + if ($key === null) { + $key = 'null'; + } + + if (!isset($this->instances[$key][$app])) { + $this->instances[$key][$app] = new \OC_L10N($app, $lang); } - return $this->instances[$app]; + + return $this->instances[$key][$app]; } } |