Skip to content

Commit

Permalink
Merge pull request #59 from nestordedios/patch-1
Browse files Browse the repository at this point in the history
Set the right language on $lang variable
  • Loading branch information
bobdenotter authored Dec 5, 2017
2 parents 487c64b + f77c27e commit 42a1b3d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/LabelsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ public function twigL($label, $lang = false)
/** @var Labels $labels */
$labels = $app['labels'];
$label = $labels->cleanLabel($label);
$lang = mb_strtolower($lang);
$lang = $this->isValidLanguage($lang) ? mb_strtolower($lang) : $this->getCurrentLanguage();

if (!$this->isValidLanguage($lang)) {
$lang = $this->getCurrentLanguage();
}
$savedLabels = $labels->getLabels();
$savedLabel = $savedLabels->getPath("$label/$lang");

Expand All @@ -187,7 +184,7 @@ public function twigL($label, $lang = false)
}

// If we're automatically saving new/missing labels, add it to the JSON file
if ($config->isAddMissing() && !$savedLabels->hasItem($label)) {
if ($config->isAddMissing() && $this->isValidLanguage($lang) && !$savedLabels->hasItem($label)) {
$labels->addLabel($label);
}

Expand Down

0 comments on commit 42a1b3d

Please sign in to comment.