Skip to content

Commit db3e6cb

Browse files
committed
Template: better error message when Translator is not set
1 parent 190f630 commit db3e6cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Bridges/ApplicationLatte/TemplateFactory.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public function createTemplate(UI\Control $control = NULL)
8484
return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
8585
});
8686

87+
if (!isset($latte->getFilters()['translate'])) {
88+
$latte->addFilter('translate', function () {
89+
throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
90+
});
91+
}
92+
8793
// default parameters
8894
$template->control = $template->_control = $control;
8995
$template->presenter = $template->_presenter = $presenter;

0 commit comments

Comments
 (0)