Welcome Guest, Not a member yet? Register   Sign In
How to provide a limited language option to the user.
#1

[eluser]Knitter[/eluser]
Hi,
I'm trying to develop a simple application using codeignite, a simple site for a developers team. The site should offer the option to be displayed in two languages.

For this first application I thought that one single controller would be enough, each public function in that controller is used for page navigation, thus, the function named home will present the home page to the user, the function named team will show the team's page, and so on. There is also one only view to which I send the data to display, therefor the only thins in the page that change are center content and the title.

I know would like to add content in one other language, and allow the user to choose the language that is being presented to him. The content is, for the most part, static and will not suffer changes over time, this is no blog nor does it show any news. So I was thinking of writing the content into a PHP file or XML file and just load it as it was needed.

What I'm not seeing how to do is the language part. I have two flags representing the available languages and the user can click them to change the language detection but I don't know how to properly inform the application that the user want's to change the language and to what language is should change to.

I've though about sending the click to a given function, in the existing controller, that would set a session variable and then redirect the user to the function that represents the view he was on, but this seems a bit awkward.

Any thoughts on how should I make this happen?
#2

[eluser]Aken[/eluser]
I did basically what you described on an informational site. You can view it's functionality here: http://f4i.modyourbike.com/specs ("US Measurements | Switch to Metric").

I have a function set up to search the user's session (using CI's standard cookie) and see what language they've selected. By default there's none defined, so it just uses the measurement specified (in this case, US by default).

I have a controller called "setmeasure" set up, and for whichever one is specified, it adds the session variable to the cookie, so it can be called site-wide.

I've also got some fancy nonsense setup using jQuery that shows and hides info depending on which measure is set (sweet for SEO!), but that's not really necessary. More just for me to play with.




Theme © iAndrew 2016 - Forum software by © MyBB