[Libreoffice-commits] .: solenv/bin
Michael Meeks
mmeeks at kemper.freedesktop.org
Fri Dec 17 12:27:48 PST 2010
solenv/bin/modules/pre2par/language.pm | 54 ++++++++++-----------------------
1 file changed, 17 insertions(+), 37 deletions(-)
New commits:
commit f9e28afc172a67433f3318368ff04cfb0f77fadb
Author: Michael Meeks <michael.meeks at novell.com>
Date: Fri Dec 17 20:27:35 2010 +0000
another 4x faster - down to ~2 seconds now for me.
diff --git a/solenv/bin/modules/pre2par/language.pm b/solenv/bin/modules/pre2par/language.pm
index bc02064..56162a8 100644
--- a/solenv/bin/modules/pre2par/language.pm
+++ b/solenv/bin/modules/pre2par/language.pm
@@ -27,6 +27,7 @@
package pre2par::language;
+use strict;
use pre2par::existence;
##############################################################
@@ -71,39 +72,6 @@ sub get_language_string_from_language_block
return $newstring;
}
-##############################################################
-# Returning the complete block in all languages
-# for a specified string
-##############################################################
-
-sub get_language_block_from_language_file
-{
- my ($searchstring, $langfile) = @_;
-
- my @language_block = ();
-
- for ( my $i = 0; $i <= $#{$langfile}; $i++ )
- {
- if ( ${$langfile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
- {
- my $counter = $i;
-
- push(@language_block, ${$langfile}[$counter]);
- $counter++;
-
- while (( $counter <= $#{$langfile} ) && (!( ${$langfile}[$counter] =~ /^\s*\[/ )))
- {
- push(@language_block, ${$langfile}[$counter]);
- $counter++;
- }
-
- last;
- }
- }
-
- return \@language_block;
-}
-
############################################
# collecting all replace variables
# in a language file
@@ -119,7 +87,20 @@ sub get_all_replace_variables
{
if ( ${$langfile}[$i] =~ /^\s*\[\s*(.*?)\s*\]\s*$/ )
{
- $allvars{$1} = 1;
+ my $variable = $1;
+# print "lang block '$variable'\n";
+ my @lang_block = ();
+ my $counter;
+
+ # Store the complete block in all languages for a specified variable
+ for ( $counter = $i + 1; $counter <= $#{$langfile}; $counter++ ) {
+ my $line = ${$langfile}[$counter];
+ last if ($line =~ /^s*\[/); # next decl.
+ push @lang_block, $line;
+ }
+# print "$variable = '@lang_block'\n";
+ $allvars{$variable} = \@lang_block;
+ $i = $counter - 1;
}
}
@@ -151,9 +132,8 @@ sub localize
# print "line '$oneline' split to '$language' '$variable'\n";
if (defined $replace_hash->{$variable}) {
- my $languageblock = get_language_block_from_language_file($variable, $langfile);
- my $newstring = get_language_string_from_language_block($languageblock, $language);
-
+ my $languageblock = $replace_hash->{$variable};
+ my $newstring = get_language_string_from_language_block($replace_hash->{$variable}, $language);
if ( $newstring eq "" ) { $newstring = "\"" . $variable . "\""; }
$oneline =~ s/$variable/$newstring/g;
More information about the Libreoffice-commits
mailing list