function testInterpolation()
 {
     $t = new DummyTranslator();
     $t->setTranslation('foo ${someObject/method} bar ${otherObject/method} buz', 'ok ${someObject/method} ok ${otherObject/method} ok');
     $tpl = $this->newPHPTAL('input/i18n-attributes-05.html');
     $tpl->setTranslator($t);
     $tpl->someObject = array('method' => 'good');
     $tpl->otherObject = array('method' => 'great');
     $res = normalize_html($tpl->execute());
     $exp = normalize_html_file('output/i18n-attributes-05.html');
     $this->assertEquals($exp, $res);
 }
Esempio n. 2
0
 function testTranslateChainStructureExistsTranslated()
 {
     $tpl = $this->newPHPTAL();
     $tpl->setTranslator($t = new DummyTranslator());
     $t->setTranslation('<foo> value', '<foo> translated');
     $tpl->foo = '<foo> value';
     $tpl->setSource('<div i18n:translate="structure foo | string:&lt;bar> translated">not translated</div>');
     $this->assertEquals('<div><foo> translated</div>', $tpl->execute());
 }
Esempio n. 3
0
 function testFillWithi18n()
 {
     $tpl = $this->newPHPTAL();
     $tpl->setSource('
     <div metal:use-macro="m1"><p metal:fill-slot="test-slot"><span i18n:translate="">translatemetoo</span></p></div>
     <div metal:define-macro="m1">
         <p metal:define-slot="test-slot" i18n:attributes="title" title="translateme">test</p>
     </div>
     ');
     $tr = new DummyTranslator();
     $tr->setTranslation("translateme", "translatedyou");
     $tr->setTranslation("translatemetoo", "translatedyouaswell");
     $tpl->setTranslator($tr);
     $this->assertEquals(normalize_html('<div><p><span>translatedyouaswell</span></p></div>'), normalize_html($tpl->execute()), $tpl->getCodePath());
 }