Annotation of loncom/localize/localize/synch.pl, revision 1.4
1.3 www 1:
2:
1.1 www 3: sub readlexicon {
4: my $fn=shift;
5: open(IN,$fn);
6: my %lexicon=();
7: my $contents=join('',<IN>);
8: close(IN);
9: $contents=~s/package Apache\:[^\;]+//;
10: $contents=~s/use base[^\;]+//;
11: eval($contents.'; %lexicon=%Lexicon;');
12: delete $lexicon{'_AUTO'};
13: delete $lexicon{'char_encoding'};
14: delete $lexicon{'language_code'};
15: return %lexicon;
16: }
17:
1.2 www 18: my %master=();
19: foreach (<*.pm>) {
20: print "Reading: ".$_."\n";
21: %master=(%master,&readlexicon($_));
22: }
1.4 ! www 23:
! 24: foreach my $fn (<*.pm>) {
1.3 www 25: print "Synching: ".$fn."\n";
1.4 ! www 26: my %lang=&readlexicon($fn);
! 27: system ("cp $fn $fn.original");
1.2 www 28: open(IN,$fn.'.original');
29: open(OUT,'>'.$fn);
30: my $found=0;
1.4 ! www 31: while (<IN>) {
1.2 www 32: if ($_=~/\#\s*SYNCMARKER/) { $found=1; last; }
33: print OUT $_;
34: }
35: if ($found) {
1.4 ! www 36: print OUT "\n\#SYNC ".localtime()."\n";
! 37: foreach (sort keys %master) {
! 38: unless ($lang{$_}) {
! 39: print OUT (<<ENDNEW);
! 40: '$_'
! 41: => '$_',
! 42:
! 43: ENDNEW
! 44: }
! 45: }
1.2 www 46:
47: print OUT "\n\#SYNCMARKER\n";
48: foreach (<IN>) {
49: print OUT $_;
50: }
51: }
52: close (IN);
53: close (OUT);
54: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>