View | Details | Raw Unified | Return to bug 35043
Collapse All | Expand All

(-)a/misc/translator/TmplTokenizer.pm (-9 lines)
Lines 461-475 sub trim { Link Here
461
    return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s;
461
    return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s;
462
}
462
}
463
463
464
sub quote_po {
465
    my($s) = @_;
466
    # Locale::PO->quote is buggy, it doesn't quote newlines :-/
467
    $s =~ s/([\\"])/\\$1/gs;
468
    $s =~ s/\n/\\n/g;
469
    #$s =~ s/[\177-\377]/ sprintf("\\%03o", ord($&)) /egs;
470
    return "\"$s\"";
471
}
472
473
sub charset_canon {
464
sub charset_canon {
474
    my($charset) = @_;
465
    my($charset) = @_;
475
    $charset = uc($charset);
466
    $charset = uc($charset);
(-)a/misc/translator/tmpl_process3.pl (-1 / +1 lines)
Lines 40-46 sub find_translation { Link Here
40
    if ($s =~ /\S/s) {
40
    if ($s =~ /\S/s) {
41
      $key = TmplTokenizer::string_canon($key);
41
      $key = TmplTokenizer::string_canon($key);
42
      $key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out);
42
      $key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out);
43
      $key = TmplTokenizer::quote_po($key);
43
      $key = Locale::PO->quote($key);
44
    }
44
    }
45
    if (defined $href->{$key} && !$href->{$key}->fuzzy && length Locale::PO->dequote($href->{$key}->msgstr)){
45
    if (defined $href->{$key} && !$href->{$key}->fuzzy && length Locale::PO->dequote($href->{$key}->msgstr)){
46
	if ($s =~ /^(\s+)/){
46
	if ($s =~ /^(\s+)/){
(-)a/misc/translator/xgettext.pl (-8 / +3 lines)
Lines 265-277 EOF Link Here
265
        }
265
        }
266
266
267
        printf $OUTPUT "#, c-format\n" if $cformat_p;
267
        printf $OUTPUT "#, c-format\n" if $cformat_p;
268
        printf $OUTPUT "msgid %s\n", TmplTokenizer::quote_po(
268
        my $msgid = TmplTokenizer::string_canon( TmplTokenizer::charset_convert( $t, $charset_in, $charset_out ) );
269
            TmplTokenizer::string_canon(
269
        printf $OUTPUT "msgid %s\n", ( defined $msgid && length $msgid ? Locale::PO->quote($msgid) : q{""} );
270
                TmplTokenizer::charset_convert( $t, $charset_in, $charset_out )
270
        printf $OUTPUT "msgstr %s\n\n", ( defined $translation{$t} ? Locale::PO->quote( $translation{$t} ) : q{""} );
271
            )
272
        );
273
        printf $OUTPUT "msgstr %s\n\n", (defined $translation{$t}?
274
            TmplTokenizer::quote_po( $translation{$t} ): "\"\"");
275
    }
271
    }
276
}
272
}
277
273
278
- 

Return to bug 35043