$l) { if ($al == $l['codes'][2]) { $lang = $i; break; } } } } // If no language has been worked out - or it is not supported - use the default if (empty($lang) OR !array_key_exists($lang, $config['supported_languages'])) { $lang = $config['language']; } // Whatever we decided the lang was, save it for next time to avoid working it out again $_SESSION['lang_code'] = $lang; // Load CI config class $CI_config = & load_class('Config'); // Set the language config. Selects the folder name from its key of 'en' $CI_config->set_item('language', $config['supported_languages'][$lang]['folder']); // Sets a constant to use throughout ALL of CI. define('AUTO_LANGUAGE', $lang); }