Diff for /loncom/localize/localize/mtarguments between versions 1.1 and 1.2

version 1.1, 2008/12/30 20:45:38 version 1.2, 2009/01/13 12:42:55
Line 3 Line 3
 use strict;  use strict;
 use warnings;  use warnings;
   
 my $man =  my $man = "
 "mtarguments - searches a single file or all files in a directory and its subdirectory for occurence of calls to the subroutine &mt. Arguments of &mt are written to the file newphrases.txt. In addition, arguments and locations where such calls appear are written to the file newphraseslocations.txt.  mtarguments - searches a single file or all files in a directory and its subdirectory for occurence of calls to the subroutine &mt. Arguments of &mt are appended to the file newphrases.txt. In addition, arguments and locations where such calls appear are written to the file newphraseslocations.txt.
   
 mtarguments is particularly useful for detecting new arguments to mt which consequently need to be translated for non-English users of loncapa. Detection of such arguments is most easily done by comparing newphrases.txt with an earlier version of this file via unix's diff. Detected new phrases can then be incorporated into localization files using sync.pl.  mtarguments is particularly useful for detecting new arguments to mt which consequently need to be translated for non-English users of loncapa. Detection of such arguments is most easily done by comparing newphrases.txt with an earlier version of this file via unix's diff. Detected new phrases can then be incorporated into localization files using sync.pl.
   
Line 36  if ( $ARGV[0] =~ m/^\s*-h/ ) { Line 36  if ( $ARGV[0] =~ m/^\s*-h/ ) {
  die "$files[0] is not a file.\n" unless -f $ARGV[0];   die "$files[0] is not a file.\n" unless -f $ARGV[0];
 }  }
   
   
   # Start Analysis
   print "mtarguments is searching...\n";
   
 # expression for nested parantheses  # expression for nested parantheses
 my $rep;  my $rep;
 $rep = qr{ \( ((?: (?> [^()]+ )  | (??{ $rep })  )*) \) }x;  $rep = qr{ \( ((?: (?> [^()]+ )  | (??{ $rep })  )*) \) }x;
Line 70  sub find_mt_arguments{ Line 74  sub find_mt_arguments{
 }  }
   
 #write outputfiles  #write outputfiles
 open(NP,'>','newphrases.txt');  open(NP,'>>','newphrases.txt'); # Keep existing entries and append new phrases. synch.pl will care about entries which occur more than one time.
 open(NPL,'>','newphraseslocations.txt');  open(NPL,'>','newphraseslocations.txt');
   my $counter=0;
 my $warnings=0;  my $warnings=0;
   my $exprNP="";
 foreach my $expr (sort keys %mtArgInFile){  foreach my $expr (sort keys %mtArgInFile){
  print NP "$expr\n";   $exprNP=$expr;
           $exprNP=~s/^["'](.*)["']$/$1/; # Remove " and ' at beginning and end for newphrases.txt
    print NP "$exprNP\n";
  print NPL "$expr\n\tFOUND IN: $mtArgInFile{$expr}\n";   print NPL "$expr\n\tFOUND IN: $mtArgInFile{$expr}\n";
    $counter++;
  $warnings++ if($expr=~/\$|@|&/);   $warnings++ if($expr=~/\$|@|&/);
 }  }
 close(NPL);  
 close(NP);  close(NP);
 print "Wrote newphrases.txt.\nWrote newphraseslocations.txt.\n";  print "Wrote newphrases.txt.\n";
 print "WARNING: Found $warnings case(s) where argument of &mt is a perl variable.\n" if $warnings;  close(NPL);
   print "Wrote newphraseslocations.txt.\n";
   
   print "WARNING: Found $warnings case(s) where argument of &mt contains a perl variable.\n" if $warnings;
   print "Found $counter new phrases.\n";
   
 sub recursivefilelist {  sub recursivefilelist {
  my ($currentpath) = @_;   my ($currentpath) = @_;

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>