Skip to content

Commit

Permalink
Merge pull request #15 from litstack/feat/translate-routes-if-needed
Browse files Browse the repository at this point in the history
Only translate routes when app is translatable
  • Loading branch information
jannescb committed Oct 13, 2021
2 parents f7940fa + b919b32 commit ccb8c69
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Localize/LocalizeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ protected function registerTranslatorMacro()
});

$this->app->afterResolving('lit.pages.routes', function ($routes) {
$routes->extend(function (Route $route) {
$route->translator(function ($locale, $slug = null) {
$slug = Page::current()->translate($locale)->t_slug;
if (lit()->isAppTranslatable()) {
$routes->extend(function (Route $route) {
$route->translator(function ($locale, $slug = null) {
$slug = Page::current()->translate($locale)->t_slug;

return ['slug' => $slug];
return ['slug' => $slug];
});
});
});
}
});
}

Expand Down

0 comments on commit ccb8c69

Please sign in to comment.