Skip to content

Commit

Permalink
Fixes combination of cached routes and hide default locale in URL (#651)
Browse files Browse the repository at this point in the history
* Fixed loading of translated cached routes in console context

Used to only work for requests, since it depended on the request segment to read the locale. Now, LaravelLocalization's current locale is used.

* Fixed route cache and list command for Laravel 5.8

* Fixed hide default locale in URL flag not working when routes are cached

This fix ensures that no locale string is returned from `::setLocale()`, even when routes are cached, for the default locale, when this config flag is enabled.
  • Loading branch information
czim authored and Marc Cámara committed Sep 20, 2019
1 parent d45b8be commit d228a61
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Mcamara/LaravelLocalization/LaravelLocalization.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public function setLocale($locale = null)

if (!empty($this->supportedLocales[$locale])) {
$this->currentLocale = $locale;

if ($locale === $this->defaultLocale && $this->hideDefaultLocaleInURL()) {
$locale = null;
}

} else {
// if the first segment/locale passed is not valid
// the system would ask which locale have to take
Expand Down

0 comments on commit d228a61

Please sign in to comment.