Skip to content

Commit

Permalink
PHRAS-4111: Default language in the configuration file not taken into…
Browse files Browse the repository at this point in the history
… account on the homepage. (#4570)

* taken account default langage

* test
  • Loading branch information
aynsix authored Jan 8, 2025
1 parent 13fc43a commit c26da21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -75,7 +75,7 @@ public function testCookieIsSet()
}

$this->assertNotNull($settedCookie);
$this->assertEquals('fr', $settedCookie->getValue());
$this->assertEquals('en', $settedCookie->getValue());
}

/**
Expand Down

0 comments on commit c26da21

Please sign in to comment.