From 873091dcc84de8856a1da936ab0045351273cc53 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 4 Oct 2011 10:43:45 +1300 Subject: [PATCH] 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 - 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 --- misc/translator/tmpl_process3.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 988e18b2f9..cb69117e7c 100755 --- a/misc/translator/tmpl_process3.pl +++ b/misc/translator/tmpl_process3.pl @@ -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 ($$) { -- 2.39.5