gettext, how to handle homonyms?

后端 未结 4 1136
悲&欢浪女
悲&欢浪女 2021-02-20 11:36

Using gettext

Single value

echo gettext( \"Hello, world!\\n\" );

Plurals

printf(ngett         


        
4条回答
  •  青春惊慌失措
    2021-02-20 12:16

    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.

提交回复
热议问题