laravel-localization icon indicating copy to clipboard operation
laravel-localization copied to clipboard

Working with Laravel Nova

Open covaberjon opened this issue 6 years ago • 8 comments

First of all, thank you for the package.

I have a problem using your package with Laravel Nova. I am only using your package with my frontend routes. However, my laravel nova backend is being affected.

Instead of showing my ES translations, is showing EN translations.

I tried adding:

'urlsIgnored' => ['/nova/*']

But it didn't work.

The only thing that actually worked was setting useAcceptLanguageHeader to false.

covaberjon avatar Jan 23 '19 11:01 covaberjon

Same problem caused by "LaravelLocalization::setLocale()" in ->prefix(LaravelLocalization::setLocale())

YannikFirre avatar May 05 '19 10:05 YannikFirre

Any updates here ?

maherelgamil avatar Oct 04 '19 20:10 maherelgamil

Any updates?

marijoo avatar Nov 19 '19 14:11 marijoo

Sorry but Laravel Nova is not open source, so I can't look into it to help you. You may need to fix it by yourself and send a PR. Or switch to an open source admin panel: https://voyager.devdojo.com/

iwasherefirst2 avatar Nov 20 '19 10:11 iwasherefirst2

Maybe I don't understand but can't you just create a 'frontend' middlewaregroup and reference that wherever you need route localization? That's what I do. Using a seperate group for frontend does not affect any Nova routes.

gavinhewitt avatar Nov 28 '19 01:11 gavinhewitt

I have solved this issue for me. I have created a helper function for routing with using LaravelLocalization class. Try this in web.php instead of transRoute method. Add the nova paths in config file btw.

function __route($name)
{
    $shouldIgnore = function ($request) {
        $excepts = config('laravellocalization.urlsIgnored', []);

        foreach ($excepts as $except) {
            if ($except !== '/') {
                $except = trim($except, '/');
            }

            if ($request->is($except)) {
                return true;
            }
        }

        return false;
    };


    if ($shouldIgnore(request())) {
        return;
    }

    return LaravelLocalization::transRoute('routes.' . $name);
}

ysfkaya avatar Jun 20 '20 21:06 ysfkaya

@ysfkaya no luck man :(.

namnh06 avatar Oct 11 '20 10:10 namnh06