/**
  * @param Latte\Template|\Nette\Bridges\ApplicationLatte\Template|\Nette\Templating\Template $template
  * @param ITranslator $translator
  */
 private static function overrideTemplateTranslator($template, ITranslator $translator)
 {
     if ($template instanceof Latte\Template) {
         $template->getEngine()->addFilter('translate', array(new TemplateHelpers($translator), 'translate'));
     } elseif ($template instanceof \Nette\Bridges\ApplicationLatte\Template) {
         $template->getLatte()->addFilter('translate', array(new TemplateHelpers($translator), 'translate'));
     } elseif ($template instanceof \Nette\Templating\Template) {
         $template->registerHelper('translate', array(new TemplateHelpers($translator), 'translate'));
     }
     return $translator;
 }