diff --git a/src/LocalizedRoutesServiceProvider.php b/src/LocalizedRoutesServiceProvider.php index ec57499..1c72343 100644 --- a/src/LocalizedRoutesServiceProvider.php +++ b/src/LocalizedRoutesServiceProvider.php @@ -42,6 +42,10 @@ private function registerMacros() private function determineAppLocale() { + if (! config('localized-routes.auto_detect_locales')) { + return; + } + $locale = app()->request->segment(1); if (array_key_exists($locale, config('localized-routes.locales'))) { diff --git a/src/Macros/LocalizedRoutesMacro.php b/src/Macros/LocalizedRoutesMacro.php index 7c90733..b910c49 100644 --- a/src/Macros/LocalizedRoutesMacro.php +++ b/src/Macros/LocalizedRoutesMacro.php @@ -10,6 +10,11 @@ class LocalizedRoutesMacro public static function register() { Route::macro('localized', function ($callback) { + if (! config('localized-routes.enable_localized_routes')) { + $callback(); + return; + } + $locales = config('localized-routes.locales'); foreach ($locales as $abbreviation => $locale) { diff --git a/src/Middleware/RedirectLocale.php b/src/Middleware/RedirectLocale.php index c9294f4..10109fe 100644 --- a/src/Middleware/RedirectLocale.php +++ b/src/Middleware/RedirectLocale.php @@ -8,6 +8,10 @@ class RedirectLocale { public function handle($request, Closure $next) { + if (! config('localized-routes.auto_redirect_to_localized_route')) { + return $next($request); + } + $locale = $request->segment(1); if (! array_key_exists($locale, config('localized-routes.locales'))) {