How can I add support for plural forms in this Yii class:

http://code.google.com/p/yii/source/browse/tags/1.1.8/framework/i18n/gettext/CGettextPoFile.php

?

Right now the pattern is

     $pattern='/(msgctxt\s+"(.*?(?<!\\\\))")?'
            . '\s+msgid\s+"(.*?(?<!\\\\))"'
            . '\s+msgstr\s+"(.*?(?<!\\\\))"/';

which corresponds to something like this (inside the po file):

msgid "Edit Comments"
msgstr "Modifier les commentaires"

But a plural definition looks like this:

msgid "%s comment"
msgid_plural "%s comments"
msgstr[0] "%s commentaire"
msgstr[1] "%s commentaires"

The problem is that depending on the language, there can be msgstr[3], msgstr[4] ...

有帮助吗?

解决方案

I think it better to look for a PHP gettext library that already has plurals and msgctx support.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top