Translation of Zend_Translate Email Templates

Using zend framework, i, like many others, send emails. Now I use the presentation template for writing. fx welcome.phtml welcome to my website

Hi <?php print $this->name; ?><br />
Welcome to my site.<br /><br />

Regards <?php print $this->siteName; ?>

Now translating this would be a few ways. I could put the whole wall of text in translate () ;? > All html will follow, so this is a dumb idea.

Secondly, I can place each email template in the language folder, fx./languages/en_en/emails/welcome.phtml and translate the whole file, html will still follow, but it will be easier. The disadvantage is that if I have 40 languages, and html to change the template, I have to edit 40 files.

Thirdly, I can put each line in print $ this-> translate (); but it will give a lot of lines.

Are there any other ways? Or what is the best way to do this?

A small question: what should I do if I have a wall with text with a little formatting? maybe 10 lines of text, and some words are in bold and a few
? The whole wall of text in translation () ;? >?

Hi

+5
source share
1 answer

Zend_Translate supports placeholders, so you can also try to create messages in the translation source, for example:

// NOTE: this is only wireframe, working code depends on your translation adapter format
"message-id" => "Hi %s<br /> Welcome to my site.<br /><br /> Regards %s"     // en
"message-id" => "Hallo %s <br/>Willkommen auf meiner Website.<br/><br/>Regards %s" // de

and if your data:

name => 'John'
siteName => 'MySite.com'

you can just call the translation method

$mailBody = $this->translate('message-id', $this->name, $this->siteName);

and "% s" will be replaced with actual data

Hi John<br /> Welcome to my site.<br /><br /> Regards MySite.com
+5
source

All Articles