我有以下代码:
public function bulk_updated_messages ( $bulk_messages = array(), $bulk_counts = array() ) {
$bulk_messages[ $this->post_type ] = array(
'updated' => sprintf( _n( '%1$s %2$s updated.', '%1$s %3$s updated.', $bulk_counts['updated'], 'yosilose' ), $bulk_counts['updated'], $this->single, $this->plural ),
'locked' => sprintf( _n( '%1$s %2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $bulk_counts['locked'], 'yosilose' ), $bulk_counts['locked'], $this->single, $this->plural ),
'deleted' => sprintf( _n( '%1$s %2$s permanently deleted.', '%1$s %3$s permanently deleted.', $bulk_counts['deleted'], 'yosilose' ), $bulk_counts['deleted'], $this->single, $this->plural ),
'trashed' => sprintf( _n( '%1$s %2$s moved to the Trash.', '%1$s %3$s moved to the Trash.', $bulk_counts['trashed'], 'yosilose' ), $bulk_counts['trashed'], $this->single, $this->plural ),
'untrashed' => sprintf( _n( '%1$s %2$s restored from the Trash.', '%1$s %3$s restored from the Trash.', $bulk_counts['untrashed'], 'yosilose' ), $bulk_counts['untrashed'], $this->single, $this->plural ),
);
return $bulk_messages;
}然后在我的.po文件中有:
#, php-format
msgid "%1$s %2$s updated."
msgid_plural "%1$s %3$s updated."
msgstr[0] "%1$s %2$s actualizado/a."
msgstr[1] "%1$s %3$s actualizados/as."但是,当我尝试用Poedit创建我的.mo文件时,我得到了以下错误:
a format specification for argument 2, as in 'msgstr[0]', doesn't exist in 'msgid_plural'我不明白这里出了什么问题。这是我称之为"_n“的方式,还是我翻译的字符串中的什么东西?
我知道这和斯普林特的位置标志有关.显然,我不喜欢msgid_plurals的3%,而不是msgid.但不应该仅仅翻译字符串“原样”吗?我将在运行时将翻译的字符串传递给sprintf,插入适当的名词.
发布于 2014-11-20 09:32:15
这并不是Poedit不喜欢它,而是gettext msgfmt工具--而且您的多义性检查方法失败了。正如您所观察到的,原因是您必须在msgid和msgid_plural中使用相同的参数。就这么做。
如果您想知道为什么,这是因为您的代码忽略了某些语言可能有更多(或更少!)不只是两种形式,单数和复数。斯拉夫语有3种,阿拉伯语有6种,日语只有1种。
就像通常的情况一样,gettext手册详细讨论了这个问题:node/Plural-forms.html
https://stackoverflow.com/questions/27021037
复制相似问题