From c5823023653b09b3a2312335a538f9b6afec27d3 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 --- misc/translator/tmpl_process3.pl | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl index 988e18b..cb69117 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 ($$) { -- 1.7.4.1