Welcome Guest, Not a member yet? Register   Sign In
Multilingual System lang files

(06-15-2018, 05:08 AM)1tft Wrote: Hello,

I found the following issue in Codeigniter.

Initial situation:
I have a multilingual site and using language class of CI. Everything is working fine for own language files.

I want to translate content of (/codeigniter/system/language/english/form_validation_lang.php) and tried following: Created translated file /codeigniter/system/language/german/form_validation_lang.php
In controller I use $this->lang->load('form_validation', 'german'); for loading language file, but I still get english translation for form errors.

My workaround at the moment: Created dummy (almost empty) file /codeigniter/system/language/english/form_validation_lang.php.
Also created /codeigniter/application/language/german/system/form_validation_lang.php
 and load $this->lang->load('system/form_validation', 'german');

Does anyone know what is the right way to work with translated system lang files? Documention at https://github.com/bcit-ci/codeigniter3-translations is not helping me.


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(){

   //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(){

   $dados['titulo'] = $this->lang->line('titulo');
   $dados['subtitulo'] = $this->lang->line('subtitulo');

See that have no need to indicate the validation file with translation.

Hope it works,


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

Theme © iAndrew 2016 - Forum software by © MyBB