-
-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Description
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],
];
}
smuuf and aryelgois
Metadata
Metadata
Assignees
Labels
No labels