language abbreviation in url |
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
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/CodeIgnit...#in-routes (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.
(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.
Edit routes.php like this:
PHP Code: $routes->get('{locale}/auth/(:any)', 'Auth::$1'); {locale} - local code auth - name controller (:any) - name method |
Welcome Guest, Not a member yet? Register Sign In |