I have a bunch of .cpp files which contain text including a literal percent sign. Those files don't use printf
at all, they use iostream
stuff:
std::cout << _( "50 % of 10 is 5" ) << std::endl;
However, strings containing %
are still marked as c-format
by xgettext
:
#: test.cpp:5
#, c-format
msgid "50 % of 10 is 5"
msgstr ""
This template then gets processed by msgmerge
and translated, and translation tools (e.g. Poedit) complains about such entries:
#: test.cpp:5
#, c-format
msgid "50 % of 10 is 5"
msgstr "50 % de 10 est 5"
Format specification in 'msgid' and 'msgstr' does not match
Manually removing the #, c-format
comments helps, but they come back after every merge. How can I force xgettext
or msgmerge
to drop those comments? I know I can just filter them out with sed
, but is there a smarter way, which would keep such comments for strings coming from C files?
The gettext
documentation talks about this exact same issue here: https://www.gnu.org/software/gettext/manual/html_node/c_002dformat-Flag.html
According to the docs, you should use this special comment before the lines:
xgettext:no-c-format