File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
src/Folklore/LaravelLocale Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 5
5
6
6
class LocaleEventHandler
7
7
{
8
-
9
8
/**
10
9
* Handle user login events.
11
10
*/
12
11
public function onRouteMatched (RouteMatched $ event )
13
12
{
14
- $ app = app ();
15
- $ route = $ event ->route ;
16
- $ currentLocale = $ app ->getLocale ();
17
- $ action = $ route ->getAction ();
13
+ $ locale = app ()->getLocale ();
14
+ $ action = $ event ->route ->getAction ();
18
15
$ locales = config ('locale.locales ' );
19
- if (isset ($ action ['locale ' ]) && $ action ['locale ' ] !== $ currentLocale && in_array ($ action ['locale ' ], $ locales )) {
20
- $ app ->setLocale ($ action ['locale ' ]);
16
+ if (isset ($ action ['locale ' ]) && $ action ['locale ' ] !== $ locale && in_array ($ action ['locale ' ], $ locales )) {
17
+ app () ->setLocale ($ action ['locale ' ]);
21
18
}
22
19
}
23
20
24
- public function onLocaleChanged ($ currentLocale )
21
+ public function onLocaleChanged ($ locale )
25
22
{
26
- app ('locale.manager ' )->setLocale ($ currentLocale );
23
+ app ('locale.manager ' )->setLocale ($ locale );
27
24
}
28
25
29
26
public function onLocaleUpdated (LocaleUpdated $ event )
You can’t perform that action at this time.
0 commit comments