![]() |
Translated Routes - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Translated Routes (/showthread.php?tid=77106) |
Translated Routes - kilden - 07-19-2020 Hello, I've got a question about localization and translated routes : I wonder if there is a solution to combine 'named routes' and the 'lang() function' to translate URL and keep the app very simple to update for future developments. First I made my translations in Routes.php like this : PHP Code: /*In my template-view header.php*/ If possible I would like to put all translations in app/Language... I've tried this without success : PHP Code: /*In my template-view header.php*/ It almost works, because Routes.php reads a part of the translation... but just the default language. there is no update of the locale with {locale}... Do you know a way to do it ? Thank you for any help ! RE: Translated Routes - kilden - 07-21-2020 So, Is there no solution to avoid translations into routes.php ? The best I could do (because the function 'lang' in Routes.php doesn't recognize current locale) looks like this : PHP Code: /*in Routes.php*/ Routes.php doesn't recognize current $locale, so I need two lines... And all translations of urls are in app/Language/fr/app.php which is pretty dumb and illogical. RE: Translated Routes - kilden - 07-21-2020 ups no... ![]() RE: Translated Routes - nicojmb - 07-21-2020 (07-21-2020, 04:38 AM)kilden Wrote: ups no... try with reverse routes and put lang() in routes PHP https://codeigniter4.github.io/userguide/incoming/routing.html#reverse-routing or extend core class to support this function https://codeigniter4.github.io/userguide/extending/core_classes.html?highlight=router#extending-core-classes RE: Translated Routes - kilden - 07-24-2020 According to your advice I've tried a lot of ways but always without success. Even with reverse routes, I think you can't put lang() in routes... |