CodeIgniter Forums
config language and the i18n-wiki tutorial - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: config language and the i18n-wiki tutorial (/showthread.php?tid=2733)



config language and the i18n-wiki tutorial - El Forum - 08-21-2007

[eluser]tobben[/eluser]
Concerning the Wiki-post:
i18n-wiki post

Anyone figured out a way to swap language settings in the config file, depending on the language set in the i18n script?

So, if I swap language to "no" (norwegian), the language set is also switched - so I could get me some nice norwegian day names on ex. the calendar.


Sincerly yours,

tobben Tongue


config language and the i18n-wiki tutorial - El Forum - 08-22-2007

[eluser]tobben[/eluser]
Update:

I added this to the controller construct:



Code:
if($this->uri->segment(1) == 'no')
            {    
                $this->config->set_item('language', 'norwegian');
            }
            else
            {    
                $this->config->set_item('language', 'english');
            }



So if the URI is:

http://localhost:8888/en/kalender/dato/2007/12 - show english language files
http://localhost:8888/no/kalender/dato/2007/12 - show norwegian language files





It works, but its probably a lame way to change this system language.


Suggestions to make it work globaly on all scripts?


config language and the i18n-wiki tutorial - El Forum - 08-22-2007

[eluser]Michael Wales[/eluser]
Documentation: Hooks


config language and the i18n-wiki tutorial - El Forum - 08-22-2007

[eluser]Rick Jolly[/eluser]
As an alternative to hooks, you could put it in the constructor of a custom parent controller and extend it. You might find the parent controller handy for other things as well.


config language and the i18n-wiki tutorial - El Forum - 08-22-2007

[eluser]wemago[/eluser]
you should see how language is set at the mini application
by Peccavio. They did a really good job.