Using gettext
Single value
echo gettext( \"Hello, world!\\n\" );
Plurals
printf(ngett
I have made a package to provide an easy solution to the lack of pgettext in PHP.
See here.
You need to install the package with composer require datalinx/gettext-context
and then you can use
echo pgettext('Mail', 'Letter'); // Echoes: письмо
echo pgettext('Character', 'Letter'); // Echoes: буква
Plural and domain override functions (npgettext, dpgettext, dnpgettext) are also implemented.