Merge pull request #14674 from owncloud/fix-l10n-getlanguagecode-2
Jenkins #14650
This commit is contained in:
commit
e12c83e3dc
|
@ -358,24 +358,15 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
self::$language = $lang;
|
self::$language = $lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the best language
|
* The code (en, de, ...) of the language that is used for this OC_L10N object
|
||||||
*
|
*
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* If nothing works it returns 'en'
|
|
||||||
* @return string language
|
* @return string language
|
||||||
*/
|
*/
|
||||||
public function getLanguageCode($app=null) {
|
public function getLanguageCode() {
|
||||||
return self::findLanguage($app);
|
return $this->lang ? $this->lang : self::findLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the best language
|
* find the best language
|
||||||
* @param array|string $app details below
|
* @param array|string $app details below
|
||||||
|
@ -515,7 +506,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
* @throws \Punic\Exception\ValueNotInList
|
* @throws \Punic\Exception\ValueNotInList
|
||||||
*/
|
*/
|
||||||
public function getDateFormat() {
|
public function getDateFormat() {
|
||||||
$locale = self::findLanguage();
|
$locale = $this->getLanguageCode();
|
||||||
return Punic\Calendar::getDateFormat('short', $locale);
|
return Punic\Calendar::getDateFormat('short', $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +514,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getFirstWeekDay() {
|
public function getFirstWeekDay() {
|
||||||
$locale = self::findLanguage();
|
$locale = $this->getLanguageCode();
|
||||||
return Punic\Calendar::getFirstWeekday($locale);
|
return Punic\Calendar::getFirstWeekday($locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,8 +396,7 @@ class OC_Util {
|
||||||
*/
|
*/
|
||||||
public static function addTranslations($application, $languageCode = null) {
|
public static function addTranslations($application, $languageCode = null) {
|
||||||
if (is_null($languageCode)) {
|
if (is_null($languageCode)) {
|
||||||
$l = new \OC_L10N($application);
|
$languageCode = \OC_L10N::findLanguage($application);
|
||||||
$languageCode = $l->getLanguageCode($application);
|
|
||||||
}
|
}
|
||||||
if (!empty($application)) {
|
if (!empty($application)) {
|
||||||
$path = "$application/l10n/$languageCode";
|
$path = "$application/l10n/$languageCode";
|
||||||
|
|
|
@ -75,15 +75,9 @@ interface IL10N {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the best language
|
* The code (en, de, ...) of the language that is used for this OC_L10N object
|
||||||
* @param array|string $app details below
|
*
|
||||||
* @return string language
|
* @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.
|
|
||||||
*
|
|
||||||
* If nothing works it returns 'en'
|
|
||||||
*/
|
*/
|
||||||
public function getLanguageCode($app=null);
|
public function getLanguageCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,4 +173,20 @@ class Test_L10n extends \Test\TestCase {
|
||||||
array(null, null, 'en'),
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue