I've encountered a translation issue for the given source;
<?php
$this->messageAdd($this->_("Ett okänt fel uppstod när %0 skulle skapas!", $term2), "error");
return $this->setResultCode(self::RESULT_ERROR);
?>
If I'm not blind this is a completely normal string and I have many alike in other source files but this specific one causes these lines in the po file;
#: ../../../../path/to/source_file.php:552
#, php-format
msgid "Ett okänt fel uppstod när %0 skulle skapas!"
msgstr "An unknown error occurred while creating the %0!"
With the error
Error: 'msgstr' is not a valid PHP format string, unlike 'msgid'. Reason: In the directive number 1, the character 'w' is not a valid conversation specifier.
What is the issue and why is it that only this string causes the error? If I remove the string from the source file no errors are generated in poedit.
Edit #1; I found this issue after further research and found that adding the comment /* xgettext:no-php-format */
before the translation string in the source file fixed the problem. It would be nice though to know why this happens only to the specified string and not to any other of my 5k+ strings.
xgettext
uses a heuristic that is, presumably, triggered by the use of % in the string (which you, presumably, don't use in all that 5k+ strings). Heuristics — by definition — occasionally fail and that's why gettext has builtin support for correcting them manually. – Václav Slavík