skip to Main Content

I’m trying "mcamara/laravel-localization" package to localize my app and it works as expected except for one small issue, the package seems to override the config('app.locale') default value.
For instance if the default value of the locale property in configapp.php file is set to en end I changed the application language to french with the language switcher then config('app.locale') is evaluated to fr instead of the default en.

I hope the issue is clear so my question is: how can get the default locale as defined the configapp.php config file?
Thanks

2

Answers


  1. whole point of that package is changing locale, no matter what the default locale is that package change it to whatever you config it to.
    but you can get current locale anytime you want using currentLocale() method of App facade and change it with setLocale($yourLocale).

    Login or Signup to reply.
  2. In order to get the current language code, write the following function:

    app()->getLocale();
    

    In order to activate the activation of a new language, you can write the following function:

    app()->setLocale('fr');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search