Welcome Guest, Not a member yet? Register   Sign In
Language-based SEF URL`s
#1

[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.
#2

[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]
#3

[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.
#4

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

Good luck !
#5

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

Sikkle is on the ball again. :lol:
#6

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

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

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

[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";




Theme © iAndrew 2016 - Forum software by © MyBB