Version: 3.0.18
Bug Description
The Nette\Utils\Translator interface allows returning both string|\Stringable.
https://github.com/nette/utils/blob/736c567e257dbe0fcf6ce81b4d6dbe05c6899f96/src/Translator.php#L21
But the Latte's translate filter which is ultimately used when tags {translate} and {_} are compiled forces the return value of type string.
|
'translate' => fn(Latte\Runtime\FilterInfo $fi, ...$args): string => $this->translator |
This causes an error when returning results of translation as an \Nette\Utils\Html objects (related to nette/utils#231).
Possible Solution
public function getFilters(): array
{
return [
'translate' => fn(Latte\Runtime\FilterInfo $fi, ...$args): string|\Stringable => $this->translator
? ($this->translator)(...$args)
: $args[0],
];
}
Version: 3.0.18
Bug Description
The
Nette\Utils\Translatorinterface allows returning bothstring|\Stringable.https://github.com/nette/utils/blob/736c567e257dbe0fcf6ce81b4d6dbe05c6899f96/src/Translator.php#L21
But the Latte's
translatefilter which is ultimately used when tags{translate}and{_}are compiled forces the return value of type string.latte/src/Latte/Essential/TranslatorExtension.php
Line 53 in bd46751
This causes an error when returning results of translation as an
\Nette\Utils\Htmlobjects (related to nette/utils#231).Possible Solution