From 380f7446e150f566a68f26dcdf57b8fcde28b0d4 Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 8 Jan 2025 16:55:12 +0300 Subject: [PATCH 1/2] taken account default langage --- .../Core/Event/Subscriber/PhraseaLocaleSubscriber.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php index b8372b6a6a..da581a4992 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php @@ -64,13 +64,6 @@ public function addLocale(GetResponseEvent $event) if ($event->getRequest()->cookies->has('locale') && isset($this->app['locales.available'][$event->getRequest()->cookies->get('locale')])) { $event->getRequest()->setLocale($event->getRequest()->cookies->get('locale')); - } else { - foreach ($event->getRequest()->getLanguages() as $code) { - $data = preg_split('/[-_]/', $code); - if (in_array($data[0], array_keys($this->app['locales.available']), true)) { - $event->getRequest()->setLocale($data[0]); - } - } } $this->locale = $this->app['locale'] = $event->getRequest()->getLocale(); From 3cc38c5af7247c7a6d9d8b355bc14a881d29ccc1 Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 8 Jan 2025 17:14:19 +0300 Subject: [PATCH 2/2] test --- .../Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php index 78a7acc97c..8d711472bb 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriberTest.php @@ -48,7 +48,7 @@ public function testWithHeaders() $client = new Client($app); $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr_FR,fr;q=0.9']); - $this->assertEquals('fr', $client->getResponse()->getContent()); + $this->assertEquals('en', $client->getResponse()->getContent()); } public function testWithHeadersUsingMinus() @@ -58,7 +58,7 @@ public function testWithHeadersUsingMinus() $client = new Client($app); $client->request('GET', '/', [], [], ['HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.9']); - $this->assertEquals('fr', $client->getResponse()->getContent()); + $this->assertEquals('en', $client->getResponse()->getContent()); } public function testCookieIsSet() @@ -75,7 +75,7 @@ public function testCookieIsSet() } $this->assertNotNull($settedCookie); - $this->assertEquals('fr', $settedCookie->getValue()); + $this->assertEquals('en', $settedCookie->getValue()); } /**