我正在使用库php-gettext
来解决 Google Cloud 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
s 并且现在无法更改我的整个项目以使用神秘的 ID,例如
ngettext("%d-correct-singular", "%d-correct-plural", $n)
在原始语言中处理相同的单数和复数形式的适当方法是什么?