return in_array($lang, $languages);
}
-
- public function getLanguageDirectionFromLocale(string $locale): string {
- if (in_array($locale, self::RTL_LANGUAGES)) {
+ public function getLanguageDirection(string $language): string {
+ if (in_array($language, self::RTL_LANGUAGES, true)) {
return 'rtl';
}
// Send the language, locale, and direction to our layouts
$lang = \OC::$server->get(IFactory::class)->findLanguage();
$locale = \OC::$server->get(IFactory::class)->findLocale($lang);
- $direction = \OC::$server->getL10NFactory()->getLanguageDirectionFromLocale($locale);
+ $direction = \OC::$server->getL10NFactory()->getLanguageDirection($lang);
$lang = str_replace('_', '-', $lang);
$this->assign('language', $lang);
public function localeExists($locale);
/**
- * Return the current language direction from locale
+ * Return the language direction
*
- * @param string $locale
+ * @param string $language
* @return 'ltr'|'rtl'
* @since 31.0.0
*/
- public function getLanguageDirectionFromLocale(string $locale): string;
+ public function getLanguageDirection(string $language): string;
/**
* iterate through language settings (if provided) in this order:
self::assertInstanceOf(ILanguageIterator::class, $iterator);
}
- public static function languagesWithRespectedDirection():array {
+ public static function dataGetLanguageDirection(): array {
return [
['en', 'ltr'],
['de', 'ltr'],
}
/**
- * @dataProvider languagesWithRespectedDirection
+ * @dataProvider dataGetLanguageDirection
*/
- public function testDirectionOfLocales(string $locale, string $expectedDirection) {
+ public function testGetLanguageDirection(string $language, string $expectedDirection) {
$factory = $this->getFactory();
- self::assertEquals($expectedDirection, $factory->getLanguageDirectionFromLocale($locale));
+ self::assertEquals($expectedDirection, $factory->getLanguageDirection($language));
}
}