]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(rtl): Make clear that the direction is based on language feat/31420/bidi-backend-support 47349/head
authorJoas Schilling <coding@schilljs.com>
Wed, 18 Sep 2024 09:13:30 +0000 (11:13 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 23 Sep 2024 15:00:07 +0000 (17:00 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/L10N/Factory.php
lib/private/TemplateLayout.php
lib/public/L10N/IFactory.php
tests/lib/L10N/FactoryTest.php

index ea6360efdf0989d1b20a26f838a30007e910f925..a519ae7e7616bda2176db85aa957b0d894fe2130 100644 (file)
@@ -377,9 +377,8 @@ class Factory implements IFactory {
                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';
                }
 
index bca9af16d2263aa3623c370a65ba936b736d502f..60c7526435e2c7617e984ecaf5d3a1c1e8e94634 100644 (file)
@@ -196,7 +196,7 @@ class TemplateLayout extends \OC_Template {
                // 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);
index 4259baa3b2f2b4d6245b91a88a71f594a1332466..aebd318dfad2c3ad05755857896163b4e4e0d893 100644 (file)
@@ -104,13 +104,13 @@ interface IFactory {
        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:
index 510c165eba9a4c86908749301434655e1f1e99e2..c29c31bf6503a03daebf26f01a55567002b46825 100644 (file)
@@ -776,7 +776,7 @@ class FactoryTest extends TestCase {
                self::assertInstanceOf(ILanguageIterator::class, $iterator);
        }
 
-       public static function languagesWithRespectedDirection():array {
+       public static function dataGetLanguageDirection(): array {
                return [
                        ['en', 'ltr'],
                        ['de', 'ltr'],
@@ -786,11 +786,11 @@ class FactoryTest extends TestCase {
        }
 
        /**
-        * @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));
        }
 }