Changing language

#1
[eluser]WoolyG[/eluser]
Hi all,

If I have 2 languages - say, english and spanish, and relevent language files set with equivalent listings for each line, how would I easily flick between the two languages?

I'm thinking a jump menu that changes a session setting relating to the language that the viewer would like to see the site in, but how would I load the language in question for the person viewing the site, using the session variable?

All info appreciated.
WoolyG

#2
[eluser]Akinzekeel[/eluser]
I used to load the language in a pre_controller hook.

In this hook I first check if there is a language set in $this->CI->session->userdata. Depending on this, I either load the default language or the one which has been stored for this session.

If the user wishes to change the language, I call a public change_language controller-method with two arguments: the language and a base64-encoded URL of the page which is currently displayed. The method will then simply save the new language to the session, decode the base64 URL and redirect back to it.

Since the new language is now stored in the session, the hook will load that language as mentioned above.

#3
[eluser]WoolyG[/eluser]
Cool. I'll have a read about the process you mention, and look into implementing it. Thanks for your reply!
WoolyG.

#4
[eluser]wiredesignz[/eluser]
try the URI Language Identifier extension. Having the language id in the url also makes each page unique to search engines.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.