I am trying to translate a theme using Poedit, every thing is alright except two strings which give me errors like this:
Error: 'msgstr' is not a valid PHP format string, unlike 'msgid'. Reason: The character that terminates the directive number 1 is not a valid conversation specifier.
The string itself is this:
% comments
Both errors are in strings having % comment
(not sth like % s
).
Now I have two problems:
1. How can I resolve these errors? Do I need to change theme code?
2. After getting these compile errors, I used .mo and .po files anyway but some phrases had been translated and some not! What is the reason to this?
EDIT: The PHP code translation associated to is:
comments_number( __('There are no comments so far', 'hbthemes'), __('There is <strong>1 comment</strong> so far', 'hbthemes'), __('There are <strong>% comments</strong> so far', 'hbthemes') );
The
%
character is a special character in the gettext translation functions. To escape the%
character to use it in a string, change it to%%
.If you weren’t using the
__()
translation functions, then a single%
character would give you the number of comments. However, when you are using the translation functions,%
is a special character with special meaning. If you want to actually include a%
character in the string, you need to type it as%%
. The__()
function will send a single%
on to thecomments_number
function, and you should get the number of comments in its place.Your
comments_number
function should be:The problem was with
POEdit
program. I used another app and it’s gone.