CodeIgniter Forums

Full Version: Help deal with routes ?!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[/url][url=]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 "", although should be EN or RU, in dependence where initially I was.
How can I fix this ?
See for a working example of localization with the locale part of the URI.
(09-20-2019, 07:12 AM)ciadmin Wrote: [ -> ]См. для рабочего примера локализации с языковой частью URI.
Oh, I seem to have missed the news about this repository. Thanks for the answer !
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). ?
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.