Language indicator in URL |
[eluser]mDonchev[/eluser]
Hello all, I want to put a language indicator in the URLs generated in the CI website like this: www.example.com/en/controler/function/parametter I want this "en" to be "read" by the router, set a session variable and then to load the proper controler/funciton/parametter. Note: I want the URL to stay as it is. Not to redirect to www.example.com/controler/function/parametter Please tell me how I can achieve that. THanks Martin
[eluser]pistolPete[/eluser]
I already told you about this wiki category: http://codeigniter.com/wiki/Category:Int...alization/ Have a look at: - http://codeigniter.com/wiki/Category:Int...iews_i18n/ - http://ellislab.com/forums/viewthread/44721/ - http://ellislab.com/forums/viewthread/61150/
[eluser]mDonchev[/eluser]
Thanks I read that with one eye, but I've done something different as a solution and I'm aaaalllmost done. I've rewrote the URLs so that the first segment to be the language indicator, and I'm rewriting the Router.php class so that it sets the language indicator as a session variable and exclude it from the segments so that everything goes as normal as it would be without that language indicator in the URL. I'm having a slight problem with setting the session because the session class is not loaded in the Router.php and I cannot load it.. so I'm trying to use pure PHP for setting that session. Thanks Martin
[eluser]mDonchev[/eluser]
Any ideas how I can load the session library inside the Router.php (note that its used too early in the loading process so the Loader is not available yet!) Thanks Martin
[eluser]xwero[/eluser]
Why would you need to change the router. You just set a route to redirect each url that has a language segment Code: $route['[a-z]{2}/(.+)'] = '$1'; // regex may not work And you overwrite the url creating functions to add the language segment or just append the language segment to the index_page with a hook function. Having as config file with the language, an url with the language and on top of that a session with the language isn't that too much redundance?
[eluser]phpwebdev[/eluser]
Здравей Мартине, Не разбирам защо трябва пазиш езика в сесията. По добре от гледна точка на SEO -то да бъде в урл-то Аз използвам една библиотека която използва нещто като http://www.server.com/bg/controller/function/ http://www.server.com/en/controller/function/ И нямам оплаквания ..... Ето и линка http://codeigniter.com/wiki/URI_Language_Identifier
[eluser]Treeda[/eluser]
if you would use english like nearly everyone in that forum, quite a lot more people could benefit from your answer.
|
Welcome Guest, Not a member yet? Register Sign In |