Welcome Guest, Not a member yet? Register   Sign In
Multilanguage database
#1

[eluser]in4matic[/eluser]
Hello everybody! I have a CodeIgniter site in english. Now i want to add another language (italian). I have translated all the content and place in database, in table fields like name_en, name_it, content_en, content_it,,,, etc. I want the user to select what language want and to navigate on site with the choosing language. I think to do this with sessions,according to language make querys to model functions that corresponds to database fields; and make english default language otherwise. Can anyone help me with this?
Thnx in advance ! Smile
#2

[eluser]porquero[/eluser]
Is better use translations through filesystem.
I recommend you see:


http://ellislab.com/codeigniter/user-gui...guage.html
http://ellislab.com/codeigniter/user-gui...elper.html
#3

[eluser]in4matic[/eluser]
Thanks Grad Student, but i want to implement as i said. Isn't there any way of manipulation only with database? I think it need to change the URI on user clicking. Help me please !
#4

[eluser]porquero[/eluser]
You can save language tables suffix in a session.
#5

[eluser]timobg[/eluser]
You have to edit the routes.php in the config dir to have urls like:

domain.com/en/pages/...

then you can check the first segment and store the current language in the config,

so in your controllers you can choose to show the field name according to the language

ex. if you have tables fields like "content_en", "content_it"

Code:
echo $data->{"content_".$this->config->item('current_lang')};
#6

[eluser]in4matic[/eluser]
I think this will help me a lot. Smile)
Now i'm trying.....
Thanks!
#7

[eluser]in4matic[/eluser]
I have another problem, when i click english or italian link, the language of site changes. But doing this more then one time, the uri looks like this: domain.com/en/it/en......./controller. Is there a way to overwrite new language in previous language, not to add it?
#8

[eluser]astroanu[/eluser]
whats the href value in your <a> tag?
#9

[eluser]in4matic[/eluser]
Now i can't post the code, it gives me an error.
#10

[eluser]in4matic[/eluser]
I solve this problem, but i have another one:
When i change the language with links its ok, but when i go on another page in the site, it is in default language, not the selected one. I tell you that when i change the language, it appears in uri, and in controllers i have added in every function that if the language is changed (checks the language through URI) create a session that save this language else create a session with the default language. Maybe isn't correct to insert in every function this if....else statement? But, where to insert this condition?
Thnx in advance!




Theme © iAndrew 2016 - Forum software by © MyBB