language abbreviation in url - 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: language abbreviation in url (/showthread.php?tid=73431) |
language abbreviation in url - arassaff - 04-23-2019 Hello everybody, I am working with codeigniter 4. I have a problem. how can i recognize languageĀ abbreviation in url. with PHP Code: $routes->get('{locale}/books', 'App\Books::index'); I tried but the problem is the following. 1. for all routes {locale} must be defined. 2. without language abbreviation the controller is not found. 3. $routes->setAutoRoute(true); no longer works. it has to work like this: when user enters the URL: www.domain.com requires its browser language to be recognized and redirected to www.domain.com/en/ and if user enters the URL www.domain.com/de/ the locale must be changed in German. this must work as well: http://www.domain.com/contoller/method redirect to http://www.domain.com/en/contoller/method I look forward to your suggestions thanks RE: language abbreviation in url - includebeer - 04-24-2019 Did you read this section in the user guide? I didn't try it yet, but it explains how to do it: https://codeigniter4.github.io/CodeIgniter4/outgoing/localization.html#in-routes RE: language abbreviation in url - arassaff - 04-24-2019 (04-24-2019, 05:28 AM)includebeer Wrote: Did you read this section in the user guide? I didn't try it yet, but it explains how to do it: yes but that is not four for this. RE: language abbreviation in url - futureisnow - 09-23-2019 (04-23-2019, 09:45 PM)arassaff Wrote: Hello everybody, Hi, did you find any solution? I am struggling the same problem now. Thanks in advance. RE: language abbreviation in url - ciadmin - 09-23-2019 See https://github.com/codeigniter4projects/website2 for a working example. RE: language abbreviation in url - mintwint - 09-26-2019 Edit routes.php like this: PHP Code: $routes->get('{locale}/auth/(:any)', 'Auth::$1'); {locale} - local code auth - name controller (:any) - name method |