From 2cc58ad5465230520ca04ac08d4d4852e3bf53b9 Mon Sep 17 00:00:00 2001 From: jekkos Date: Sun, 23 Sep 2018 02:01:39 +0200 Subject: [PATCH] Fix language fallback (#2148) --- application/hooks/load_config.php | 23 ++++++++----------- .../migrations/sqlscripts/3.0.2_to_3.1.1.sql | 2 -- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/application/hooks/load_config.php b/application/hooks/load_config.php index 972c42625..15b79fce0 100644 --- a/application/hooks/load_config.php +++ b/application/hooks/load_config.php @@ -11,21 +11,18 @@ function load_config() { $CI->config->set_item($CI->security->xss_clean($app_config->key), $CI->security->xss_clean($app_config->value)); } - - //Loads all the language files from the language directory - if(!empty(current_language())) - { - // fallback to English if language folder does not exist - if(!file_exists('../application/language/' . current_language_code())) - { - $CI->config->set_item('language', 'english'); - $CI->config->set_item('language_code', 'en-US'); - } - _load_language_files($CI, '../vendor/codeigniter/framework/system/language', current_language()); - _load_language_files($CI, '../application/language', current_language_code()); + // fallback to English if language settings are not correct + $file_exists = !file_exists('../application/language/' . current_language_code()); + if(current_language_code() == null || current_language() == null || $file_exists) + { + $CI->config->set_item('language', 'english'); + $CI->config->set_item('language_code', 'en-US'); } - + + _load_language_files($CI, '../vendor/codeigniter/framework/system/language', current_language()); + _load_language_files($CI, '../application/language', current_language_code()); + //Set timezone from config database if($CI->config->item('timezone')) { diff --git a/application/migrations/sqlscripts/3.0.2_to_3.1.1.sql b/application/migrations/sqlscripts/3.0.2_to_3.1.1.sql index e366e071e..ea2f721a0 100644 --- a/application/migrations/sqlscripts/3.0.2_to_3.1.1.sql +++ b/application/migrations/sqlscripts/3.0.2_to_3.1.1.sql @@ -417,5 +417,3 @@ ALTER TABLE ospos_items UPDATE `ospos_app_config` SET `value` = 'en-US' WHERE `key` = 'language_code' AND `value` = 'en'; --- Delete any configured specific locale as folders were moved in this version -DELETE FROM `ospos_app_config` WHERE `key` = 'language_code' and `value` LIKE '%_%';