Language related question |
[eluser]Jondolar[/eluser]
[quote author="Klaatush" date="1243950010"]I am also facing the same situation, actually a little more worse We have currently 3 languages ENG/DUT/FRE (English, Dutch, French). Any of the language can be set to default and saved in DB. for the default language we don't need the lang parameter but the rest will show with the lang in URI. Structure of URI is http://domain.com/[lang/]controller/function/parameters... so for example if eng is default lang of site, page will be http://domain.com/news/show/1 but if the user selects DUT as language, the page URI will become http://domain.com/dut/news/show/1 if you find the solution of your problem, kindly post here, so with the help of that solution, I can solve my problem. Thanks in advance.[/quote] There is a solution. You use URI routing so if the first section of the URI has 2 characters, rewrite it to the controller in the second section. There are posts on how to do this but it is just one line and very simple: Next, in your controller, look to see if the first section of the URI has 2 characters and if it does, assign your $lang variable to that. If not, assign your default lang to that variable. You now have the proper language. When creating URLs, you can create a variable is assigned "/lang" if you are not on your default language and is assigned "" if you are on your default language. Then, echo out the lang variable in front of every URL. There are other ways to do this. Good luck with your project.
[eluser]Klaatush[/eluser]
played with CI for sometime and end up with this code my_router.php to override some routing Code: class MY_Router extends CI_Router lang_stting_a.php and lang_setting_b.php holds same data and will be generated from DB.... using two files just to eliminate the chances that if the file is opened up for writing and have garbage data for the time..the routing class attempt to read lang_setting_b first but when generating files, lang_setting_a will be generated first.. lang_setting_a.php Code: $site_langs=array(); if we have a language but its disables, e.g. French in above case, all request to the language will be transferred to default language and there will be a CMS as well whose pages will be accessed as http://domain.tld/[language/]page but the actual path will be http://domain.tld/[language/]cms_page/show_page/page I think I have some mess in the code (though in initial testing it worked fine).. looking forward to your comments to improve the code
[eluser]Tottys Design[/eluser]
But what if I need something like this: default language: www.website.com/en/gallery and portuguese: www.website.com/pt/galeria How can i do it? Thanks!
[eluser]Unknown[/eluser]
I have the same question on my mind, is it possible to have the following solution in CI default language: www.website.com/gallery and portuguese: pt.website.com/galeria Any tips or hints would be very helpfull. Thanks. |
Welcome Guest, Not a member yet? Register Sign In |