Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-4111: Default language in the configuration file not taken into account on the homepage. #4570

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading