In Magento, performing a translation in modules involves invoking a helper and calling its translation function, E.G.
Mage::helper("core")->__("This is a string to translate");
However, I haven't found any resources online regarding translating strings that contain variables. From past experience, I know that this is usually handled by using a token inside the string, with token replacements defined using additional arguments.
For example, GNU gettext's manual recommends using format strings for translation:
sprintf (gettext ("Hello %s!"), username ());
While Yii Framework has a similar, but subtly different format:
Yii::t("default", "Hello {username}!", array("username"=>username()));
From a quick grep of Magento's core files, it looks like Magento uses C-style format strings, for example in Mage_Adminhtml_Block_Api_User_Edit::getHeaderText the following can be found:
return Mage::helper('adminhtml')->__("Edit User '%s'", $this->escapeHtml(Mage::registry('api_user')->getUsername()));
But I would like further confirmation or advice since online documentation is quite sparse.