Commit b7deec6e authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

WIP: change default lang to FR if no Accept-Language header

WIP:
- 8 unit tests fails
- 3 acceptance tests fails
parent f017dfba
Pipeline #18700 failed with stage
in 4 minutes and 57 seconds
......@@ -212,8 +212,12 @@ class AppController extends Controller
protected function setLocale()
{
if ($this->request->param('language')) {
// at the beginning of the URL: /fr/ or /en/
$lang = $this->request->param('language');
} else {
} elseif (is_null($this->request->header('Accept-Language'))) {
// no HTTP 'Accept-Language' header
$lang = 'fr';
} else { // Let CakePHP handle the retrieval of the HTTP 'Accept-Language' header
$lang = preg_replace('/_\w*/', "", I18n::locale());
}
......@@ -221,7 +225,7 @@ class AppController extends Controller
I18n::locale($lang);
$selectedLanguage = $this->availableLanguages[$lang];
} else {
I18n::locale('en');
I18n::locale('en'); // Default case if the desired language does not exist in the application
$selectedLanguage = I18n::locale();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment