mcamara / laravel-localization

Easy localization for Laravel
MIT License
3.37k stars 515 forks source link

Translated route not redirecting correctly #493

Open istratos opened 7 years ago

istratos commented 7 years ago

Utilizing all 4 middleware for this procedure.

Route::group([
    'prefix' => LaravelLocalization::setLocale(),
    'middleware' => [
        'localize',
         'localeSessionRedirect',
        'localizationRedirect',
        'localeViewPath'
    ]
], function()
{
    Route::get(LaravelLocalization::transRoute('routes.contact'), 'PageController@contact')->name('contact');
});

'hideDefaultLocaleInURL' => true,

Supporting english (default) and spanish

English route: /contactus

Spanish route: /es/contacto

If current locale is EN (English): /contactus shows english page fine. (correct) /en/contactus redirects to /contactus (correct) /contacto shows 404 (should redirect to /es/contacto) /es/contacto shows spanish page fine. (correct)

If current locale is ES (Spanish): /contactus redirects to es/contacto (correct because sessionredirect) /en/contactus redirects to /contactus (correct) /contacto shows 404 (should redirect to /es/contacto) /es/contacto shows spanish page fine. (correct)

So in short, the localized uri name won't ever work. /contacto route should redirect to es/contacto rather than showing a 404.

Why is this?

Laravel 5.5 Laravel-localization 1.3.2

dorinesinenco commented 7 years ago

+1, Subscribe to this issue. Same goes in my case, we have 2 projects where /test/{param} /ru/тест/{param} works on default language but when switching to the translated counterpart the route becomes /тест/{param} /ru/тест/{param} laravel 5.5 Laravel-localization 1.3.2

aydinfatih commented 4 years ago

+1