php - CodeIgniter getting CI load the correct language file when validating forms -


this rather call testimonies real questions. appreciate feedbacks ci experts , fans.

i have been searching internet hours issue of mine: getting ci form validation class load proper language file dynamically.

let me explain. in config.php file, have:

$config['language'] = 'english'; 

which indeed default language. have implemented settings controller letting users set values , of course change default language. have stored setting session variable moment don't, load language user setting each controller within constructor :

$this->idiom = get_user_setting('language'); $this->lang->load('main', $this->idiom); $this->lang->load('settings', $this->idiom); $this->lang->load('cst', $this->idiom); 

and can see load language files need each controller appropriate language. 'get_user_setting' function helper of mine querying database particular setting id.

i have copied form_validation_lang.php /system/language/english/ directory , put /application/language/french/ directory, , thought doing following magic:

$this->lang->load('form_validation', $this->idiom); 

but nope... not change anything. took @ form validation class in core folder , saw following:

// load language file containing error messages $this->ci->lang->load('form_validation'); 

this makes me think load file of default language set in config.php file. right or wrong?

hence, way got have work user defined settings fetch database (and store in session variable), following:

$this->idiom = get_user_setting('language'); $this->config->set_item('language', $this->idiom); ... 

i appreciate feedbacks if of had cope kind of requirements , if indeed managed same way did or not. if i'm totally wrong, i'd appreciate solutions of course.

thanks lot help.

yes form_validation load default language file.if want load different language can trick or change source code of form validation class.

the trick use, change default language before using form validation(you can change after form validation complete if need.)

you can change default language code.

$this->config->set_item('language', 'your_language'); 

after code can use form validation load language set.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -