@@ -17,16 +17,21 @@ public function handle($request, Closure $next)
1717 {
1818 $ site = Site::current ();
1919
20- // Dates, Carbon, etc expect the full locale. (eg. "fr_FR" or whatever is
20+ // PHP date-formatting functions expect the full locale. (eg. "fr_FR" or whatever is
2121 // installed on your actual server. You can check by running `locale -a`).
2222 // We'll save the original locale so we can reset it later. Of course,
2323 // you can get the locale by calling the setlocale method. Logical.
2424 $ originalLocale = setlocale (LC_TIME , 0 );
2525 setlocale (LC_TIME , $ site ->locale ());
2626
27- // Use the site's lang for translations.
28- $ originalTranslatorLocale = app ('translator ' )->getLocale ();
29- app ('translator ' )->setLocale ($ site ->lang ());
27+ // The sites lang is used for your translations.
28+ // e.g. If you set your lang to "fr" it'll look for "fr" translations.
29+ // If not explicitly set, a site's lang will fall back to the "short locale"
30+ // e.g. If your site's locale is "fr_FR", the lang would be "fr".
31+ // Note that Carbon does also use this for some things.
32+ // Again, we'll save the original locale so we can reset it later.
33+ $ originalAppLocale = app ()->getLocale ();
34+ app ()->setLocale ($ site ->lang ());
3035
3136 // Get original Carbon format so it can be restored later.
3237 $ originalToStringFormat = $ this ->getToStringFormat ();
@@ -43,7 +48,7 @@ public function handle($request, Closure $next)
4348 // Reset everything back to their originals. This allows everything
4449 // not within the scope of the request to be the "defaults".
4550 setlocale (LC_TIME , $ originalLocale );
46- app (' translator ' )->setLocale ($ originalTranslatorLocale );
51+ app ()->setLocale ($ originalAppLocale );
4752 Date::setToStringFormat ($ originalToStringFormat );
4853
4954 return $ response ;
0 commit comments