Using gettext
Single value
echo gettext( \"Hello, world!\\n\" );
Plurals
printf(ngett
What you are looking for is contexts for gettext
which solves ambiguities like your example. You can find information about in the documentation. Still the needed method pgettext
is not implemented in PHP so you might use the helper method stated in a user comment in the php documentation.
if (!function_exists('pgettext')) {
function pgettext($context, $msgid)
{
$contextString = "{$context}\004{$msgid}";
$translation = dcgettext('messages', contextString,LC_MESSAGES);
if ($translation == $contextString) return $msgid;
else return $translation;
}
}
In your case it would be
echo pgettext('mail', 'Letter');
echo pgettext('character', 'Letter');