aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-27 13:14:50 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-27 13:14:50 +0200
commitc3c7689b6743e5d36a6d46730a53b058499ca97a (patch)
tree4112b118b1d3df4e88a79bbd2572339b0062cf78 /lib/private
parent27af0e82ddba29512a4a5fe08cbd060cc6251264 (diff)
downloadnextcloud-server-c3c7689b6743e5d36a6d46730a53b058499ca97a.tar.gz
nextcloud-server-c3c7689b6743e5d36a6d46730a53b058499ca97a.zip
Add a public interface for the language factory so apps can use it
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/l10n/factory.php24
-rw-r--r--lib/private/server.php9
2 files changed, 23 insertions, 10 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];
}
}
diff --git a/lib/private/server.php b/lib/private/server.php
index 287b70eb806..a47fa2e43f9 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -674,6 +674,13 @@ class Server extends SimpleContainer implements IServerContainer {
}
/**
+ * @return \OCP\L10N\IFactory
+ */
+ public function getL10NFactory() {
+ return $this->query('L10NFactory');
+ }
+
+ /**
* get an L10N instance
*
* @param string $app appid
@@ -681,7 +688,7 @@ class Server extends SimpleContainer implements IServerContainer {
* @return \OC_L10N
*/
public function getL10N($app, $lang = null) {
- return $this->query('L10NFactory')->get($app, $lang);
+ return $this->getL10NFactory()->get($app, $lang);
}
/**