Sorry about the blank post: I was having attachment woes with my e-mail account.
In working through the spanish localization file I wanted a way to determine which keys were missing/extraneous.
I tried a quick googling but didn't find anything - so I wrote up a quick & dirty perl script to 'diff' two localization files. FYI the output is more of a report than a true diff.
Peace, Enrique
Usage: localization-diff.pl file1 file2
-------------------------------- BEGIN SCRIPT
#!/usr/bin/perl # # Copyright 2000-2004 The Apache Software Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #-------------------------------------------------------------------- # Purpose : Give a simple "diff" between two turbine localization files. # Just tells what keys are missing in the 2nd file #-------------------------------------------------------------------- # Author: [EMAIL PROTECTED] #-------------------------------------------------------------------- use strict;
#----------------------------------------------------------%%% #Globals #------------------------------------------------------------- $| = 1;
my $USAGE ="perl $0 file1 file2\n"; my $file1; my $file2;
#----------------------------------------------------------%%% sub parseInput { if(scalar(@ARGV) > 1) { $file1 = shift(@ARGV); $file2 = shift(@ARGV); } else { return -1; } return 0; }
#-----------------------------------------------------------------%%% sub slurp { my ($filename, $hash_ref) = @_;
open(IN,$filename) || die("Couldn't open $filename for input\n");
while(<IN>) { chomp(my $str = $_);
my $lineNo = $.;
if($str =~ /^\#/) { next; } ($str =~ /.+=.+/) or next; my ($key, $value) = split(/=/,$str); $key = uc($key);
if(exists $$hash_ref{$key}) {
print STDERR "$filename:$lineNo: $key already defined at line $$hash_ref{$key}\n";
} else {
$$hash_ref{$key} = $lineNo;
}
}
close(IN); }
#-----------------------------------------------------------------%%% sub main { if(parseInput() != 0) { print $USAGE; exit(-1); }
my %KEYS1 = (); my %KEYS2 = ();
slurp($file1, \%KEYS1); slurp($file2, \%KEYS2);
print "Analysis of $file2\n"; foreach my $key1 (sort keys %KEYS1) { if(exists $KEYS2{$key1}) { #ok } else { print STDERR "Missing key $key1, See $file1:$KEYS1{$key1}\n"; } }
foreach my $key2 (sort keys %KEYS2) { if(exists $KEYS1{$key2}) { #ok } else { print STDERR "Extra key $key2, $file2:$KEYS2{$key2}\n"; } }
}
main();
1;
__END__
_________________________________________________________________
Las mejores tiendas, los precios mas bajos y las mejores ofertas en MSN Latino. http://latino.msn.com/compras
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]