Skip to content

Commit

Permalink
Merge branch 'v2' of github.com:chinleung/laravel-multilingual-routes…
Browse files Browse the repository at this point in the history
… into v2
  • Loading branch information
chinleung committed Jul 27, 2020
2 parents 7913270 + 9d7698a commit e1bc7fa
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/MultilingualRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,10 @@ protected function generatePrefixForLocale(string $key, string $locale): ?string
protected function generateUriFromKey(string $key, string $locale): string
{
if ($key == '/') {
return $this->shouldNotPrefixLocale($locale) ||
$this->shouldNotPrefixDefaultHome($locale) ? '/' : "/$locale";
return $this->shouldNotPrefixHome($locale) ? '/' : "/{$locale}";
}

return Lang::has("routes.{$key}")
return Lang::has("routes.{$key}", $locale)
? trans("routes.{$key}", [], $locale)
: $key;
}
Expand Down Expand Up @@ -230,7 +229,19 @@ protected function shouldNotPrefixLocale(string $locale): bool
}

/**
* Verify if we should not prefix the default Home Route.
* Verify if we should not prefix the home page.
*
* @param string $locale
* @return bool
*/
protected function shouldNotPrefixHome(string $locale): bool
{
return $this->shouldNotPrefixLocale($locale)
|| $this->shouldNotPrefixDefaultHome($locale);
}

/**
* Verify if we should not prefix the home page.
*
* @param string $locale
* @return bool
Expand Down

0 comments on commit e1bc7fa

Please sign in to comment.