diff --git a/src/Helper/Translator.php b/src/Helper/Translator.php index a399c5a7..f5ae847b 100644 --- a/src/Helper/Translator.php +++ b/src/Helper/Translator.php @@ -133,7 +133,7 @@ public function __invoke($messageid = null) public function setTranslator($translator) { if ($translator instanceof TranslationAdapter) { - $this->translator = $translate; + $this->translator = $translator; } else if ($translator instanceof Translation) { $this->translator = $translator->getAdapter(); } else { diff --git a/test/Helper/TranslatorTest.php b/test/Helper/TranslatorTest.php index 5ce00183..bc13276f 100644 --- a/test/Helper/TranslatorTest.php +++ b/test/Helper/TranslatorTest.php @@ -243,4 +243,24 @@ public function testTranslationWithoutTranslator() $result = $this->helper->__invoke("test %1\$s", "100"); $this->assertEquals('test 100', $result); } + + /** + * @group ZF2-140 + */ + public function testSetTranslatorWithTranslationAdapter() + { + $trans = new Translator\Adapter\ArrayAdapter(array('one' => 'eins', "two %1\$s" => "zwei %1\$s", + "three %1\$s %2\$s" => "drei %1\$s %2\$s", 'vier%ig' => 'four%'), 'de'); + $this->helper->setTranslator($trans); + } + + /** + * @group ZF2-140 + */ + public function testSetTranslatorWithTranslation() + { + $trans = new Translator\Translator('arrayAdapter', array('one' => 'eins', "two %1\$s" => "zwei %1\$s", + "three %1\$s %2\$s" => "drei %1\$s %2\$s", 'vier%ig' => 'four%'), 'de'); + $this->helper->setTranslator($trans); + } }