summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-03-03 18:33:08 +0100
committerJoas Schilling <nickvergessen@gmx.de>2015-03-03 18:33:08 +0100
commite12c83e3dc85d80d6271e05395b3e55e98b3a2b0 (patch)
tree3dc779ab16a296fea6c5eff1aea90f7a603a0c0e
parent1761b162e65e24ade7c9db1d96341a49e29f653f (diff)
parentb669bf26d6774706a61242d67fbfe24f05eb1760 (diff)
downloadnextcloud-server-e12c83e3dc85d80d6271e05395b3e55e98b3a2b0.tar.gz
nextcloud-server-e12c83e3dc85d80d6271e05395b3e55e98b3a2b0.zip
Merge pull request #14674 from owncloud/fix-l10n-getlanguagecode-2
Jenkins #14650
-rw-r--r--lib/private/l10n.php19
-rw-r--r--lib/private/util.php3
-rw-r--r--lib/public/il10n.php12
-rw-r--r--tests/lib/l10n.php16
4 files changed, 25 insertions, 25 deletions
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index 6c66bee3e79..4e9316c333e 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -358,24 +358,15 @@ class OC_L10N implements \OCP\IL10N {
self::$language = $lang;
}
-
/**
- * find the best language
- *
- * @param array|string $app details below
- *
- * If $app is an array, ownCloud assumes that these are the available
- * languages. Otherwise ownCloud tries to find the files in the l10n
- * folder.
+ * The code (en, de, ...) of the language that is used for this OC_L10N object
*
- * If nothing works it returns 'en'
* @return string language
*/
- public function getLanguageCode($app=null) {
- return self::findLanguage($app);
+ public function getLanguageCode() {
+ return $this->lang ? $this->lang : self::findLanguage();
}
-
/**
* find the best language
* @param array|string $app details below
@@ -515,7 +506,7 @@ class OC_L10N implements \OCP\IL10N {
* @throws \Punic\Exception\ValueNotInList
*/
public function getDateFormat() {
- $locale = self::findLanguage();
+ $locale = $this->getLanguageCode();
return Punic\Calendar::getDateFormat('short', $locale);
}
@@ -523,7 +514,7 @@ class OC_L10N implements \OCP\IL10N {
* @return int
*/
public function getFirstWeekDay() {
- $locale = self::findLanguage();
+ $locale = $this->getLanguageCode();
return Punic\Calendar::getFirstWeekday($locale);
}
}
diff --git a/lib/private/util.php b/lib/private/util.php
index 3a0d7f653ed..4c60af88189 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -396,8 +396,7 @@ class OC_Util {
*/
public static function addTranslations($application, $languageCode = null) {
if (is_null($languageCode)) {
- $l = new \OC_L10N($application);
- $languageCode = $l->getLanguageCode($application);
+ $languageCode = \OC_L10N::findLanguage($application);
}
if (!empty($application)) {
$path = "$application/l10n/$languageCode";
diff --git a/lib/public/il10n.php b/lib/public/il10n.php
index 2c95ddfec18..c63c18209e4 100644
--- a/lib/public/il10n.php
+++ b/lib/public/il10n.php
@@ -75,15 +75,9 @@ interface IL10N {
/**
- * find the best language
- * @param array|string $app details below
- * @return string language
- *
- * If $app is an array, ownCloud assumes that these are the available
- * languages. Otherwise ownCloud tries to find the files in the l10n
- * folder.
+ * The code (en, de, ...) of the language that is used for this OC_L10N object
*
- * If nothing works it returns 'en'
+ * @return string language
*/
- public function getLanguageCode($app=null);
+ public function getLanguageCode();
}
diff --git a/tests/lib/l10n.php b/tests/lib/l10n.php
index 2235581add8..0307dd459e5 100644
--- a/tests/lib/l10n.php
+++ b/tests/lib/l10n.php
@@ -173,4 +173,20 @@ class Test_L10n extends \Test\TestCase {
array(null, null, 'en'),
);
}
+
+ public function testGetLanguageCode() {
+ $l = OC_L10N::get('lib', 'de');
+ $this->assertEquals('de', $l->getLanguageCode());
+ }
+
+ public function testFactoryGetLanguageCode() {
+ $factory = new \OC\L10N\Factory();
+ $l = $factory->get('lib', 'de');
+ $this->assertEquals('de', $l->getLanguageCode());
+ }
+
+ public function testServiceGetLanguageCode() {
+ $l = \OC::$server->getL10N('lib', 'de');
+ $this->assertEquals('de', $l->getLanguageCode());
+ }
}