[Koha-cvs] CVS: koha/misc/translator tmpl_process3.pl,1.20.2.2,1.20.2.3 VerboseWarnings.pm,1.4,1.4.2.1

Paul POULAIN tipaul at users.sourceforge.net
Wed Mar 30 14:28:51 CEST 2005


Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17202/misc/translator

Modified Files:
      Tag: rel_2_2
	tmpl_process3.pl VerboseWarnings.pm 
Log Message:
* Useful for translators only : modified tmpl_process to copy files that are not translated (like images, css... previously, they were not copied, it had to be done manually. Errors occurs because changes in english css or images were not reported to the translation directory giving a buggy translation)
* added a -q flag, for silent run of the tmpl_process3.pl (to put it in a crontab for example)

Index: tmpl_process3.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/tmpl_process3.pl,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -C2 -r1.20.2.2 -r1.20.2.3
*** tmpl_process3.pl	4 Feb 2005 03:48:53 -0000	1.20.2.2
--- tmpl_process3.pl	30 Mar 2005 12:28:47 -0000	1.20.2.3
***************
*** 21,25 ****
  ###############################################################################
  
! use vars qw( @in_files $in_dir $str_file $out_dir );
  use vars qw( @excludes $exclude_regex );
  use vars qw( $recursive_p );
--- 21,25 ----
  ###############################################################################
  
! use vars qw( @in_files $in_dir $str_file $out_dir $quiet );
  use vars qw( @excludes $exclude_regex );
  use vars qw( $recursive_p );
***************
*** 126,130 ****
  		;
  	    } elsif (-f $path) {
! 		push @it, $path if !defined $type || $dirent =~ /\.(?:$type)$/;
  	    } elsif (-d $path && $recursive_p) {
  		push @it, listfiles($path, $type);
--- 126,130 ----
  		;
  	    } elsif (-f $path) {
! 		push @it, $path ;#if !defined $type || $dirent =~ /\.(?:$type)$/;
  	    } elsif (-d $path && $recursive_p) {
  		push @it, listfiles($path, $type);
***************
*** 146,150 ****
      mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix;
      if (!-d $dir) {
! 	print STDERR "Making directory $dir...";
  	# creates with rwxrwxr-x permissions
  	mkdir($dir, 0775) || warn_normal "$dir: $!", undef;
--- 146,150 ----
      mkdir_recursive($prefix) if $prefix ne '.' && !-d $prefix;
      if (!-d $dir) {
! 	print STDERR "Making directory $dir..." unless $quiet;
  	# creates with rwxrwxr-x permissions
  	mkdir($dir, 0775) || warn_normal "$dir: $!", undef;
***************
*** 174,177 ****
--- 174,178 ----
    -x, --exclude=REGEXP        Exclude files matching the given REGEXP
        --help                  Display this help and exit
+   -q, --quiet                 no output to screen (except for errors)
  
  The -o option is ignored for the "create" and "update" actions.
***************
*** 199,202 ****
--- 200,204 ----
      'str-file|s=s'			=> \$str_file,
      'exclude|x=s'			=> \@excludes,
+ 	'quiet|q'				=> \$quiet,
      'pedantic-warnings|pedantic'	=> sub { $pedantic_p = 1 },
      'help'				=> \&usage,
***************
*** 360,378 ****
      # creates the new tmpl file using the new translation
      for my $input (@in_files) {
! 	die "Assertion failed"
! 		unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
! 
! 	my $h = TmplTokenizer->new( $input );
! 	$h->set_allow_cformat( 1 );
! 	VerboseWarnings::set_input_file_name $input;
! 
! 	my $target = $out_dir . substr($input, length($in_dir));
! 	my $targetdir = $` if $target =~ /[^\/]+$/s;
! 	mkdir_recursive($targetdir) unless -d $targetdir;
! 	print STDERR "Creating $target...\n";
! 	open( OUTPUT, ">$target" ) || die "$target: $!\n";
! 	text_replace( $h, *OUTPUT );
! 	close OUTPUT;
!     }
  
  } else {
--- 362,389 ----
      # creates the new tmpl file using the new translation
      for my $input (@in_files) {
! 		die "Assertion failed"
! 			unless substr($input, 0, length($in_dir) + 1) eq "$in_dir/";
! # 		print "$input / $type\n";
! 		if (!defined $type || $input =~ /\.(?:$type)$/) {
! 			my $h = TmplTokenizer->new( $input );
! 			$h->set_allow_cformat( 1 );
! 			VerboseWarnings::set_input_file_name $input;
! 		
! 			my $target = $out_dir . substr($input, length($in_dir));
! 			my $targetdir = $` if $target =~ /[^\/]+$/s;
! 			mkdir_recursive($targetdir) unless -d $targetdir;
! 			print STDERR "Creating $target...\n" unless $quiet;
! 			open( OUTPUT, ">$target" ) || die "$target: $!\n";
! 			text_replace( $h, *OUTPUT );
! 			close OUTPUT;
! 		} else {
! 		# just copying the file
! 			my $target = $out_dir . substr($input, length($in_dir));
! 			my $targetdir = $` if $target =~ /[^\/]+$/s;
! 			mkdir_recursive($targetdir) unless -d $targetdir;
! 			system("cp -f $input $target");
! 			print STDERR "Copying $input...\n" unless $quiet;
! 		}
! 	}
  
  } else {
***************
*** 381,387 ****
  
  if ($st == 0) {
!     printf "The %s seems to be successful.\n", $action;
  } else {
!     printf "%s FAILED.\n", "\u$action";
  }
  exit 0;
--- 392,398 ----
  
  if ($st == 0) {
!     printf "The %s seems to be successful.\n", $action unless $quiet;
  } else {
!     printf "%s FAILED.\n", "\u$action" unless $quiet;
  }
  exit 0;

Index: VerboseWarnings.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/VerboseWarnings.pm,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** VerboseWarnings.pm	25 Feb 2004 03:37:27 -0000	1.4
--- VerboseWarnings.pm	30 Mar 2005 12:28:48 -0000	1.4.2.1
***************
*** 39,43 ****
  ###############################################################################
  
! use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag );
  use vars qw( $warned $erred );
  
--- 39,43 ----
  ###############################################################################
  
! use vars qw( $appName $input $input_abbr $pedantic_p $pedantic_tag $quiet);
  use vars qw( $warned $erred );
  
***************
*** 99,106 ****
      my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
      $msg .= "\n" unless $msg =~ /\n$/s;
!     warn "$prefix$msg" if $pedantic_p || !$$flag;
      if (!$pedantic_p) {
  	$prefix = construct_warn_prefix("Warning$pedantic_tag", undef);
! 	warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless $$flag;
  	$$flag = 1;
      }
--- 99,106 ----
      my $prefix = construct_warn_prefix("Warning$pedantic_tag", $lc);
      $msg .= "\n" unless $msg =~ /\n$/s;
!     warn "$prefix$msg" if ($pedantic_p || !$$flag) && $quiet;
      if (!$pedantic_p) {
  	$prefix = construct_warn_prefix("Warning$pedantic_tag", undef);
! 	warn $prefix."Further similar negligible warnings will not be reported, use --pedantic for details\n" unless ($$flag || !$quiet);
  	$$flag = 1;
      }





More information about the Koha-cvs mailing list