Task: It is necessary to determine the localization in the RegionMiddleware.php mediator and use it in controllers and in views.

RegionMiddleware.php

public function handle($request, Closure $next) { App::setLocale('ru'); return $next($request); } 

MainController.php

 public function __construct() { $this->middleware('region'); } public function index() { echo App::getLocale();die; } 

Displays in this case the value that is written in the config file (en). What am I doing wrong?

    2 answers 2

    It is necessary to use Lang::setLocale('ru'); instead of App::setLocale('ru');

      The fact is that you do not have the localization files themselves for the language you need, and therefore the locale rolls back to the default one from the config. Here still try to look.

      • Thanks for the advice, but all the files are in place. - Arzek