Skip to content

Commit

Permalink
Fixes #2932 : Fix Translation key separated by dot
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed May 5, 2020
1 parent 65f0a0e commit f9cab40
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions system/Language/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public function getLine(string $line, array $args = [])
$current = $this->language[$this->locale][$file] ?? null;
}

if (isset($current[$row][substr($parsedLine, strlen($row) + 1)]))
{
$output = $current[$row][substr($parsedLine, strlen($row) + 1)];
break;
}

$output = $current[$row] ?? null;
if (is_array($output))
{
Expand Down
3 changes: 3 additions & 0 deletions tests/_support/Language/en/Foo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
'bar' => 'Foo Bar Translated',
'bar.min_length1' => 'The {field} field is very short.',
'bar.min_length2' => 'Supplied value ({value}) for {field} must have at least {param} characters.',
'bar' => [
'min.length' => 'The {field} field is very short.',
],
];
9 changes: 9 additions & 0 deletions tests/system/Language/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,13 @@ 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']));
$this->assertEquals('The fieldname field is very short.', $lang->getLine('Foo.bar.min.length', ['field' => 'fieldname']));
}

}

0 comments on commit f9cab40

Please sign in to comment.