Имам следния код:
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."
Но когато се опитам да създам своя .mo файл с Poedit, получавам тази грешка:
a format specification for argument 2, as in 'msgstr[0]', doesn't exist in 'msgid_plural'
Не разбирам какво не е наред тук. Това ли е начинът, по който наричам "_n", или нещо в моя преведен низ?
Виждам, че това по някакъв начин е свързано с маркерите за позиция на sprintf... че poedit очевидно не харесва, че имам $3%s в msgid_plurals, а не в msgid... но не трябва ли просто да превежда низа "както е"? Ще предам преведените низове на sprintf по време на изпълнение, като вмъкна подходящите съществителни на място...