wordpress - a format specification for argument 2, as in 'msgstr[0]', doesn't exist in 'msgid_plural' -
i have following code:
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, editing it.', '%1$s %3$s not updated, 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 trash.', '%1$s %3$s moved trash.', $bulk_counts['trashed'], 'yosilose' ), $bulk_counts['trashed'], $this->single, $this->plural ), 'untrashed' => sprintf( _n( '%1$s %2$s restored trash.', '%1$s %3$s restored trash.', $bulk_counts['untrashed'], 'yosilose' ), $bulk_counts['untrashed'], $this->single, $this->plural ), ); return $bulk_messages; }
and in .po file have:
#, 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."
but when try create .mo file poedit, error:
a format specification argument 2, in 'msgstr[0]', doesn't exist in 'msgid_plural'
i don't what's wrong here. way call "_n", or in translated string?
i see somehow related sprintf position markers... poedit apparently doesn't have $3%s in msgid_plurals , not in msgid... shouldn't translate string "as is"? i'll pass translated strings sprintf @ runtime, inserting appropriate nouns in place...
thanks , regards.
it’s not poedit doesn’t it, it’s gettext msgfmt
tool — , way of doing plurals fails sanity checks. observed, reason must use same arguments in both msgid
, msgid_plural
. it.
if you’re wondering why, it’s because code ignores possibility languages may have more (or less!) 2 forms, singular , plural. slavic languages have 3, arabic has 6, japanese 1. code never work right these languages.
as case, gnu gettext manual discusses issue in detail: http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/plural-forms.html
Comments
Post a Comment