Locale-MO-File

 view release on metacpan or  search on metacpan

lib/Locale/MO/File.pm  view on Meta::CPAN

    my ($msgid, $msgstr) = map {
        ( defined && length )
        ? $self->_decode_and_replace_newline($_)
        : q{};
    } @{$message}{qw(msgid msgstr)};

    # return value
    my %message;

    # split original
    my @strings = split m{ \Q$CONTEXT_SEPARATOR\E }xms, $msgid;
    if ( @strings > 1 ) {
        ( $message{msgctxt}, $msgid ) = @strings;
    }
    my @plurals = split m{ \Q$PLURAL_SEPARATOR\E }xms, $msgid;
    my $is_plural = @plurals > 1;
    if ( $is_plural ) {
        @message{qw(msgid msgid_plural)} = @plurals;
    }
    else {
        $message{msgid} = $msgid;
    }

    # split translation
    @plurals = split m{ \Q$PLURAL_SEPARATOR\E }xms, $msgstr, -1; ## no critic (MagicNumbers)
    if ( $is_plural ) {
        $message{msgstr_plural} = \@plurals;
    }
    else {
        $message{msgstr} = $plurals[0];
    }

    return \%message;
}

t/chars.t  view on Meta::CPAN

    {
        open my $file, '< :raw', $file_name
            or die "Cannnot open file $file_name";
        local $/ = ();
        my $text = <$file>;
        # repair last line without \n
        ok(
            ! ( $text =~ s{([^\x0D\x0A]) \z}{$1\x0D\x0A}xms ),
            "$file_name has newline at EOF",
        );
        @lines = split m{\x0A}, $text;
    }

    my $find_line_numbers = sub {
        my ($test_description, $test_reason, $regex, $regex_negation) = @_;
        my $line_number = 0;
        my @line_numbers = map {
            ++$line_number;
            ($regex_negation xor $_ =~ $regex)
            ? $line_number
            : ();



( run in 1.427 second using v1.01-cache-2.11-cpan-71847e10f99 )