Support » Plugin: Loco Translate » msgid' and msgstr' entries do not both end with '\n'

  • Resolved tanguysauvin



    My wordpress didn’t get translated. So I tried to compile the generated by Loco Translate PO file into a mo in Poedit.

    It turned out, it failed because of the crazy error I put as a subject. To patch it, i changed admin-poedit.tpl.php on the last lines to:

    loco = window.loco || {};
    $file = compact(‘po’,’pot’,’headers’) + array(
    ‘locale’ => $locale ? $locale->export() : null,
    if (isset( $file[‘po’] )) {
    foreach ($file[‘po’] as &$po_entry) {
    if (isset($po_entry[‘source’]))
    $po_entry[‘source’] = trim( $po_entry[‘source’] );
    if (isset($po_entry[‘target’]))
    $po_entry[‘target’] = trim( $po_entry[‘target’] );
    loco.conf = <?php echo json_encode( $file )?>;

    It just sorted out the problem.

    I hope it can help,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tim W


    I’m glad this solves your problem, but I do not recommend the solution.

    This error comes from the Gettext msgfmt program (used by POEdit). It is a useful error because it tells you your translations probably have accidental line breaks at the end.

    Trimming all entires forcefully like this could result in further errors. I’m sure you know what you’re doing, but I strongly recommend anyone else reading this post does not implement the same fix.

    Loco’s native MO compiler is not strict about line endings, so saving your MO file within the plugin won’t throw this error. If you have an issue saving files within Loco, it is likely to be for some other reason.

    Thank you Tim for your explanations. I guess you’re right. It was just in case it could give you any idea on how to improve the plugin. But, I see you’re already well documented on the case.

    Great plugin anyway! And thank you for your work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘msgid' and msgstr' entries do not both end with '\n'’ is closed to new replies.