Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active August 29, 2015 14:01
Show Gist options
  • Save GaryJones/bb4bb12d078a397e9ad9 to your computer and use it in GitHub Desktop.
Save GaryJones/bb4bb12d078a397e9ad9 to your computer and use it in GitHub Desktop.
POEdit Keyword Header Value questions

Thanks for looking :-)

I was looking at some typical POEdit keyword header value in WordPress plugins and themes - e.g.:

'__;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n';

There's several things wrong here, but the oddity is:

_c,_nc:4c,1,2

_c( $string ) and _nc( $string, $plural ) are both deprecated anyway, but:

  1. They are split by a comma, instead of a semi-colon. Is this allowed, or is that a typo?
  2. There's not four arguments, so that 4c, is completely wrong and shouldn't be there?
  3. For _nx( $string, $plural, $number, $context ) the keyword value is given as _nx:4c,1,2. Should that be _nx:1,2,4c or does the order not matter?
  4. Should this (and all header values in a pot) end with \n for a new line?

Thanks!

@vslavik
Copy link

vslavik commented May 8, 2014

  1. Typo, presumably. Poedit splits the specifiers with ;, everything within that is xgettext syntax for the keyword argument.
  2. Looks like that. See https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html for the documentation of the syntax.
  3. I think the order doesn't matter, but am not sure. See xgettext docs or experiment with it.
  4. See PO format docs at http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html#sec-poheader — the headers have the form of "Name: value\n". Your example seems wrong, the end single quote is wrong (should be double quote); the ; at the end is not needed (but harmless).

@GaryJones
Copy link
Author

Thanks for answering those @vslavik. Good to know that 1. and 2. were definitely wrong, though a lack of understanding means this _c,nc:4c1,2 is present in lots more than just a handful of plugins and themes, as folks have just copied and pasted without understanding (as have I previously).

For 4., I think that's my mistake as I copied the list from PHP which generates the .pot but good to know about the PO format docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment