Something is wrong with exporting .mo when original string has msgid_plural and translation has only one msgstr #594

Closed
tg29359 opened this Issue Nov 3, 2016 · 4 comments

Projects

None yet

3 participants

@ocean90 ocean90 added the bug label Nov 3, 2016
@ocean90
Member
ocean90 commented Nov 3, 2016

Confirmed.

Steps to reproduce:

Expected: The command runs without errors and the PO file is complete.
Actual: There is an error read-mo.c:249: invalid multibyte sequence and some translations are missing in the PO file.

@ocean90
Member
ocean90 commented Nov 3, 2016

Simpler test case:

<?php
require '/path/to/wp-includes/pomo/mo.php';

$mo = new MO();
$mo->add_entry( new Translation_Entry( [
    'singular' => 'Page Layout',
    'translations' => [
        '固定ページレイアウト',
    ]
] ) );

$mo->export_to_file( 'test.mo' );

$ msgunfmt test.mo -o test.po will produce the same error as above.

@ocean90 ocean90 added this to the 2.3 milestone Nov 3, 2016
@ocean90
Member
ocean90 commented Nov 3, 2016

Okay, that's a major issue and was introduced in 1a9e695.

Adding $mo->set_header( 'Content-Type', 'text/plain; charset=UTF-8' ); to the test script generates a correct PO file.

MO files currently don't have any headers like the required Content-Type or Plural-Forms.

@ocean90 ocean90 modified the milestone: 2.2.1, 2.3 Nov 3, 2016
@toolstack
Contributor

Easy enough to fix, we can simply remove the override of the header output for mo's.

@ocean90 ocean90 self-assigned this Nov 3, 2016
@ocean90 ocean90 closed this in #598 Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment