From 20240fee15c6ae9bb89f715910d7d0fca620fdb9 Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Fri, 19 Apr 2019 11:00:29 +0200 Subject: [PATCH] Fix i18n.php review comments * remove useless is_string check * use the DEFAULT_LANGUAGE when Accept-Language is invalid. --- app/inc/i18n.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/inc/i18n.php b/app/inc/i18n.php index ebcc4ec..f211a8d 100644 --- a/app/inc/i18n.php +++ b/app/inc/i18n.php @@ -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;