This is a bug or feature ? - 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: This is a bug or feature ? (/showthread.php?tid=74128) |
This is a bug or feature ? - Digital_Wolf - 07-26-2019 Hello everyone who reads this topic Helping one man solve his problem with the redirects, I was faced with the problem... let's say I have this small system routing: PHP Code: $routes->group('{locale}', function($routes) { and in the method "test_1" spelled out the function "return redirect()->route('Test_2')", then when you go to this route, it redirects to "TestController::test_2" and in the place of the name of the locale in the url is this entry: "%7Blocale%7D" and segmet "/SecondTest" Q: is This recording supposed to be like this "%7Blocale%7D", or should it be the localization we were originally in ? RE: This is a bug or feature ? - MGatner - 07-28-2019 Docs state: “ {locale} cannot be used as a placeholder or other part of the route, as it is reserved for use in localization.” So my guess is that the explicit reference is bugging the named route. Not sure how to accomplish what you’re after other than leaving out the group maybe? Ref https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#placeholders RE: This is a bug or feature ? - Digital_Wolf - 07-28-2019 (07-28-2019, 07:52 AM)MGatner Wrote: Docs state: I don't quite understand, then it turns out this section (which you refer to) contradicts that: {locale} in routes How can I then implement such a system: I have a variable: $baseLocale = 'en'; $supportedLocales = ['en', 'ru']; and I want to have routes like: https://example.com/(EN or RU)/auth/(SignIN or SignUP)/ But so that these routes were logically linked using groups, like in my example above... now I have here such code at myself in the file of a route.PHP: PHP Code: $routes->group('{locale}', function($routes) { RE: This is a bug or feature ? - InsiteFX - 07-28-2019 PHP Code: // Config/App.php It's doing that because you may not have set the default locale by using getLocale() method. RE: This is a bug or feature ? - Digital_Wolf - 07-28-2019 (07-28-2019, 10:53 AM)InsiteFX Wrote: Uh no, I have in config/App.php all this has long been installed, but that's what I do not have in the controller so this is this function: PHP Code: $locale = $this->request->getLocale(); in place of it I have this: PHP Code: $data = [ In my case, this variable: $data['Head']; Called in Code: <html lang="<?= $Lang; ?>"> And when I follow the link from example.com/EN/auth/welcome to example.com/EN/auth/signup that at me everything is perfectly displayed, but if I in a method "signup" of the controller "Auth" call function "return redirect()->route('Welcome')", and then I update the page, then at me instead of example.com/EN/auth/welcome the browser bar appears example.com/%7Blocale%7D/auth/welcome RE: This is a bug or feature ? - Digital_Wolf - 07-28-2019 UPD: I do not quite understand why to use the variable $locale, because it is of little use, as I directly transmit this value to the views and there is already as I said before can just use: Code: <= lang(head.namePageAuth_welcome, $Lang); ?> |