yab86 yab86 - 1 year ago 276
PHP Question

codeigniter change language form_validation_lang

I try to change the language file for my form_validation_lang in my LanguageLoader.php in my hooks folder like this:

class LanguageLoader
function initialize() {
$ci =& get_instance();
$siteLang = $ci->session->userdata('site_lang');
if ($siteLang) {
} else {

For my message_lang.php file it works fine, but codeigniter does not load the form_validation_lang.php correctly after changing the language.

In my application folder:


-- english






It takes always the form_validation_lang.php file under english. When I change to german it takes the correct message_lang.php file but not the form_validation_lang.php file. What I am doing wrong?

Thanks for your help!

Best regards,


Error messages for form_validation are always loaded in language you set in your config.php. To change the language for your form_validation messages, you need to do a little trick, changing the default language like this:

$ci->config->set_item('language', $siteLang);