Fix i18n.php review comments

* remove useless is_string check
* use the DEFAULT_LANGUAGE when Accept-Language is invalid.
This commit is contained in:
Nicolas Bouilleaud 2019-04-19 11:00:29 +02:00
parent 780392bb37
commit 20240fee15

View file

@ -19,14 +19,14 @@
// Change language when requested
if (isset($_REQUEST['lang'])
&& is_string($_REQUEST['lang'])
&& in_array($_REQUEST['lang'], array_keys($ALLOWED_LANGUAGES), true)) {
$_SESSION['lang'] = $_REQUEST['lang'];
}
// Use the user-specified locale or the browser-specified locale
// Use the user-specified locale, or the browser-specified locale, or the app default.
$locale = $_SESSION['lang']
?: locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
?: locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE'])
?: DEFAULT_LANGUAGE;
/* i18n helper functions */
use Symfony\Component\Translation\Loader\PoFileLoader;