Confusion for translations in Latte 3

SPu
Member | 2
+
0
-

Either I am misunderstanding the documentation or there is a bug in the new release.

Code in the Latte template is as follows:

<li><a href="#Home">{_'Home'}</a></li>

And the translators have been registered in the PHP code with following:

$this->latte->addFilter('translate', function($string) {
	// Calls the translator here
});

This setup works fine with Latte 2.11.3, but throws and error for the translation with Latte 3.0.

Updating the template code to either “{translate}Home{/translate}” or “{=‘Home’|translate}” will make it work. Documentation says the single underscore method should be fine (https://doc.nette.org/…on/templates#…).

To my understanding the underscore template call should be still available in v.3.0, with the addition of the new {translate}xx{/translate} tag, to which I do not like to migrate since that is a hell of a job.

Something I am missing?

Last edited by SPu (2022-05-26 18:03)

Rick Strafy
Nette Blogger | 81
+
0
-

Hi, https://latte.nette.org/…-from-latte2#… it looks like addFilter method is now addFilterLoader

David Grudl
Nette Core | 8218
+
0
-

Do you use Latte standalone or as part of Nette with presenters?

SPu
Member | 2
+
0
-

Heya, Latte is used alone as part of our own framework, other components of Nette are not used.

David Grudl
Nette Core | 8218
+
0
-

Okay, I'll fix it.

David Grudl
Nette Core | 8218
+
+2
-

It already works in Latte 3.0.1

https://latte.nette.org/en/develop#…