Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Illuminate/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ protected function getLine($namespace, $group, $locale, $item, array $replace)
if (is_string($line)) {
return $this->makeReplacements($line, $replace);
} elseif (is_array($line) && count($line) > 0) {
foreach ($line as $key => $value) {
$line[$key] = $this->makeReplacements($value, $replace);
}
array_walk_recursive($line, function (&$value, $key) use ($replace) {
$value = $this->makeReplacements($value, $replace);
});

return $line;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Translation/TranslationTranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public function testGetMethodProperlyLoadsAndRetrievesItem()
$this->assertSame('foo', $t->get('foo::bar.foo'));
}

public function testGetMethodProperlyLoadsAndRetrievesArrayItem()
{
$t = new Translator($this->getLoader(), 'en');
$t->getLoader()->shouldReceive('load')->once()->with('en', '*', '*')->andReturn([]);
$t->getLoader()->shouldReceive('load')->once()->with('en', 'bar', 'foo')->andReturn(['foo' => 'foo', 'baz' => 'breeze :foo', 'qux' => ['tree :foo', 'breeze :foo', 'beep' => ['rock' => 'tree :foo']]]);
$this->assertEquals(['foo' => 'foo', 'baz' => 'breeze bar', 'qux' => ['tree bar', 'breeze bar', 'beep' => ['rock' => 'tree bar']]], $t->get('foo::bar', ['foo' => 'bar'], 'en'));
$this->assertSame('breeze bar', $t->get('foo::bar.baz', ['foo' => 'bar'], 'en'));
$this->assertSame('foo', $t->get('foo::bar.foo'));
}

public function testGetMethodForNonExistingReturnsSameKey()
{
$t = new Translator($this->getLoader(), 'en');
Expand Down