Rename controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Rename controller (/showthread.php?tid=1051) |
Rename controller - superheld - 02-08-2015 Hi! I'm new in oop and ci and there is a point, where i have no idea for a nice solution: My first project should be available in different languages. But how can i bring the nice URIs to an other language? I think routes are my friends, but is this the way of choice? I have in german Code: /karte/erstellen This should in english Code: /card/create As i told, i'm new. So what is the finest way to rename my controllers and methods for a new language? Thanks RE: Rename controller - Avenirer - 02-09-2015 I was just trying to do a tutorial about multilanguage site subject (http://avenir.ro/create-cms-using-codeigniter-3/create-multilanguage-site-codeigniter/), and I got to this part that you are asking about. What I was thinking is something in the lines of this: I thought of doing the language things inside the routes.php. First of all, I associated "controllers" and "methods" of other languages to the controllers and methods we have defined (this one is done manually, unless you think of another method): PHP Code: $controllers_methods = array( Then, I just return a callback function when someone asks for a controller and method in a particular language: PHP Code: $route['^(\w{2})/(.*)'] = function($language, $link) use ($controllers_methods) So, in the end the router.php would look something like this: PHP Code: <?php What do you think? Any inputs? RE: Rename controller - superheld - 02-18-2015 HI! I will just say thank you at the moment. I have some other issues with my project, so i work on this part a little bit later. I will comḿent what i did then and how it works. |