The GetText class allows some variable interpolation in your translations. It is quite usefull when you need to insert some small dynamic strings into your translation whithout breaking it in two parts or more.
# english
msgid "welcome"
msgstr "Welcome ${name} you have ${n} mails !"
# french
msgid "welcome"
msgstr "Bienvenue ${name} vous avez recu ${n} messages !"To do this, the translator must know $name and $n before translating the text.
The setVar() method is used in that aim.
...
GetText::setVar("name", $userName);
GetText::setVar("n", $nbrMails);
echo GetText::gettext("welcome");If you have a lot of variables stored in an hashtable, you can set all of them using setVars($hash).
For security reasons, GetText can access only setted variables.