Skip to content

Commit 42a1b3d

Browse files
authored
Merge pull request #59 from nestordedios/patch-1
Set the right language on $lang variable
2 parents 487c64b + f77c27e commit 42a1b3d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/LabelsExtension.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,8 @@ public function twigL($label, $lang = false)
173173
/** @var Labels $labels */
174174
$labels = $app['labels'];
175175
$label = $labels->cleanLabel($label);
176-
$lang = mb_strtolower($lang);
176+
$lang = $this->isValidLanguage($lang) ? mb_strtolower($lang) : $this->getCurrentLanguage();
177177

178-
if (!$this->isValidLanguage($lang)) {
179-
$lang = $this->getCurrentLanguage();
180-
}
181178
$savedLabels = $labels->getLabels();
182179
$savedLabel = $savedLabels->getPath("$label/$lang");
183180

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

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

0 commit comments

Comments
 (0)