Multilingual System lang files |
(06-15-2018, 05:08 AM)1tft Wrote: Hello, Hi, I have used the following to translate the system messages and validations in codeigniter: In my case I wanted to add 'portuguese-br', but doesn't matter the language: 1) Do not change anything inside the System folder. It will make thigs harder when update codeigniter. 2) I create the file application/language/portuguese-br/form_validation_lang.php with my translation. 3) I introduced in the controller function __construct the following code (this is the main thing): public function __construct(){ parent::__construct(); //Adjust internal codeigniter language $this->idiom = $this->session->userdata('language'); $ci =& get_instance(); $ci->config->set_item('language', $this->idiom); } Note: I use the session variable 'language' = 'portuguese-br' to define the current language. 4) In the function that renders the page I load the language file that I need on the page, not needed to mention the validation file created... in my case: public function pag_registration(){ $this->lang->load('registration','portuguese-br'); $dados['titulo'] = $this->lang->line('titulo'); $dados['subtitulo'] = $this->lang->line('subtitulo'); //Pagina $this->load->view('registration'); } See that have no need to indicate the validation file with translation. Hope it works, Eduardo |
Messages In This Thread |
Multilingual System lang files - by 1tft - 06-15-2018, 05:08 AM
RE: Multilingual System lang files - by Eduardo Faria - 06-15-2018, 07:13 AM
RE: Multilingual System lang files - by 1tft - 06-15-2018, 08:20 AM
|