From 3c4ecb28735106eaa8ee782e1e0c9123b7552ce5 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 27 Mar 2020 11:00:54 +0100 Subject: [PATCH] Corrected issue with language resolving on an API request. --- application/config/config.php | 57 +++++++++++++++-------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 2c368b84..1b8369de 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -82,38 +82,31 @@ $config['url_suffix'] = ''; | */ -$config['language'] = (null !== $_SERVER['HTTP_ACCEPT_LANGUAGE'] - ? - array( - 'ar' => 'arabic', - 'bu' => 'bulgarian', - 'zh' => 'chinese', - 'da' => 'danish', - 'nl' => 'dutch', - 'en' => 'english', - 'fi' => 'finnish', - 'fr' => 'french', - 'de' => 'german', - 'el' => 'greek', - 'hi' => 'hindi', - 'hu' => 'hungarian', - 'it' => 'italian', - 'ja' => 'japanese', - 'pl' => 'polish', - 'pt' => 'portuguese', - 'pt' => 'portuguese', - 'ro' => 'romanian', - 'ru' => 'russian', - 'sk' => 'slovak', - 'es' => 'spanish', - 'tr' => 'turkish' - )[substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)] - : - (defined('Config::LANGUAGE') - ? Config::LANGUAGE - : 'english' - ) - ); +$config['language'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? + [ + 'ar' => 'arabic', + 'bu' => 'bulgarian', + 'zh' => 'chinese', + 'da' => 'danish', + 'nl' => 'dutch', + 'en' => 'english', + 'fi' => 'finnish', + 'fr' => 'french', + 'de' => 'german', + 'el' => 'greek', + 'hi' => 'hindi', + 'hu' => 'hungarian', + 'it' => 'italian', + 'ja' => 'japanese', + 'pl' => 'polish', + 'pt' => 'portuguese', + 'ro' => 'romanian', + 'ru' => 'russian', + 'sk' => 'slovak', + 'es' => 'spanish', + 'tr' => 'turkish' + ][substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)] + : Config::LANGUAGE; /* |--------------------------------------------------------------------------