This is a bug or feature ? |
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 ? I would change this world, but God doesn't give me the source.
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/CodeIgnit...aceholders
(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) { I would change this world, but God doesn't give me the source.
PHP Code: // Config/App.php It's doing that because you may not have set the default locale by using getLocale() method. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
07-28-2019, 11:30 AM
(This post was last modified: 07-28-2019, 11:33 AM by Digital_Wolf. Edit Reason: replace of "i" on "to" ) (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 I would change this world, but God doesn't give me the source.
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); ?> I would change this world, but God doesn't give me the source.
|
Welcome Guest, Not a member yet? Register Sign In |