summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-01-15 10:27:09 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2016-01-26 14:02:31 +0100
commit29a93064299f57584c6aadc8a6c56b51715d7269 (patch)
tree43128bacac2f784549d54a6e418eb63e58b12f84 /lib
parent6aec550d6efb1cb50f6404bf72eb78ea37f36266 (diff)
downloadnextcloud-server-29a93064299f57584c6aadc8a6c56b51715d7269.tar.gz
nextcloud-server-29a93064299f57584c6aadc8a6c56b51715d7269.zip
Move languageExists() to the factory
Diffstat (limited to 'lib')
-rw-r--r--lib/private/l10n.php10
-rw-r--r--lib/private/l10n/factory.php17
-rw-r--r--lib/public/l10n/ifactory.php8
3 files changed, 27 insertions, 8 deletions
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index aa19102b70c..085914a68b6 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -462,16 +462,10 @@ class OC_L10N implements \OCP\IL10N {
* @param string $app
* @param string $lang
* @return bool
+ * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->languageExists() instead
*/
public static function languageExists($app, $lang) {
- if ($lang === 'en') {//english is always available
- return true;
- }
- $dir = self::findI18nDir($app);
- if(is_dir($dir)) {
- return file_exists($dir.'/'.$lang.'.json');
- }
- return false;
+ return \OC::$server->getL10NFactory()->languageExists($app, $lang);
}
/**
diff --git a/lib/private/l10n/factory.php b/lib/private/l10n/factory.php
index aaa41f5e645..b1304727606 100644
--- a/lib/private/l10n/factory.php
+++ b/lib/private/l10n/factory.php
@@ -37,6 +37,9 @@ class Factory implements IFactory {
*/
protected $instances = [];
+ /**
+ * @var array Structure: App => string[]
+ */
protected $availableLanguages = [];
/**
@@ -94,6 +97,20 @@ class Factory implements IFactory {
}
/**
+ * @param string|null $app App id or null for core
+ * @param string $lang
+ * @return bool
+ */
+ public function languageExists($app, $lang) {
+ if ($lang === 'en') {//english is always available
+ return true;
+ }
+
+ $languages = $this->findAvailableLanguages($app);
+ return array_search($lang, $languages);
+ }
+
+ /**
* find the l10n directory
*
* @param string $app App id or empty string for core
diff --git a/lib/public/l10n/ifactory.php b/lib/public/l10n/ifactory.php
index d6944b375f0..09c75e9af7d 100644
--- a/lib/public/l10n/ifactory.php
+++ b/lib/public/l10n/ifactory.php
@@ -42,4 +42,12 @@ interface IFactory {
* @since 9.0.0
*/
public function findAvailableLanguages($app = null);
+
+ /**
+ * @param string|null $app App id or null for core
+ * @param string $lang
+ * @return bool
+ * @since 9.0.0
+ */
+ public function languageExists($app, $lang);
}