I'm trying to translate a theme for WordPress using Poedit. When I try to translate % comment
string, whether I use %
in translation or not, I get this error:
Error: 'msgstr' is not a valid PHP format string, unlike 'msgid'.
Reason: The character that terminates the directive number 1 is not a valid conversion specifier.
That string's resource is line below:
comments_number(
__( '0 comments' , 'hbthemes' ) ,
__( '1 comment' , 'hbthemes' ),
__( '% comments' , 'hbthemes' )
);
I took a look at gettext manual but didn't understand what would make these error. At first I wondered how just a single %
could be in a format string, but the theme natively shows comments count correctly.
EDIT:
If I use %%
instead of %
in translation, the error remains and if I change it inside the PHP code, I get comments count twice, e.g. 22
instead of 2
.
UPDATE:
The documentation here says %
will be replaced by number of comments, so I think actual problem is with Poedit not the code.
The problem was with POEdit and by using another translation tool, I got what I was looking for.