Welcome Guest, Not a member yet? Register   Sign In
Multilingual SEO friendly urls
#1

[eluser]Unknown[/eluser]
Hello all. I'm desperate help. I'm quite new to CI although I love it. I've been looking for my answer for some time and I'm beginning to believe that it's impossible.
My question is:
How can I do something like that:

www.example.com/en/cars
www.example.com/fr/voitures

I want that those two urls was targeted into the same controller, I know how to make such language selection by i18n but how can I do those "controller translation" ?
I think that maybe hook can do the thing but I don't have any idea how to begin.
Please help
#2

[eluser]regal2157[/eluser]
Well, I'm sure they're would be an optimal way, possibly setting up a language file, but possibly, if it's not too much of a hassel, just make routes for now. I never used i18n.. so I am not sure about using it's features.
#3

[eluser]adityamenon[/eluser]
Are you asking how to send those requests into the same controller? Make a function called lang and take it from there:

http://example.com/page/lang/en/cars
http://example.com/page/lang/fr/voitures

Lang will be a function in the 'page' controller, accepting the two params "language" and "word"... you can do your processing from that point...

Like regal pointed out, you could then configure your config/routes.php or even use .htaccess to convert http://example.com/en/cars to http://example.com/page/lang/en/cars

Hope that is all you were confused about.
#4

[eluser]Unknown[/eluser]
Thanks both of you, actually I did what I wanted by using routes and .htaccess, maybe it's not efficient but quite simple.
#5

[eluser]Unknown[/eluser]
[quote author="adityamenon" date="1307237900"]Are you asking how to send those requests into the same controller? Make a function called lang and take it from there:

http://example.com/page/lang/en/cars
http://example.com/page/lang/fr/voitures

Lang will be a function in the 'page' controller, accepting the two params "language" and "word"... you can do your processing from that point...

Like regal pointed out, you could then configure your config/routes.php or even use .htaccess to convert http://example.com/en/cars to http://example.com/page/lang/en/cars

Hope that is all you were confused about.[/quote]

Nice way indeed!
but when we want multilingual sites, it's about having a big one, with severals sub folders in controller, with plenty of method in it..

i'm using the routing method, but forced to add some lines for each new controller...

is there a way to have this kind of implementation in the core system of CodeIgniter in a next version ?

for instance :

$config['default_controller'] = 'http://www.example.com/:lang/';
$config['multilang'] = array('fr','en', 'it, 'es', 'de');

and nothing more...

thank you all !





Theme © iAndrew 2016 - Forum software by © MyBB