我正在使用库php-gettext来解决谷歌云AppEngine上缺少的gettext扩展。单数和复数形式在英语中相同,但在其他语言中不同。
ngettext("%d correct", "%d correct", $n)西班牙语的翻译应该是
"%d correcto" (singular)
"%d correctos" (plural)表示给出正确答案的数量。
但这给了我一个错误,因为单数msgid与复数msgid完全相同。即使是允许在翻译中添加上下文的函数dngettext()也不能做到这一点:
dngettext("Number of correct answers", "%d correct", "%d correct", $n)它会在gettext库中触发警告和错误:
PHP Notice: Undefined offset: -1
PHP Parse error: syntax error, unexpected '!=' (T_IS_NOT_EQUAL)
PHP Notice: Undefined variable: number
PHP Warning: Missing argument 4 for gettext_reader::npgettext()我正在使用英语句子作为msgid,现在不能将我的整个项目改为使用神秘的I,例如
ngettext("%d-correct-singular", "%d-correct-plural", $n) 在原始语言中处理相同的单数和复数形式的适当方式是什么?
发布于 2016-12-17 23:22:30
我刚刚发现它实际上是gettext库中的一个已知错误:https://bugs.launchpad.net/php-gettext/+bug/1415873?comments=all
您需要手动修复此错误,才能正确使用ngettext函数。
这个问题与一般的gettext扩展无关。
https://stackoverflow.com/questions/41199724
复制相似问题