Translating dynamic string? $subject = $user . " commented on your " . $type;
Posted by jaochoo on August 18, 2010 at 7:39pm
I need to send email notifications like the following: $subject = $username . " commented on your " . $type; whereas $type is the content type, e. g. "blog", "gallery", etc.
Now I would like to send translated emails depending on the user's preferred language. So I also need to translate the $type, of course, otherwise I would get a mixed-language subject line. So my first idea was to use:
<?php
$subject = t("!username commented on your !type", array(
'!username' => $user->name,
'!type' => t($type)
));
?>