简体   繁体   中英

xgettext won't scan plural form

I use Poedit for my gettext i18n and that works fine. I use ZF2 where there are view helpers to integrate the translations. One is translate , the other translatePlural .

Usage:

<?php echo $this->translate('Welcome') ?>
<?php echo $this->translatePlural('Item', 'Items', $number) ?>

In Poedit I add the keywords translate and translatePlural . The normal translations work fine, but for the plural forms, only the "Item" is found (and not the "Items"). Just for testing purposes, I replaced the $this->translatePlural() call with ngettext() , but I end up with the same result. My conclusion: (my version of) Poedit is unable to scan plural forms.

What should I enter as keyword to let Poedit scan the second string as well?

After some further search, I stumbled upon the syntax [function]:1,2 . That did the trick for me. I have now identified these two functions as keywords for Poedit as follows:

translate
translatePlural:1,2

And now my second argument is scanned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM