Skip to content

Commit

Permalink
Also translate fallback language for current model
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed Jan 16, 2020
1 parent 8fef15a commit 3f7279a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Model/Multilingual.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public function getAlias($language, $aliasColumnName = 'alias')
{
// Do not load any translation if already target language
$langColumn = static::getLangColumn();
$fallbackLang = static::getFallbackLanguage();

if ($language === $fallbackLang && $this->{$langColumn} === '') {
return $this->{$aliasColumnName};
}

if ($language === $this->{$langColumn}) {
return $this->{$aliasColumnName};
Expand All @@ -56,8 +61,6 @@ public function getAlias($language, $aliasColumnName = 'alias')

if (null === $translatedModel) {
// Get fallback
$fallbackLang = static::getFallbackLanguage();

if ($language === $fallbackLang) {
return $this->{$aliasColumnName};
}
Expand Down

0 comments on commit 3f7279a

Please sign in to comment.