Translation of standalone latte application

Notice: This thread is very old.
mrataja
Member | 57
+
+1
-

Hi all, I have simple web with now mvc architecture, using only form, mail, latte and tracy from Nette framework. Can you help me with setup of translator? I cant figure it out.

I am going stright forward as documentation says. How to inject language and translation file?

$latte = new \Latte\Engine;
$latte->setTempDirectory('/tmp');
$template = new \Nette\Templating\FileTemplate;
$template->setTranslator(new MyTranslator);
$template->registerFilter($latte);
$template->setFile('mail.latte');
$template->rezervace = $rezervace;
$template->emailTo = EMAIL_TO;
$template->emailFrom = EMAIL_FROM;
$template->serverName = SERVER_NAME;
$mail->setHTMLBody($template);
$mailer = new \Nette\Mail\SendmailMailer;
$mailer->send($mail);

In mail.latte is this sample
<p><strong>{_'Zadané údaje'}:</strong></p>

amik
Member | 118
+
+1
-

there is no setTranslator() method in Latte\Engine, it is a method of Nette\Bridges\ApplicationLatte.
Get inspired by https://api.nette.org/…ate.php.html#… on how to set up translator on Latte\Engine.

P.S. next time when you ask for something, tell how exactly your code doesn't work. It was just my raw (and probably correct) guess that you get error when calling $template->setTranslator:)