title: How can I change the language of errors in laravel 5.1 dynamically
body: <p>I have been using the helper </p>
  
  <blockquote>
    <p>app()->setLocale(session('lang'));</p>
  </blockquote>
  
  <p>However, I can get to change the languages of views but the languages of errors still continues reading of </p>
  
  <blockquote>
    <p>\config\app.php  locale => ‘es’</p>
  </blockquote>
  
  <p>That means that always show the same language.</p>
  
  <p>How can i change it also dynamically?</p>
  
  <p><a href="https://i.stack.imgur.com/GqFlu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GqFlu.png" alt="enter image description here"></a></p>
  
  <p>The problems is that the partial view that prints the errors always print in the same language.</p>
  
  <p>Here is the code that i have.</p>
  
  <p><strong>\resources\views\layout.blade.php</strong></p>
  
  <pre><code>@lang('messages.project')
  &lt;ul class="nav navbar-nav navbar-right"&gt;
    &lt;li&gt;&lt;a href="{{ url('lang', ['en']) }}"&gt;En&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="{{ url('lang', ['es']) }}"&gt;Es&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p><strong>\app\Http\routes.php</strong></p>
  
  <pre><code>Route::get('lang/{lang}', 'NotesController@changeLang')-&gt;where([ 'lang' =&gt; 'en|es']); 
  
  Route::group(['middleware' =&gt; ['web']], function () { 
  Route::get('notes', 'NotesController@index'); 
  Route::get('notes/create', 'NotesController@create'); 
  });
  </code></pre>
  
  <p><strong>\app\Http\Controllers\NotesController.php</strong></p>
  
  <pre><code>public function changeLang($lang)
  {
     session(['lang' =&gt; $lang]);
     return Redirect::back();
  }
  </code></pre>
  
  <p><strong>\app\Http\Middleware\LangMiddleware.php</strong></p>
  
  <pre><code>public function handle($request, Closure $next)
  {
     if (!empty(session('lang'))) {
       app()-&gt;setLocale(session('lang'));
     }
     return $next($request);
  }
  </code></pre>
  
  <p><strong>\resources\views\partials\errors.blade.php</strong></p>
  
  <pre><code>&lt;ul&gt;
     @foreach($errors-&gt;all() as $error)
        &lt;li&gt;{{ $error }}&lt;/li&gt;
     @endforeach
  &lt;/ul&gt;
  </code></pre>