Why doesn't $request->getLocale() return the correct locale any more (since v.4.3)? |
I noticed that the last time $request->getLocale() returned the correct locale based on the URI was with CI_VERSION 4.2.x
How I use it: PHP Code: class BaseController extends Controller app/Config/App.php : PHP Code: class App extends BaseConfig The routes: PHP Code: $routes->get('/', 'Home::index'); Expected behavior: When in a URL like http://localhost:8080/fr/cp/countries, $currentLocale in the view equals "fr". In CodeIgniter 4.2.5: $currentLocale gets set as "fr" In CodeIgniter 4.3.x: $currentLocale gets set as "en" probably what's set as the default locale in app/Config/App.php (i.e. on a page in French, locale is returned as English) Why? And how to get "fr" from http://localhost:8080/fr/... now in CI 4.3.x and 4.4.x? CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5)
In 4.4, I cannot reproduce.
Code: diff --git a/app/Config/App.php b/app/Config/App.php Code: diff --git a/app/Config/Routes.php b/app/Config/Routes.php Code: diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php Code: diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php Navigate to http://localhost:8080/fr/cp , I see "fr".
I checked v4.3.8, and I cannot reproduce it.
I also see "fr".
I'm using IncludeBeers Create a Multilingual Website and it is working fine here with CodeIgniter 4.4.0.
Creating a multilingual website with CodeIgniter 4 (part 1) Creating a multilingual website with CodeIgniter 4 (part 2) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Sorry, but the problem persists. I not only tried all the steps in the documentation, but also the tutorial above. Working app based on CI 4.2.x is at https://ccpdemo2.ozar.net - it can be tested by selecting a language from the dropdown in the right hand side of the top navbar. When all the code in this app is copied over to CI 4.3.x, it breaks and language selection menu always takes the user to an English page.
May I request, those who assert no such problem exists, describe all the steps to reproduce a working solution testing also with the Safari browser? Can't do withouts: The URLs to be tested need to be created using routes that will reside in the below route groups. PHP Code: $routes->group('{locale}/cp', [], function($routes) { PHP Code: $routes->group('{locale}/admin', [], function($routes) { CodeIgniter Wizard (CRUD code generator for Mac) instantly scaffolds Bootstrap-based web applications with an administrative interface (admin templates include Bootstrap5) |
Welcome Guest, Not a member yet? Register Sign In |