Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
If locale is null when creating a new instance use fallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Oct 29, 2014
1 parent 78d5eb2 commit 8972405
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Vinkla/Translator/TranslatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ private function getTranslation($locale = null, $fallback = true)
$this->translatorInstance = new $this->translator();
}

$locale = $locale ?: $this->getLocale();

// Fetch the translation by their locale.
$translation = $this->getTranslationByLocale($locale);
$translation = $this->getTranslationByLocale($locale ?: $this->getLocale());

if ($translation)
{
Expand All @@ -79,7 +77,7 @@ private function getTranslation($locale = null, $fallback = true)

// If fallback is set to false, create a new instance.
return $this->newTranslatorInstance([
$this->getLocaleKey() => $locale
$this->getLocaleKey() => $this->getLocale() ?: $this->getFallback()
]);
}

Expand Down

0 comments on commit 8972405

Please sign in to comment.