diff --git a/misc/translator/TmplTokenizer.pm b/misc/translator/TmplTokenizer.pm index 05cc54ea6b..1e95c54879 100644 --- a/misc/translator/TmplTokenizer.pm +++ b/misc/translator/TmplTokenizer.pm @@ -461,15 +461,6 @@ sub trim { return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s; } -sub quote_po { - my($s) = @_; - # Locale::PO->quote is buggy, it doesn't quote newlines :-/ - $s =~ s/([\\"])/\\$1/gs; - $s =~ s/\n/\\n/g; - #$s =~ s/[\177-\377]/ sprintf("\\%03o", ord($&)) /egs; - return "\"$s\""; -} - sub charset_canon { my($charset) = @_; $charset = uc($charset); diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index ddb02e7957..6417226d9b 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -40,7 +40,7 @@ sub find_translation { if ($s =~ /\S/s) { $key = TmplTokenizer::string_canon($key); $key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out); - $key = TmplTokenizer::quote_po($key); + $key = Locale::PO->quote($key); } if (defined $href->{$key} && !$href->{$key}->fuzzy && length Locale::PO->dequote($href->{$key}->msgstr)){ if ($s =~ /^(\s+)/){ diff --git a/misc/translator/xgettext.pl b/misc/translator/xgettext.pl index 0ebf93ebc3..fcb89f8cf2 100755 --- a/misc/translator/xgettext.pl +++ b/misc/translator/xgettext.pl @@ -265,13 +265,9 @@ EOF } printf $OUTPUT "#, c-format\n" if $cformat_p; - printf $OUTPUT "msgid %s\n", TmplTokenizer::quote_po( - TmplTokenizer::string_canon( - TmplTokenizer::charset_convert( $t, $charset_in, $charset_out ) - ) - ); - printf $OUTPUT "msgstr %s\n\n", (defined $translation{$t}? - TmplTokenizer::quote_po( $translation{$t} ): "\"\""); + my $msgid = TmplTokenizer::string_canon( TmplTokenizer::charset_convert( $t, $charset_in, $charset_out ) ); + printf $OUTPUT "msgid %s\n", ( defined $msgid && length $msgid ? Locale::PO->quote($msgid) : q{""} ); + printf $OUTPUT "msgstr %s\n\n", ( defined $translation{$t} ? Locale::PO->quote( $translation{$t} ) : q{""} ); } }