Skip to content

Commit

Permalink
Merge pull request #2938 from samsonasik/fix-2932
Browse files Browse the repository at this point in the history
Fixes #2932 : Fix Translation key separated by dot
  • Loading branch information
lonnieezell authored May 6, 2020
2 parents 2e95838 + 72e03e7 commit 10207eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions system/Language/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ public function getLine(string $line, array $args = [])
}
}

if ($output === null)
{
$row = current(explode('.', $parsedLine));
$key = substr($parsedLine, strlen($row) + 1);
$output = $this->language[$this->locale][$file][$row][$key] ?? null;
}

if ($output === null && strpos($this->locale, '-'))
{
[$locale] = explode('-', $this->locale, 2);
Expand Down
8 changes: 8 additions & 0 deletions tests/system/Language/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,12 @@ public function testLanguageNestedArrayDefinition()
$this->assertEquals('e', $lang->getLine('Nested.a.b.c.d'));
}

public function testLanguageKeySeparatedByDot()
{
$lang = new SecondMockLanguage('en');
$lang->loadem('Foo', 'en');

$this->assertEquals('The fieldname field is very short.', $lang->getLine('Foo.bar.min_length1', ['field' => 'fieldname']));
}

}

0 comments on commit 10207eb

Please sign in to comment.