]> git.mxchange.org Git - friendica.git/commitdiff
fix L10n path after move
authornupplaPhil <admin@philipp.info>
Sun, 19 Jan 2020 16:11:48 +0000 (17:11 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 19 Jan 2020 16:11:48 +0000 (17:11 +0100)
src/Core/L10n.php
tests/src/Core/L10n/L10nTest.php [deleted file]
tests/src/Core/L10nTest.php [new file with mode: 0644]

index 3f92dd5800c35b857295dcb391050c69bf8a8d0b..0238af3bd169d9d5d1e29b84553d25978f3b78e1 100644 (file)
@@ -115,13 +115,13 @@ class L10n
                $addons = $this->dba->select('addon', ['name'], ['installed' => true]);
                while ($p = $this->dba->fetch($addons)) {
                        $name = Strings::sanitizeFilePathItem($p['name']);
-                       if (file_exists("addon/$name/lang/$lang/strings.php")) {
-                               include __DIR__ . "/../../../addon/$name/lang/$lang/strings.php";
+                       if (file_exists(__DIR__ . "/../../addon/$name/lang/$lang/strings.php")) {
+                               include __DIR__ . "/../../addon/$name/lang/$lang/strings.php";
                        }
                }
 
-               if (file_exists(__DIR__ . "/../../../view/lang/$lang/strings.php")) {
-                       include __DIR__ . "/../../../view/lang/$lang/strings.php";
+               if (file_exists(__DIR__ . "/../../view/lang/$lang/strings.php")) {
+                       include __DIR__ . "/../../view/lang/$lang/strings.php";
                }
 
                $this->lang    = $lang;
@@ -191,8 +191,8 @@ class L10n
                        while (count($lang_code)) {
                                // try to mix them so we can get double-code parts too
                                $match_lang = strtolower(join('-', $lang_code));
-                               if (file_exists(__DIR__ . "/../../../view/lang/$match_lang") &&
-                                   is_dir(__DIR__ . "/../../../view/lang/$match_lang")) {
+                               if (file_exists(__DIR__ . "/../../view/lang/$match_lang") &&
+                                   is_dir(__DIR__ . "/../../view/lang/$match_lang")) {
                                        if ($lang_quality > $current_q) {
                                                $current_lang = $match_lang;
                                                $current_q    = $lang_quality;
diff --git a/tests/src/Core/L10n/L10nTest.php b/tests/src/Core/L10n/L10nTest.php
deleted file mode 100644 (file)
index b9f6681..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-namespace src\Core\L10n;
-
-use Friendica\Core\L10n;
-use Friendica\Test\MockedTest;
-
-class L10nTest extends MockedTest
-{
-       public function dataDetectLanguage()
-       {
-               return [
-                       'empty'   => [
-                               'server'  => [],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'en',
-                       ],
-                       'withGet' => [
-                               'server'  => [],
-                               'get'     => ['lang' => 'de'],
-                               'default' => 'en',
-                               'assert'  => 'de',
-                       ],
-                       'withPipe' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'en-gb'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'en-gb',
-                       ],
-                       'withoutPipe' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'fr',
-                       ],
-                       'withQuality1' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'de',
-                       ],
-                       'withQuality2' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'fr',
-                       ],
-                       'withLangOverride' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
-                               'get'     => ['lang' => 'it'],
-                               'default' => 'en',
-                               'assert'  => 'it',
-                       ],
-                       'withQualityAndPipe' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2,nb-no;q=0.7'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'nb-no',
-                       ],
-                       'withQualityAndInvalid' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,bla;q=0.2,nb-no;q=0.7'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'nb-no',
-                       ],
-                       'withQualityAndInvalid2' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,bla;q=0.2,nb-no;q=0.7'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'nb-no',
-                       ],
-                       'withQualityAndInvalidAndAbsolute' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,de,nb-no;q=0.7'],
-                               'get'     => [],
-                               'default' => 'en',
-                               'assert'  => 'de',
-                       ],
-                       'withInvalidGet' => [
-                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,nb-no;q=0.7'],
-                               'get'     => ['lang' => 'blu'],
-                               'default' => 'en',
-                               'assert'  => 'nb-no',
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider dataDetectLanguage
-        */
-       public function testDetectLanguage(array $server, array $get, string $default, string $assert)
-       {
-               $this->assertEquals($assert, L10n::detectLanguage($server, $get, $default));
-       }
-}
diff --git a/tests/src/Core/L10nTest.php b/tests/src/Core/L10nTest.php
new file mode 100644 (file)
index 0000000..7d30d31
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+namespace Friendica\Test\src\Core\L10n;
+
+use Friendica\Core\L10n;
+use Friendica\Test\MockedTest;
+
+class L10nTest extends MockedTest
+{
+       public function dataDetectLanguage()
+       {
+               return [
+                       'empty'   => [
+                               'server'  => [],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'en',
+                       ],
+                       'withGet' => [
+                               'server'  => [],
+                               'get'     => ['lang' => 'de'],
+                               'default' => 'en',
+                               'assert'  => 'de',
+                       ],
+                       'withPipe' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'en-gb'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'en-gb',
+                       ],
+                       'withoutPipe' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'fr',
+                       ],
+                       'withQuality1' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'de',
+                       ],
+                       'withQuality2' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'fr',
+                       ],
+                       'withLangOverride' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2'],
+                               'get'     => ['lang' => 'it'],
+                               'default' => 'en',
+                               'assert'  => 'it',
+                       ],
+                       'withQualityAndPipe' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,de;q=0.2,nb-no;q=0.7'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'nb-no',
+                       ],
+                       'withQualityAndInvalid' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'fr;q=0.5,bla;q=0.2,nb-no;q=0.7'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'nb-no',
+                       ],
+                       'withQualityAndInvalid2' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,bla;q=0.2,nb-no;q=0.7'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'nb-no',
+                       ],
+                       'withQualityAndInvalidAndAbsolute' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,de,nb-no;q=0.7'],
+                               'get'     => [],
+                               'default' => 'en',
+                               'assert'  => 'de',
+                       ],
+                       'withInvalidGet' => [
+                               'server'  => ['HTTP_ACCEPT_LANGUAGE' => 'blu;q=0.9,nb-no;q=0.7'],
+                               'get'     => ['lang' => 'blu'],
+                               'default' => 'en',
+                               'assert'  => 'nb-no',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider dataDetectLanguage
+        */
+       public function testDetectLanguage(array $server, array $get, string $default, string $assert)
+       {
+               $this->assertEquals($assert, L10n::detectLanguage($server, $get, $default));
+       }
+}