From a9798bf27ee75731bbdab52cb8ffaa5d7389576a Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 3 Jul 2023 10:27:23 +0200 Subject: [PATCH] Set the correct HTML language code --- application/config/config.php | 4 ++++ application/core/EA_Controller.php | 7 ++++++- application/views/layouts/account_layout.php | 2 +- application/views/layouts/backend_layout.php | 2 +- application/views/layouts/booking_layout.php | 2 +- application/views/layouts/message_layout.php | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index f41240a4..27f20003 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -115,12 +115,16 @@ $languages = [ 'tr' => 'turkish', ]; +$config['language_codes'] = $languages; + $language_code = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : 'en'; $config['language'] = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'], $languages[$language_code]) ? $languages[$language_code] : Config::LANGUAGE; +$config['language_code'] = array_search($config['language'], $languages) ?: 'en'; + /* |-------------------------------------------------------------------------- | Available Languages diff --git a/application/core/EA_Controller.php b/application/core/EA_Controller.php index ff4e5cce..e836d46f 100644 --- a/application/core/EA_Controller.php +++ b/application/core/EA_Controller.php @@ -97,7 +97,12 @@ class EA_Controller extends CI_Controller { if ($session_language) { - config(['language' => $session_language]); + $language_codes = config('language_codes'); + + config([ + 'language' => $session_language, + 'language_code' => array_search($session_language, $language_codes) ?: 'en' + ]); } $this->lang->load('translations'); diff --git a/application/views/layouts/account_layout.php b/application/views/layouts/account_layout.php index 38ea729f..7a3d5aaf 100644 --- a/application/views/layouts/account_layout.php +++ b/application/views/layouts/account_layout.php @@ -1,5 +1,5 @@ - + diff --git a/application/views/layouts/backend_layout.php b/application/views/layouts/backend_layout.php index 4b69ee2f..fcaae375 100644 --- a/application/views/layouts/backend_layout.php +++ b/application/views/layouts/backend_layout.php @@ -1,5 +1,5 @@ - + diff --git a/application/views/layouts/booking_layout.php b/application/views/layouts/booking_layout.php index fc19f653..25051685 100644 --- a/application/views/layouts/booking_layout.php +++ b/application/views/layouts/booking_layout.php @@ -1,5 +1,5 @@ - + diff --git a/application/views/layouts/message_layout.php b/application/views/layouts/message_layout.php index 899bf111..2106503d 100644 --- a/application/views/layouts/message_layout.php +++ b/application/views/layouts/message_layout.php @@ -1,5 +1,5 @@ - +