Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel set default language not working

I have changed the default website localization in confing/app.php to be (de)

'locale' => 'de',
'fallback_locale' => 'de',

But still website is loading in 'en' localization .

I tried clearing the view cache and cache but nothing changed .

I am using https://github.com/mcamara/laravel-localization

The de will be activate only when i use the URL domainname.com/de

like image 451
Q8root Avatar asked Jan 03 '23 02:01

Q8root


2 Answers

In the scenario to not be using the dynamic locale in the URL it seems you will have to adjust the configuration file for this package:

'useAcceptLanguageHeader' => false,

From the comments for that variable:

"Negotiate for the user locale using the Accept-Language header if it's not defined in the URL? If false, system will take app.php locale attribute"

Seems to get it to use that default you have to set this to false.

You could play with the other variable:

'hideDefaultLocaleInURL' => true,

to see how that adjusts the default behavior as well.

like image 116
lagbox Avatar answered Jan 07 '23 20:01

lagbox


i had the same proplem go to laravellocalization.php in config

and make

'useAcceptLanguageHeader' => false,

and then run

php artisan config:clear

and it will work

like image 33
malah Avatar answered Jan 07 '23 20:01

malah