From 234e6eea03a6c13f084053ac8fb4291a3afa5cbe Mon Sep 17 00:00:00 2001 From: Justijn Depover Date: Fri, 26 Mar 2021 13:49:25 +0100 Subject: [PATCH] all configs work --- src/LocalizedRoutesServiceProvider.php | 4 ++++ src/Macros/LocalizedRoutesMacro.php | 5 +++++ src/Middleware/RedirectLocale.php | 4 ++++ 3 files changed, 13 insertions(+) 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'))) {