Welcome Guest, Not a member yet? Register   Sign In
Help deal with routes ?!
(This post was last modified: 09-20-2019, 06:59 AM by Digital_Wolf.)

[/url][url=https://codeigniter4.github.io/userguide/incoming/routing.html#placeholders]I already asked a similar question, but alas, the response I never received.

Reading the documentation on the link, I notice that the placeholder "{locale} " CANNOT be used as a route for example:
PHP Code:
$routes->add('{locale}/news/post/id''App\News::posts\$1', ['as' => 'Select_News']);
$routes->add('{locale}/news/main''App\News::posts', ['as' => 'All_News']); 
But clicking on another link, there I see that this placeholder CAN be used as a stand, which I do...
Only here there is one problem when I use method "->back('Select_News');" in the browser line appear these strange characters "http://example.ru/%7Blocale%7D/News/Post/1", although should be EN or RU, in dependence where initially I was.
How can I fix this ?
I would change this world, but God doesn't give me the source.

See https://github.com/codeigniter4projects/website2 for a working example of localization with the locale part of the URI.

(09-20-2019, 07:12 AM)ciadmin Wrote: См. https://github.com/codeigniter4projects/website2 для рабочего примера локализации с языковой частью URI.
Oh, I seem to have missed the news about this repository. Thanks for the answer !
I would change this world, but God doesn't give me the source.

(This post was last modified: 09-21-2019, 02:03 AM by Digital_Wolf.)

Good day !

Yesterday I looked into the project I was recommended above where I saw that in the configuration file "routes.php" registered routes in two versions with localization and exactly the same only without localization "{locale}", I repeated it in my project with only one difference, I used a group. But I had a question:

This is best practice because the amount of code gets doubled, and if it's not best practice, is there a way to fix this using my data as an example (see my screenshot). ?

Attached Files Thumbnail(s)
I would change this world, but God doesn't give me the source.

The first set, without localization, is to remediate requests coming in to soething other than the homepage, but without the link. This could be bookmarked links for instance. This solves a problem we saw when converting to the localized app. It might not be the most elegant solution, but I can live with it.

The second set of routes, with localization, are the "normal" ones.

The language dropdown is driven by the supportedLocales property in app/Config/App.php. If the user chooses a language with missing or no translations, the app falls back to English.

Theme © iAndrew 2016 - Forum software by © MyBB