Multilanguage service |
Hi,
What I want to accomplish is a multilanguage web service, where language is determined by first two characters after base_url. That is, when user enters "example.com/en/someController/someMethod" it will fire up the someMethod in someController, but before doing that, it will set a global (actually defined in My_Controller) variable to 'en'. I know I can handle this by using routes, and passing the language code as first parameter to methods, but this requires a lof of work, plus, we have a lot of existing code, and modifying it would be a nightmare. So I thougt, that maybe using hooks is the way to go? There is a "pre_controller" hook, Is this possible to get an uri segment and then call a controller/method or maybe rather to alter routes dynamically from there?
Here you go ... a fast and easy tutorial for you here. Hope this help.
p.s : I have used it to on some projects and works like a charm
Website : www.my-web-projects.com
Multilanguage site that relies on session data isn't the best option (SEO).
You can try this library. It's a bit old but hey - it's CodeIgniter it should work just fine.
Thank you both! I'll look at the links and I'll get back in case of any problems.
There you go buddy, I've been using this lib for years and never failed me.
http://jeromejaglale.com/doc/php/codeigniter_i18n
Website: marcomonteiro.net | Blog: blog.marcomonteiro.net | Twitter: @marcogmonteiro | TILThings: tilthings.com
@michalsn @marcogmonteiro
Thanks. There is a problem with this library though. It doesn't recognize my other routes. I have: $route['^(en|es)/(.+)$'] = "$2"; $route['^(en|es)$'] = $route['default_controller']; And it works with e.g. example.com/en/pages/contact. But then I want to add this route: $route['contact']='pages/contact'; hoping this to work: example.com/en/contact but it doesn't. I tried $route['^(en|es)contact']='pages/contact' but it doesn't work either. Can somebody help me with this? I'm using CI v.2.2.0 Update: it actually does work with $route['en/contact']='pages/contact' although it does not work with '(es|en)/contact' - so I'm almost succeeded Do you by chance know why the later doesn't work?
I'm curios why do you want to use en/fr/.... in your link
Website : www.my-web-projects.com
Is there any library available for CodeIgniter 3.0 i18n support?
Hi Rufnex,Great post..Really i get more information about multilanguage tutorial..Can you reply where this multilanguage concept has to apply???I am waiting for the reply..keep in touch with us..Thanks in advance
|
Welcome Guest, Not a member yet? Register Sign In |