Why is Laravel's App::getLocale() method inconsistent?
<p>I'm using 2 languages in my Laravel 5.2 app. There is a simple password-reminder page I'm implementing currently, and for reasons unknown to me I have problems in sending the new-password email in the correct language. </p>

<p>Let's say I see the page in German. In the view of the page, I echo 2 values, using Facades:</p>

<pre><code>echo App::getLocale();
echo Session::get('locale');
</code></pre>

<p>The page is served in German, so <strong>both</strong> values echo <code>de</code>.</p>

<p>Now, I enter an email address into the form and submit it. The input gets to a controller method and calls a library to send a new password to the user:</p>

<pre><code>public function resetPassword() {
    // Validate the input, retrieve the user...    

    Mailer::sendNewPasswordEmail($user); // Call to the library sending emails
}
</code></pre>

<p>Finally, in the library, I var_dump the same 2 values, like this:</p>

<pre><code>public static function sendNewPasswordEmail($user) {
    var_dump(App::getLocale());
    var_dump(Session::get('locale'));
    die;
}
</code></pre>

<p>In this case, <code>Session::get('locale')</code> still equals <code>de</code>, but <code>App::getLocale()</code> shows <code>en</code>.</p>

<p>Why, why, why?</p>

<p>In my email template, I'm using the Blade's <code>@lang()</code> directive. As far as I know, the directive checks the application locale to determine which translation to serve. In my case, the email is being sent always in English and I have no clue why <code>App::getLocale()</code> returns a different value in the view and during the next POST request I'm making.</p>

<p>This is not the first time this happens, btw. At times is seems that views "know" more about the actual application locale, than the controllers, models or libraries. Confusing.</p>

<p>Ideas?</p>