laravel-localization
laravel-localization copied to clipboard
weird issue involving getInversedLocaleFromMapping
I assume I have done something wrong somewhere but...
New Laravel 8 sail install
Installed laravel-localization over composer.
Created a localesMapping
'localesMapping' => [ 'en-GB' => 'uk', 'de-DE' => 'de' ],
Redirect not working, 'en' ok, 'de' is a 404
Routing in web is set up so
Route::group( [ 'prefix' => LaravelLocalization::setLocale(), 'middleware' => [ 'localize','localeSessionRedirect', 'localizationRedirect', 'localeViewPath' ] ], function() {
After looking into this I find in vendor/mcamara/laravel-localization/src/Mcamara/LaravelLocalization/LaravelLocalization.php the following.
When calling LaravelLocalization::setLocale(),
I get from
$locale = $this->request->segment(1);
"de" as expected
but then
$locale = $this->getInversedLocaleFromMapping($locale);
"de_DE"
And the next part goes wrrong
$this->supportedLocales
array:2 [▼
"de" => array:4 [▶]
"en" => array:4 [▶]
]
where obviously de_DE is not found.
If I just comment out getInversedLocaleFromMapping then all works fine.
What have I done wrong?
thanks