CodeIgniter Forums
How to work with auto routing and languages in CI4? - 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: How to work with auto routing and languages in CI4? (/showthread.php?tid=83078)



How to work with auto routing and languages in CI4? - rodrigoguariento - 09-17-2022

Hi, I've enabled auto routing ( https://codeigniter.com/user_guide/incoming/routing.html#auto-routing-improved ) in my CI4 project, and before start work with Localization ( https://codeigniter.com/user_guide/outgoing/localization.html#working-with-locales ) I was calling my controller method like this: http://mydomain.com/mycontroller/someaction , but now with Localization on, I'm using two languages: en, pt-BR. To call the same URL in the right way would be http://mydomain.com/pt-BR/mycontroller/someaction, but working with auto routing and Localization, this URI with "locale" (pt-BR or en) does not work. Did I forget something? What is the right way to work with Location + auto routing improved in CI4? Thanks.


RE: How to work with auto routing and languages in CI4? - kenjis - 09-17-2022

The auto routing does not support localization. It does nothing for localization.

I recommend you use the defined route with locale:
https://codeigniter.com/user_guide/outgoing/localization.html#in-routes


RE: How to work with auto routing and languages in CI4? - InsiteFX - 09-18-2022

For localization see this tutorial.

Creating a multilingual website with CodeIgniter 4 (part 1)

Creating a multilingual website with CodeIgniter 4 (part 2)


RE: How to work with auto routing and languages in CI4? - rodrigoguariento - 09-30-2022

Thank you! Gradually I am understanding the difference between CI3 and CI4.