title: Laravel 5.4 set locale in session
body: <p>Update. 
  I would like to know how to set locale in session. </p>
  
  <p>my language picker isnt' input type, but just text. here is blade fragment - this is language picker:</p>
  
  <pre><code>&lt;div class = "col-lg-5 col-md-5" id = "lang"&gt;
      &lt;ul id = "lang_menu"&gt;
          &lt;li class = "language active"&gt;Latviešu&lt;/a&gt;&lt;/li&gt;
          &lt;li class = "language"&gt;Pусский&lt;/a&gt;&lt;/li&gt;
          &lt;li class = "language"&gt;English&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here are routes:</p>
  
  <pre><code>Route::get('/', 'PagesController@index');
  
  Route::get('/mafia', 'PagesController@mafia');
  
  Route::get('/games', 'PagesController@games');
  
  Route::get('/discounts', 'PagesController@discounts');
  
  Route::get('/tournaments', 'PagesController@tournaments');
  
  Route::get('/gallery', 'PagesController@gallery');
  
  Route::get('/aboutus', 'PagesController@aboutus');
  </code></pre>
  
  <p>also i have transladet files who works fine when i changing locale in config</p>
  
  <p>&lt;&lt;----------UPDATED----------------->></p>
  
  <p>Now i got so far but still its not working. I made this code from one tutorial where all works. I did the same and its not working. </p>
  
  <p>Here is lang choosing Blade : </p>
  
  <pre><code>&lt;ul id = "lang_menu"&gt;
      &lt;li class = "language active"&gt;&lt;a href ="{{ url('/locale/lv') }}"&gt;Latviešu&lt;/a&gt;&lt;/li&gt;
      &lt;li class = "language"&gt;&lt;a href ="{{ url('/locale/ru') }}"&gt;Pусский&lt;/a&gt;&lt;/li&gt;
      &lt;li class = "language"&gt;&lt;a href ="{{ url('/locale/en') }}"&gt;English&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Here is routes:</p>
  
  <pre><code>Route::get('locale/{locale?}', array('as'=&gt;'set-locale', 'uses'=&gt;'LanguageController@setLocale'));
  </code></pre>
  
  <p>Here is my LanguageController:</p>
  
  <pre><code>use Illuminate\Http\Request;
  use Session;
  use URL;
  
  class LanguageController extends Controller
  {
  public function setLocale($locale='en'){
      if (!in_array($locale, ['en', 'ru', 'lv'])){
          $locale = 'en';
      }
      Session::put('locale', $locale);
      return redirect(url(URL::previous()));
      }
  }
  </code></pre>
  
  <p>And here is middleware "Locale":</p>
  
  <pre><code>use Closure;
  use Session;
  use Config;
  use App;
  
  class Locale
  {
  /**
   * Handle an incoming request.
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  \Closure  $next
   * @return mixed
   */
  public function handle($request, Closure $next)
      {
      $locale=Session::get('locale', Config::get('app.locale'));
      App::setLocale($locale);
      return $next($request);
      }
  }
  </code></pre>
  
  <p>And added in Kernel.php:</p>
  
  <pre><code>    \App\Http\Middleware\Locale::class,
      \Illuminate\Session\Middleware\StartSession::class,
  </code></pre>