Reputation: 627
How I have to do for translate a string as this, where $user contains the user name?
$message = 'Hello ' . $user . ', how are you';
If I translate using the follow code, it don't works.
$message = $translator->translate('Hello ' . $user . ', how are you');
In my en_EN.po file I have:
msgid "Hello %s, how are you"
msgstr ""
In my es_ES.po file I have:
msgid "Hello %s, how are you"
msgstr "Hola %s, como estas"
Thanks in advance.
Upvotes: 2
Views: 1541
Reputation: 12809
Try this inside your view:
echo sprintf($this->translate("Hello %s, how are you"), $user);
Upvotes: 8