*SOLVED* Multilingual codeigniter site - 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: *SOLVED* Multilingual codeigniter site (/showthread.php?tid=34123) Pages:
1
2
|
*SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Mr. Pickle[/eluser] Hi there, I want to set-up a multilingual Codeigniter project. I've tried to look up on this but could not find a satisfying solution. I simply want my first uri segment to be the language code, e.g. /en/ /de/ /fr/ etc.... Therefore I basically want the second segment to be the controller and the third segment to be the action. With the flexibility to put one or more segments behind. I now have set up something in the routes file, but I need to tell CI every possible route to every possible controller and action, while I'd like to keep this flexible. I'd unfortunately didn't work to just say: Code: $route[':any/:any/:any'] = "$2/$3"; So, how I'd like it is to have for example: http://siteurl/en/topic/show/1 To laoad the topic controller and the show action. There I catch the fourth parameter, and use it as the topic ID to show. But I need to have it work also if I have for example: http://siteurl/en/topic/show/1/print because I check in the code if a fifth parameter is present (and possibly a sixth, seventh... as well) Thanks in advance for any ideas/solutions! *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Ki[/eluser] Hi, I had to deal with exactly same problem before. I have put my modifications and detailed instructions here: http://www.key2market.com/2010/09/internationalization-with-codeigniter-2-0/ Note that this isfor CI 2.0 *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Mr. Pickle[/eluser] What I can't figure out is how to fool the routes so that the first param is ignored when determining the controller action and other params. I tried to use @Ki's code in CI 1.7.2. but CI still tries to look for the controller en if I load mysite.com/en/ or mysite.com/en/controller/acties/param3/ *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Ki[/eluser] Did you edit your routes as per instructions? Code: // We load routes for all languages in the $config['langages'] array *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Mr. Pickle[/eluser] Yes, I did. *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Ki[/eluser] What about if you try to hard-code it: Code: $route['en'] = "default_controller"; *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Mr. Pickle[/eluser] Hi, this works for now for url's containing only the controller (e.g. category) after the language code, for example: http://myssite.com/en/category But it won't work with for example: http://mysite.com/en/category/php I don't want to put literally every possible route (with every possible segment, e.g. with pagination as this asks flexibility of your uri's) in the routes.php config. *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Ki[/eluser] Thats where you use Code: function _remap() within each controller More about this here http://ellislab.com/codeigniter/user-guide/general/controllers.html *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Mr. Pickle[/eluser] Hi Ki, but to get to a controller CI should not have the language misstaken with the controller, isn't it? I mean, your _remap() solution is normally associated with the second parameter, while my language is the first parameter. Or do I just don't understand (yet)? The current hard-coded routes.php addition only kicks in when their is only one lang code as the first parameter and one controller name as the second parameter. *SOLVED* Multilingual codeigniter site - El Forum - 09-20-2010 [eluser]Ki[/eluser] My first comment is for you to be more specific and descriptive of what is happening with your code. You stated earlier: But it won’t work with for example: http://mysite.com/en/category/php What does " it won’t work" means? Are you getting an error? Are you getting a blank screen? |