Back to Translate Extended Support


I want to setup auto redirect based on user's browser language, but it's not working - there is no redirects at all (only forced prefix). Is it possible to activate this option?


Had a same issue, but just figured that out:

  1. activating only Browser language detection doesn't work, because there several fundamental, in my opinion, wrong decision on activating the plugin. The plugin activated only if Route prefixing is ON.

  2. real language detection start only after you have Route prefixing is ON and Homepage redirect in ON. The plugin's middleware executed ONLY in this condition.

  3. Force prefix doesn't work correctly, because see #1 and #2 + locale picked up as $translator->getDefaultLocale() which always return my default locale without actual detection of the user's locale. for #3 in the /plugins/excodus/translateextended/routes.php Line=48 the block of force_prefix condition replace the if block with:

if (Settings::get('force_prefix', true)) {
            Route::get('/{any}', function ($any) use ($translator, $request) {
                $redirect = $translator->getLocale() . '/' . $request->path();
                if ($request->query()) {
                    $redirect .= '?' . http_build_query($request->query());
                return redirect($redirect);
            })->where('any', '.*')->middleware(['web', ExtendedLocaleMiddleware::class]);

what is done there is used $translator->getLocale() verses $translator->getDefaultLocale() and executed the middleware itself ->middleware(['web', ExtendedLocaleMiddleware::class])

the PR for issue #3 submitted

1-2 of 2