Skip to content

Commit

Permalink
all configs work
Browse files Browse the repository at this point in the history
  • Loading branch information
justijndepover committed Mar 26, 2021
1 parent 6314ab7 commit 234e6ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/LocalizedRoutesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))) {
Expand Down
5 changes: 5 additions & 0 deletions src/Macros/LocalizedRoutesMacro.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/Middleware/RedirectLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))) {
Expand Down

0 comments on commit 234e6ee

Please sign in to comment.