Welcome Guest, Not a member yet? Register   Sign In
Change language in config.php dynamic [RESOLVED]
#1

[eluser]ELRafael[/eluser]
How do i do this??

In the constructor of the controller
Code:
$this->config->set_item('language', 'pt-br');

But didn't work... any ideas? (Read better the user_guide)
#2

[eluser]Derek Allard[/eluser]
what is your language folder called and where is it saved?
#3

[eluser]Unknown[/eluser]
Hello

I have the same problem. I created 3 folders (de, en and fr) in system/language/
When I autoload 1 of the three folders there is no problem. But when i want to change then the language he don't react on my changes.

I try to change the language (in the views) with this code:
Code:
$this->lang->load('site', $headinfo['accountinfo']['language']);
In $headinfo['accountinfo']['language'] is the userlanguage stored (de, en or fr)

My config folder:
Code:
$config['language']    = "de";

It would be great if someone could help me! Thanks!
#4

[eluser]xwero[/eluser]
@Rafael : have you got an /language/pt-br directory? if it's easier for you just name it brasilian Smile

@flicker : you have to change the language configuration setting
Code:
$this->config->set_item('language', $headinfo['accountinfo']['language']);
This should work
#5

[eluser]ELRafael[/eluser]
i have the folder called pt-br

i tried in
system/language/pt-br and system/application/language/pt-br, but both didn't work.

whats the diferrence of brazilian and pt-br? i know that brazil is the only country that speaks "another" kind of portuguese, but don't matter if is pt-br, brazilian, brazuca, mixugues, or otherelse the name of folder-se!

if i changed "manual" the value from config.php, it works soo fine that i almost cry. but dynamic neither Daileon can resolved!!!!
#6

[eluser]xwero[/eluser]
and where or how do you want to use the string?

I don't know when you make custom files you can depend on the autoloading to load the file, probably you would have to do something like
Code:
$this->lang->load('custom_file_lang');
$this->lang->line('showstring');

It doesn't matter if you call it pt-br or brazilian, it's where you feel most comfortable with.
#7

[eluser]ELRafael[/eluser]
allright, but the problem is:

i have the string inside the config.php (the main config file). i didn't create a custom config file, or my own file. just changed the original, the main, the genesis one!

system/application/config/config.php. So i think that i don't need to load this, right?

In fact, what i wish is:

The user clicks in link that changes the language of site. And all the language strings are inside another file.

As flicker (the dolphin?) told, the system doesn't react when i wanna change the $config['language'] in runtime.
#8

[eluser]xwero[/eluser]
I meant by custom files, custom language files.
When the configured language is changed for instance the validation errors show the correct language strings.

I haven't used custom language files myself because it seems that with language change comes page changes too so i set up separate view directories.
#9

[eluser]ELRafael[/eluser]
i didn't put in different views folders....

just did that:

application/views/hello_view.php
Code:
<h1>&lt;?=$this->lang->line('hello_title');?&gt;</h1>

<p>&lt;?=$this->lang->line('hello_text');?&gt;</p>

application/language/pt-br/app_lang.php
Code:
$lang['hello_title'] = 'Olá Mundo';
$lang['hello_title'] = 'Esta é uma aplicação padrão, só pra teste';

application/language/en/app_lang.php
Code:
$lang['hello_title'] = 'Hello World';
$lang['hello_title'] = 'Just testing application, don t worry!';

and this is working... but change dynamic don't >Sad
#10

[eluser]xwero[/eluser]
That is strange. I looked at the validation class and they use
Code:
$this->CI->lang->load('validation');
to load their language file so i guess you will have to reload your file in your controller after changing the language.
Code:
$this->lang->load('app');




Theme © iAndrew 2016 - Forum software by © MyBB