@@ -279,10 +279,13 @@ sub signal_handler {
279279 # tmp files from --compose
280280 if (defined $compose_filename ) {
281281 if (-e $compose_filename ) {
282- print " '$compose_filename ' contains an intermediate version of the email you were composing.\n " ;
282+ printf __(" '%s ' contains an intermediate version " .
283+ " of the email you were composing.\n " ),
284+ $compose_filename ;
283285 }
284286 if (-e ($compose_filename . " .final" )) {
285- print " '$compose_filename .final' contains the composed email.\n "
287+ printf __(" '%s .final' contains the composed email.\n " ),
288+ $compose_filename ;
286289 }
287290 }
288291
@@ -431,7 +434,7 @@ sub read_config {
431434my (%suppress_cc );
432435if (@suppress_cc ) {
433436 foreach my $entry (@suppress_cc ) {
434- die " Unknown --suppress-cc field: '$entry '\n "
437+ die sprintf (__( " Unknown --suppress-cc field: '%s '\n " ), $entry )
435438 unless $entry =~ / ^(?:all|cccmd|cc|author|self|sob|body|bodycc)$ / ;
436439 $suppress_cc {$entry } = 1;
437440 }
@@ -460,7 +463,7 @@ sub read_config {
460463if ($confirm_unconfigured ) {
461464 $confirm = scalar %suppress_cc ? ' compose' : ' auto' ;
462465};
463- die " Unknown --confirm setting: '$confirm '\n "
466+ die sprintf (__( " Unknown --confirm setting: '%s '\n " ), $confirm )
464467 unless $confirm =~ / ^(?:auto|cc|compose|always|never)/ ;
465468
466469# Debugging, print out the suppressions.
@@ -492,16 +495,16 @@ sub split_addrs {
492495sub parse_sendmail_alias {
493496 local $_ = shift ;
494497 if (/ "/ ) {
495- print STDERR " warning: sendmail alias with quotes is not supported: $_ \n " ;
498+ printf STDERR __( " warning: sendmail alias with quotes is not supported: %s \n " ), $_ ;
496499 } elsif (/ :include:/ ) {
497- print STDERR " warning: `:include:` not supported: $_ \n " ;
500+ printf STDERR __( " warning: `:include:` not supported: %s \n " ), $_ ;
498501 } elsif (/ [\/ |]/ ) {
499- print STDERR " warning: `/file` or `|pipe` redirection not supported: $_ \n " ;
502+ printf STDERR __( " warning: `/file` or `|pipe` redirection not supported: %s \n " ), $_ ;
500503 } elsif (/ ^(\S +?)\s *:\s *(.+)$ / ) {
501504 my ($alias , $addr ) = ($1 , $2 );
502505 $aliases {$alias } = [ split_addrs($addr ) ];
503506 } else {
504- print STDERR " warning: sendmail line is not recognized: $_ \n " ;
507+ printf STDERR __( " warning: sendmail line is not recognized: %s \n " ), $_ ;
505508 }
506509}
507510
@@ -582,11 +585,11 @@ sub is_format_patch_arg {
582585 if (defined ($format_patch )) {
583586 return $format_patch ;
584587 }
585- die ( <<EOF );
586- File '$f ' exists but it could also be the range of commits
588+ die sprintf (__ <<EOF , $f , $f );
589+ File '%s ' exists but it could also be the range of commits
587590to produce patches for. Please disambiguate by...
588591
589- * Saying "./$f " if you mean a file; or
592+ * Saying "./%s " if you mean a file; or
590593 * Giving --format-patch option if you mean a range.
591594EOF
592595 } catch Git::Error::Command with {
@@ -604,7 +607,7 @@ sub is_format_patch_arg {
604607 @ARGV = ();
605608 } elsif (-d $f and !is_format_patch_arg($f )) {
606609 opendir my $dh , $f
607- or die " Failed to opendir $f : $! " ;
610+ or die sprintf (__( " Failed to opendir %s : %s " ), $f , $! ) ;
608611
609612 push @files , grep { -f $_ } map { catfile($f , $_ ) }
610613 sort readdir $dh ;
@@ -628,7 +631,8 @@ sub is_format_patch_arg {
628631 foreach my $f (@files ) {
629632 unless (-p $f ) {
630633 my $error = validate_patch($f );
631- $error and die " fatal: $f : $error \n warning: no patches were sent\n " ;
634+ $error and die sprintf (__(" fatal: %s : %s \n warning: no patches were sent\n " ),
635+ $f , $error );
632636 }
633637 }
634638}
@@ -651,7 +655,7 @@ sub get_patch_subject {
651655 return " GIT: $1 \n " ;
652656 }
653657 close $fh ;
654- die " No subject line in $fn ? " ;
658+ die sprintf (__( " No subject line in %s ? " ), $fn ) ;
655659}
656660
657661if ($compose ) {
@@ -661,7 +665,7 @@ sub get_patch_subject {
661665 tempfile(" .gitsendemail.msg.XXXXXX" , DIR => $repo -> repo_path()) :
662666 tempfile(" .gitsendemail.msg.XXXXXX" , DIR => " ." ))[1];
663667 open my $c , " >" , $compose_filename
664- or die " Failed to open for writing $compose_filename : $! " ;
668+ or die sprintf (__( " Failed to open for writing %s : %s " ), $compose_filename , $! ) ;
665669
666670
667671 my $tpl_sender = $sender || $repoauthor || $repocommitter || ' ' ;
@@ -692,10 +696,10 @@ sub get_patch_subject {
692696 }
693697
694698 open my $c2 , " >" , $compose_filename . " .final"
695- or die " Failed to open $compose_filename .final : " . $! ;
699+ or die sprintf (__( " Failed to open %s .final: %s " ), $compose_filename , $! ) ;
696700
697701 open $c , " <" , $compose_filename
698- or die " Failed to open $compose_filename : " . $! ;
702+ or die sprintf (__( " Failed to open %s : %s " ), $compose_filename , $! ) ;
699703
700704 my $need_8bit_cte = file_has_nonascii($compose_filename );
701705 my $in_body = 0;
@@ -769,7 +773,9 @@ sub ask {
769773 return $resp ;
770774 }
771775 if ($confirm_only ) {
772- my $yesno = $term -> readline(" Are you sure you want to use <$resp > [y/N]? " );
776+ my $yesno = $term -> readline(
777+ # TRANSLATORS: please keep [y/N] as is.
778+ sprintf (__(" Are you sure you want to use <%s > [y/N]? " ), $resp ));
773779 if (defined $yesno && $yesno =~ / y/i ) {
774780 return $resp ;
775781 }
@@ -811,9 +817,9 @@ sub file_declares_8bit_cte {
811817if (!$force ) {
812818 for my $f (@files ) {
813819 if (get_patch_subject($f ) =~ / \Q *** SUBJECT HERE ***\E / ) {
814- die " Refusing to send because the patch\n\t $f \n "
820+ die sprintf (__( " Refusing to send because the patch\n\t %s \n "
815821 . " has the template subject '*** SUBJECT HERE ***'. "
816- . " Pass --force if you really want to send.\n " ;
822+ . " Pass --force if you really want to send.\n " ), $f ) ;
817823 }
818824 }
819825}
@@ -848,7 +854,7 @@ sub expand_aliases {
848854sub expand_one_alias {
849855 my $alias = shift ;
850856 if ($EXPANDED_ALIASES {$alias }) {
851- die " fatal: alias '$alias ' expands to itself\n " ;
857+ die sprintf (__( " fatal: alias '%s ' expands to itself\n " ), $alias ) ;
852858 }
853859 local $EXPANDED_ALIASES {$alias } = 1;
854860 return $aliases {$alias } ? expand_aliases(@{$aliases {$alias }}) : $alias ;
@@ -910,15 +916,15 @@ sub extract_valid_address {
910916sub extract_valid_address_or_die {
911917 my $address = shift ;
912918 $address = extract_valid_address($address );
913- die " error: unable to extract a valid address from: $address \n "
919+ die sprintf (__( " error: unable to extract a valid address from: %s \n " ), $address )
914920 if !$address ;
915921 return $address ;
916922}
917923
918924sub validate_address {
919925 my $address = shift ;
920926 while (!extract_valid_address($address )) {
921- print STDERR " error: unable to extract a valid address from: $address \n " ;
927+ printf STDERR __( " error: unable to extract a valid address from: %s \n " ), $address ;
922928 # TRANSLATORS: Make sure to include [q] [d] [e] in your
923929 # translation. The program will only accept English input
924930 # at this point.
@@ -1223,7 +1229,7 @@ sub ssl_verify_params {
12231229 return (SSL_verify_mode => SSL_VERIFY_PEER(),
12241230 SSL_ca_file => $smtp_ssl_cert_path );
12251231 } else {
1226- die " CA path \" $smtp_ssl_cert_path \" does not exist" ;
1232+ die sprintf (__( " CA path \" %s \" does not exist" ), $smtp_ssl_cert_path ) ;
12271233 }
12281234}
12291235
@@ -1386,14 +1392,14 @@ sub send_message {
13861392 # supported commands
13871393 $smtp -> hello($smtp_domain );
13881394 } else {
1389- die " Server does not support STARTTLS! " . $smtp -> message;
1395+ die sprintf (__( " Server does not support STARTTLS! %s " ), $smtp -> message) ;
13901396 }
13911397 }
13921398 }
13931399
13941400 if (!$smtp ) {
1395- die " Unable to initialize SMTP properly. Check config and use --smtp-debug. " ,
1396- " VALUES: server=$smtp_server " ,
1401+ die __( " Unable to initialize SMTP properly. Check config and use --smtp-debug." ) ,
1402+ " VALUES: server=$smtp_server " ,
13971403 " encryption=$smtp_encryption " ,
13981404 " hello=$smtp_domain " ,
13991405 defined $smtp_server_port ? " port=$smtp_server_port " : " " ;
@@ -1410,10 +1416,10 @@ sub send_message {
14101416 $smtp -> datasend(" $line " ) or die $smtp -> message;
14111417 }
14121418 $smtp -> dataend() or die $smtp -> message;
1413- $smtp -> code =~ / 250|200/ or die " Failed to send $subject \n " .$smtp -> message;
1419+ $smtp -> code =~ / 250|200/ or die sprintf (__( " Failed to send %s \n " ), $subject ) .$smtp -> message;
14141420 }
14151421 if ($quiet ) {
1416- printf (( $dry_run ? " Dry-" : " " ). " Sent %s \n " , $subject );
1422+ printf ( $dry_run ? __( " Dry-Sent %s \n " ) : __( " Sent %s \n " ) , $subject );
14171423 } else {
14181424 print ($dry_run ? __(" Dry-OK. Log says:\n " ) : __(" OK. Log says:\n " ));
14191425 if (!file_name_is_absolute($smtp_server )) {
@@ -1443,7 +1449,7 @@ sub send_message {
14431449$message_num = 0;
14441450
14451451foreach my $t (@files ) {
1446- open my $fh , " <" , $t or die " can't open file $t " ;
1452+ open my $fh , " <" , $t or die sprintf (__( " can't open file %s " ), $t ) ;
14471453
14481454 my $author = undef ;
14491455 my $sauthor = undef ;
@@ -1665,18 +1671,18 @@ sub recipients_cmd {
16651671
16661672 my @addresses = ();
16671673 open my $fh , " -|" , " $cmd \Q $file \E "
1668- or die " ( $prefix ) Could not execute '$cmd ' " ;
1674+ or die sprintf (__( " ( %s ) Could not execute '%s ' " ), $prefix , $cmd ) ;
16691675 while (my $address = <$fh >) {
16701676 $address =~ s / ^\s *// g ;
16711677 $address =~ s /\s *$// g ;
16721678 $address = sanitize_address($address );
16731679 next if ($address eq $sender and $suppress_cc {' self' });
16741680 push @addresses , $address ;
1675- printf (" ( $prefix ) Adding %s : %s from: '%s '\n " ,
1676- $what , $address , $cmd ) unless $quiet ;
1681+ printf (__( " ( %s ) Adding %s : %s from: '%s '\n " ) ,
1682+ $prefix , $ what , $address , $cmd ) unless $quiet ;
16771683 }
16781684 close $fh
1679- or die " ( $prefix ) failed to close pipe to '$cmd ' " ;
1685+ or die sprintf (__( " ( %s ) failed to close pipe to '%s ' " ), $prefix , $cmd ) ;
16801686 return @addresses ;
16811687}
16821688
@@ -1730,10 +1736,10 @@ sub unique_email_list {
17301736sub validate_patch {
17311737 my $fn = shift ;
17321738 open (my $fh , ' <' , $fn )
1733- or die " unable to open $fn : $! \n " ;
1739+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
17341740 while (my $line = <$fh >) {
17351741 if (length ($line ) > 998) {
1736- return " $. : patch contains a line longer than 998 characters" ;
1742+ return sprintf (__( " %s : patch contains a line longer than 998 characters" ), $. ) ;
17371743 }
17381744 }
17391745 return ;
@@ -1749,10 +1755,11 @@ sub handle_backup {
17491755 (substr ($file , 0, $lastlen ) eq $last ) &&
17501756 ($suffix = substr ($file , $lastlen )) !~ / ^[a-z0-9]/i ) {
17511757 if (defined $known_suffix && $suffix eq $known_suffix ) {
1752- print " Skipping $file with backup suffix '$known_suffix '.\n " ;
1758+ printf (__( " Skipping %s with backup suffix '%s '.\n " ), $file , $known_suffix ) ;
17531759 $skip = 1;
17541760 } else {
1755- my $answer = ask(" Do you really want to send $file ? (y|N): " ,
1761+ # TRANSLATORS: please keep "[y|N]" as is.
1762+ my $answer = ask(sprintf (__(" Do you really want to send %s ? [y|N]: " ), $file ),
17561763 valid_re => qr / ^(?:y|n)/ i ,
17571764 default => ' n' );
17581765 $skip = ($answer ne ' y' );
@@ -1780,7 +1787,7 @@ sub handle_backup_files {
17801787sub file_has_nonascii {
17811788 my $fn = shift ;
17821789 open (my $fh , ' <' , $fn )
1783- or die " unable to open $fn : $! \n " ;
1790+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
17841791 while (my $line = <$fh >) {
17851792 return 1 if $line =~ / [^[:ascii:]]/ ;
17861793 }
@@ -1790,7 +1797,7 @@ sub file_has_nonascii {
17901797sub body_or_subject_has_nonascii {
17911798 my $fn = shift ;
17921799 open (my $fh , ' <' , $fn )
1793- or die " unable to open $fn : $! \n " ;
1800+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
17941801 while (my $line = <$fh >) {
17951802 last if $line =~ / ^$ / ;
17961803 return 1 if $line =~ / ^Subject.*[^[:ascii:]]/ ;
0 commit comments