CodeIgniter Forums
Language-based SEF URL`s - 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: Language-based SEF URL`s (/showthread.php?tid=10321)



Language-based SEF URL`s - El Forum - 07-27-2008

[eluser]harfaspaul[/eluser]
My first post here, so a big hello goes to everyone.

I`m working on a website using CI, and I want to implement Language-based SEF URL`s. I`m already using the URL language identification library, so at the moment the URL`s look like this : http://<host>/<language>/<class>/<function>
There will be 3 languages for the user to choose from : English, Romanian and Hungarian (en, ro, hu - in the URL). What I`d like to do is have the class and function names change depending on the active language, but still keep it all in just 1 file (1 controller) rather than having different controllers for each language...
Ex : English : http://<host>/en/about/history
Romanian : http://<host>/ro/despre/istoric

My question is if there`s any way to do this, except the obvious .htaccess or routes.php? Based on info stored in the DB maybe?

Thanks for your help.
Paul.


Language-based SEF URL`s - El Forum - 07-27-2008

[eluser]Yash[/eluser]
Ex : English : http://<host>/en/about/history
Romanian : http://<host>/ro/despre/istoric

not like here

Ex : English : http://<host>/about/history
Romanian : http://<host>/despre/istoric

Looks same however you can use language Class for this

[url="http://ellislab.com/codeigniter/user-guide/libraries/language.html"]Language Class[/url]


Language-based SEF URL`s - El Forum - 07-27-2008

[eluser]harfaspaul[/eluser]
Yash : thanks for your reply ... but I am not sure you understand what I mean. I want BOTH these URL`s to point to the same controller(class):
English : http://<host>/en/about/history
Romanian : http://<host>/ro/despre/istoric
And I want to avoid routes.php or .htaccess because of the dynamic nature of the pages in the website (news, job offers, etc). I am actually using the language class already, for some form labels, messages, etc.


Language-based SEF URL`s - El Forum - 07-27-2008

[eluser]sikkle[/eluser]
Your best bet is to go into the wiki and search for language url identifier.

Good luck !


Language-based SEF URL`s - El Forum - 07-27-2008

[eluser]wiredesignz[/eluser]
Quote:I`m already using the URL language identification library

Sikkle is on the ball again. :lol:


Language-based SEF URL`s - El Forum - 07-28-2008

[eluser]harfaspaul[/eluser]
Any ideeas welcome ...


Language-based SEF URL`s - El Forum - 07-28-2008

[eluser]wiredesignz[/eluser]
Look into using the _remap() feature.


Language-based SEF URL`s - El Forum - 08-11-2008

[eluser]Unknown[/eluser]
harfaspaul, did you make any progress on this? As a newbie, I am trying to solve the same thing...


Language-based SEF URL`s - El Forum - 08-12-2008

[eluser]rolly[/eluser]
In the controller, for "translating" the method:

Code:
function istoric(){
     [..]code goes here[..]
}
function history(){
     $this->istoric();
}

And for the controller you need to add this this in config/routes.php

Code:
$route['([a-zA-Z]{2})/about(.*)'] = "despre$2";