@@ -279,10 +279,13 @@ sub signal_handler {
279
279
# tmp files from --compose
280
280
if (defined $compose_filename ) {
281
281
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 ;
283
285
}
284
286
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 ;
286
289
}
287
290
}
288
291
@@ -431,7 +434,7 @@ sub read_config {
431
434
my (%suppress_cc );
432
435
if (@suppress_cc ) {
433
436
foreach my $entry (@suppress_cc ) {
434
- die " Unknown --suppress-cc field: '$entry '\n "
437
+ die sprintf (__( " Unknown --suppress-cc field: '%s '\n " ), $entry )
435
438
unless $entry =~ / ^(?:all|cccmd|cc|author|self|sob|body|bodycc)$ / ;
436
439
$suppress_cc {$entry } = 1;
437
440
}
@@ -460,7 +463,7 @@ sub read_config {
460
463
if ($confirm_unconfigured ) {
461
464
$confirm = scalar %suppress_cc ? ' compose' : ' auto' ;
462
465
};
463
- die " Unknown --confirm setting: '$confirm '\n "
466
+ die sprintf (__( " Unknown --confirm setting: '%s '\n " ), $confirm )
464
467
unless $confirm =~ / ^(?:auto|cc|compose|always|never)/ ;
465
468
466
469
# Debugging, print out the suppressions.
@@ -492,16 +495,16 @@ sub split_addrs {
492
495
sub parse_sendmail_alias {
493
496
local $_ = shift ;
494
497
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 " ), $_ ;
496
499
} elsif (/ :include:/ ) {
497
- print STDERR " warning: `:include:` not supported: $_ \n " ;
500
+ printf STDERR __( " warning: `:include:` not supported: %s \n " ), $_ ;
498
501
} elsif (/ [\/ |]/ ) {
499
- print STDERR " warning: `/file` or `|pipe` redirection not supported: $_ \n " ;
502
+ printf STDERR __( " warning: `/file` or `|pipe` redirection not supported: %s \n " ), $_ ;
500
503
} elsif (/ ^(\S +?)\s *:\s *(.+)$ / ) {
501
504
my ($alias , $addr ) = ($1 , $2 );
502
505
$aliases {$alias } = [ split_addrs($addr ) ];
503
506
} else {
504
- print STDERR " warning: sendmail line is not recognized: $_ \n " ;
507
+ printf STDERR __( " warning: sendmail line is not recognized: %s \n " ), $_ ;
505
508
}
506
509
}
507
510
@@ -582,13 +585,12 @@ sub is_format_patch_arg {
582
585
if (defined ($format_patch )) {
583
586
return $format_patch ;
584
587
}
585
- die ( <<EOF );
586
- File '$f ' exists but it could also be the range of commits
588
+ die sprintf (__(
589
+ " File '%s ' exists but it could also be the range of commits
587
590
to produce patches for. Please disambiguate by...
588
591
589
- * Saying "./$f " if you mean a file; or
590
- * Giving --format-patch option if you mean a range.
591
- EOF
592
+ * Saying \" ./%s \" if you mean a file; or
593
+ * Giving --format-patch option if you mean a range." ), $f , $f );
592
594
} catch Git::Error::Command with {
593
595
# Not a valid revision. Treat it as a filename.
594
596
return 0;
@@ -604,7 +606,7 @@ sub is_format_patch_arg {
604
606
@ARGV = ();
605
607
} elsif (-d $f and !is_format_patch_arg($f )) {
606
608
opendir my $dh , $f
607
- or die " Failed to opendir $f : $! " ;
609
+ or die sprintf (__( " Failed to opendir %s : %s " ), $f , $! ) ;
608
610
609
611
push @files , grep { -f $_ } map { catfile($f , $_ ) }
610
612
sort readdir $dh ;
@@ -628,7 +630,8 @@ sub is_format_patch_arg {
628
630
foreach my $f (@files ) {
629
631
unless (-p $f ) {
630
632
my $error = validate_patch($f );
631
- $error and die " fatal: $f : $error \n warning: no patches were sent\n " ;
633
+ $error and die sprintf (__(" fatal: %s : %s \n warning: no patches were sent\n " ),
634
+ $f , $error );
632
635
}
633
636
}
634
637
}
@@ -651,7 +654,7 @@ sub get_patch_subject {
651
654
return " GIT: $1 \n " ;
652
655
}
653
656
close $fh ;
654
- die " No subject line in $fn ?" ;
657
+ die sprintf (__( " No subject line in %s ?" ), $fn ) ;
655
658
}
656
659
657
660
if ($compose ) {
@@ -661,7 +664,7 @@ sub get_patch_subject {
661
664
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => $repo -> repo_path()) :
662
665
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => " ." ))[1];
663
666
open my $c , " >" , $compose_filename
664
- or die " Failed to open for writing $compose_filename : $! " ;
667
+ or die sprintf (__( " Failed to open for writing %s : %s " ), $compose_filename , $! ) ;
665
668
666
669
667
670
my $tpl_sender = $sender || $repoauthor || $repocommitter || ' ' ;
@@ -692,10 +695,10 @@ sub get_patch_subject {
692
695
}
693
696
694
697
open my $c2 , " >" , $compose_filename . " .final"
695
- or die " Failed to open $compose_filename .final : " . $! ;
698
+ or die sprintf (__( " Failed to open %s .final : %s " ), $compose_filename , $! ) ;
696
699
697
700
open $c , " <" , $compose_filename
698
- or die " Failed to open $compose_filename : " . $! ;
701
+ or die sprintf (__( " Failed to open %s : %s " ), $compose_filename , $! ) ;
699
702
700
703
my $need_8bit_cte = file_has_nonascii($compose_filename );
701
704
my $in_body = 0;
@@ -769,7 +772,9 @@ sub ask {
769
772
return $resp ;
770
773
}
771
774
if ($confirm_only ) {
772
- my $yesno = $term -> readline(" Are you sure you want to use <$resp > [y/N]? " );
775
+ # TRANSLATORS: Keep [y/N] as is.
776
+ my $yesno = $term -> readline(
777
+ sprintf (__(" Are you sure you want to use <%s > [y/N]? " ), $resp ));
773
778
if (defined $yesno && $yesno =~ / y/i ) {
774
779
return $resp ;
775
780
}
@@ -848,7 +853,7 @@ sub expand_aliases {
848
853
sub expand_one_alias {
849
854
my $alias = shift ;
850
855
if ($EXPANDED_ALIASES {$alias }) {
851
- die " fatal: alias '$alias ' expands to itself\n " ;
856
+ die sprintf (__( " fatal: alias '%s ' expands to itself\n " ), $alias ) ;
852
857
}
853
858
local $EXPANDED_ALIASES {$alias } = 1;
854
859
return $aliases {$alias } ? expand_aliases(@{$aliases {$alias }}) : $alias ;
@@ -910,15 +915,15 @@ sub extract_valid_address {
910
915
sub extract_valid_address_or_die {
911
916
my $address = shift ;
912
917
$address = extract_valid_address($address );
913
- die " error: unable to extract a valid address from: $address \n "
918
+ die sprintf (__( " error: unable to extract a valid address from: %s \n " ), $address )
914
919
if !$address ;
915
920
return $address ;
916
921
}
917
922
918
923
sub validate_address {
919
924
my $address = shift ;
920
925
while (!extract_valid_address($address )) {
921
- print STDERR " error: unable to extract a valid address from: $address \n " ;
926
+ printf STDERR __( " error: unable to extract a valid address from: %s \n " ), $address ;
922
927
# TRANSLATORS: Make sure to include [q] [d] [e] in your
923
928
# translation. The program will only accept English input
924
929
# at this point.
@@ -1223,7 +1228,7 @@ sub ssl_verify_params {
1223
1228
return (SSL_verify_mode => SSL_VERIFY_PEER(),
1224
1229
SSL_ca_file => $smtp_ssl_cert_path );
1225
1230
} else {
1226
- die " CA path \" $smtp_ssl_cert_path \" does not exist" ;
1231
+ die sprintf (__( " CA path \" %s \" does not exist" ), $smtp_ssl_cert_path ) ;
1227
1232
}
1228
1233
}
1229
1234
@@ -1385,7 +1390,7 @@ sub send_message {
1385
1390
# supported commands
1386
1391
$smtp -> hello($smtp_domain );
1387
1392
} else {
1388
- die " Server does not support STARTTLS! " . $smtp -> message;
1393
+ die sprintf (__( " Server does not support STARTTLS! %s " ), $smtp -> message) ;
1389
1394
}
1390
1395
}
1391
1396
}
@@ -1442,7 +1447,7 @@ sub send_message {
1442
1447
$message_num = 0;
1443
1448
1444
1449
foreach my $t (@files ) {
1445
- open my $fh , " <" , $t or die " can't open file $t " ;
1450
+ open my $fh , " <" , $t or die sprintf (__( " can't open file %s " ), $t ) ;
1446
1451
1447
1452
my $author = undef ;
1448
1453
my $sauthor = undef ;
@@ -1671,11 +1676,11 @@ sub recipients_cmd {
1671
1676
$address = sanitize_address($address );
1672
1677
next if ($address eq $sender and $suppress_cc {' self' });
1673
1678
push @addresses , $address ;
1674
- printf (" ( $prefix ) Adding %s : %s from: '%s '\n " ,
1675
- $what , $address , $cmd ) unless $quiet ;
1679
+ printf (__( " ( %s ) Adding %s : %s from: '%s '\n " ) ,
1680
+ $prefix , $ what , $address , $cmd ) unless $quiet ;
1676
1681
}
1677
1682
close $fh
1678
- or die " ( $prefix ) failed to close pipe to '$cmd ' " ;
1683
+ or die sprintf (__( " ( %s ) failed to close pipe to '%s ' " ), $prefix , $cmd ) ;
1679
1684
return @addresses ;
1680
1685
}
1681
1686
@@ -1729,10 +1734,10 @@ sub unique_email_list {
1729
1734
sub validate_patch {
1730
1735
my $fn = shift ;
1731
1736
open (my $fh , ' <' , $fn )
1732
- or die " unable to open $fn : $! \n " ;
1737
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1733
1738
while (my $line = <$fh >) {
1734
1739
if (length ($line ) > 998) {
1735
- return " $. : patch contains a line longer than 998 characters" ;
1740
+ return sprintf (__( " %s : patch contains a line longer than 998 characters" ), $. ) ;
1736
1741
}
1737
1742
}
1738
1743
return ;
@@ -1779,7 +1784,7 @@ sub handle_backup_files {
1779
1784
sub file_has_nonascii {
1780
1785
my $fn = shift ;
1781
1786
open (my $fh , ' <' , $fn )
1782
- or die " unable to open $fn : $! \n " ;
1787
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1783
1788
while (my $line = <$fh >) {
1784
1789
return 1 if $line =~ / [^[:ascii:]]/ ;
1785
1790
}
@@ -1789,7 +1794,7 @@ sub file_has_nonascii {
1789
1794
sub body_or_subject_has_nonascii {
1790
1795
my $fn = shift ;
1791
1796
open (my $fh , ' <' , $fn )
1792
- or die " unable to open $fn : $! \n " ;
1797
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1793
1798
while (my $line = <$fh >) {
1794
1799
last if $line =~ / ^$ / ;
1795
1800
return 1 if $line =~ / ^Subject.*[^[:ascii:]]/ ;
0 commit comments