Bug 6958 : Fix for leading spaces being stripped on translation

This will re-add any leading spaces, so formatting is not messed

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
- all examples from the bug report are fixed now
- verified system preferences are still translated
- verified xslt displays are still translated
- verified javascript alerts are still translated
- verified switching languages works

Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
(cherry picked from commit 873091dcc8)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Chris Cormack 2011-10-04 10:43:45 +13:00 committed by Chris Nighswonger
parent 37ef2f1830
commit e5f2ddb2be
1 changed files with 14 additions and 7 deletions

View File

@ -35,14 +35,21 @@ sub find_translation ($) {
my($s) = @_;
my $key = $s;
if ($s =~ /\S/s) {
$key = TmplTokenizer::string_canon($key);
$key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out);
$key = TmplTokenizer::quote_po($key);
$key = TmplTokenizer::string_canon($key);
$key = TmplTokenizer::charset_convert($key, $charset_in, $charset_out);
$key = TmplTokenizer::quote_po($key);
}
if (defined $href->{$key} && !$href->{$key}->fuzzy && length Locale::PO->dequote($href->{$key}->msgstr)){
if ($s =~ /^(\s+)/){
return $1 . Locale::PO->dequote($href->{$key}->msgstr);
}
else {
return Locale::PO->dequote($href->{$key}->msgstr);
}
}
else {
return $s;
}
return defined $href->{$key}
&& !$href->{$key}->fuzzy
&& length Locale::PO->dequote($href->{$key}->msgstr)?
Locale::PO->dequote($href->{$key}->msgstr): $s;
}
sub text_replace_tag ($$) {