@@ -14,27 +14,27 @@ class TranslatableRoutesMacro {
1414 * Register the macro.
1515 * @return void
1616 */
17- public static function register () {
18- function registerRoutes ($ locale , Closure $ closure ) {
19- // $currentLocale = Translatable::getLocaleFromRequest();
20- $ fallbackLocale = config ('translatable.fallback_locale ' );
21- $ hideFallbackLocale = config ('translatable.hide_fallback_locale ' );
22-
23- $ attributes = [];
24- $ attributes ["middleware " ] = [TranslatableRoutesHandler::class];
25-
26- $ attributes ["as " ] = "$ {locale}. " ;
27- $ attributes ["prefix " ] = $ locale ;
28- Route::group ($ attributes , $ closure );
17+ public static function register () {
18+ if (!Route::hasMacro ('localized ' )) {
19+ function registerRoutes ($ locale , Closure $ closure ) {
20+ // $currentLocale = Translatable::getLocaleFromRequest();
21+ $ fallbackLocale = config ('translatable.fallback_locale ' );
22+ $ hideFallbackLocale = config ('translatable.hide_fallback_locale ' );
2923
30- if ($ hideFallbackLocale && $ locale === $ fallbackLocale ) {
3124 $ attributes = [];
3225 $ attributes ["middleware " ] = [TranslatableRoutesHandler::class];
26+
27+ $ attributes ["as " ] = "$ {locale}. " ;
28+ $ attributes ["prefix " ] = $ locale ;
3329 Route::group ($ attributes , $ closure );
30+
31+ if ($ hideFallbackLocale && $ locale === $ fallbackLocale ) {
32+ $ attributes = [];
33+ $ attributes ["middleware " ] = [TranslatableRoutesHandler::class];
34+ Route::group ($ attributes , $ closure );
35+ }
3436 }
35- }
36-
37- if (!Route::hasMacro ('localized ' )) {
37+
3838 Route::macro ('localized ' , function (Closure $ closure ) {
3939 $ locales = config ('translatable.locales ' );
4040 $ fallbackLocale = config ('translatable.fallback_locale ' );
0 commit comments