i want add html symfony 2 translation. way know phrases in application translated , not. found in "symfony\component\translation\translator.php" function "trans". want add in function return, example "< /br>":
/** * {@inheritdoc} * * @api */ public function trans($id, array $parameters = array(), $domain = null, $locale = null) { if (null === $locale) { $locale = $this->getlocale(); } else { $this->assertvalidlocale($locale); } if (null === $domain) { $domain = 'messages'; } if (!isset($this->catalogues[$locale])) { $this->loadcatalogue($locale); } return strtr($this->catalogues[$locale]->get((string) $id, $domain)."</br>", $parameters); } the issue when run application i'm getting example "tag< / b r>" (i have add spaces because in normal way doesn't show here. html doesn't interprate html code string. there way achieve want ? maybe in other way ?
this happens because have twig escaper extension active. extension adds automatic output escaping twig, defines autoescape tag , raw filter.
so think best option got here define new twig extension let translate html strings without having repeat myvar|raw each time.
to see how possible create new twig extension please check docs here.
use same extension when escaping js , there should no need use else in php controllers. that's because escaping done @ twig level. remember declare new twig filter safe avoid automatic escaping again:
$filter = new twig_simplefilter('nl2br', 'nl2br', array('is_safe' => array('html'))); if need processing requested data can track strings being requested , not declare new service proxy symfony translation one. twig extension can use same service. way can converge requests 1 single service.
here few useful links you:
Comments
Post a Comment