@@ -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,11 +585,11 @@ 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 (__ <<EOF , $f , $f );
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
592
+ * Saying "./%s " if you mean a file; or
590
593
* Giving --format-patch option if you mean a range.
591
594
EOF
592
595
} catch Git::Error::Command with {
@@ -604,7 +607,7 @@ sub is_format_patch_arg {
604
607
@ARGV = ();
605
608
} elsif (-d $f and !is_format_patch_arg($f )) {
606
609
opendir my $dh , $f
607
- or die " Failed to opendir $f : $! " ;
610
+ or die sprintf (__( " Failed to opendir %s : %s " ), $f , $! ) ;
608
611
609
612
push @files , grep { -f $_ } map { catfile($f , $_ ) }
610
613
sort readdir $dh ;
@@ -628,7 +631,8 @@ sub is_format_patch_arg {
628
631
foreach my $f (@files ) {
629
632
unless (-p $f ) {
630
633
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 );
632
636
}
633
637
}
634
638
}
@@ -651,7 +655,7 @@ sub get_patch_subject {
651
655
return " GIT: $1 \n " ;
652
656
}
653
657
close $fh ;
654
- die " No subject line in $fn ? " ;
658
+ die sprintf (__( " No subject line in %s ? " ), $fn ) ;
655
659
}
656
660
657
661
if ($compose ) {
@@ -661,7 +665,7 @@ sub get_patch_subject {
661
665
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => $repo -> repo_path()) :
662
666
tempfile(" .gitsendemail.msg.XXXXXX" , DIR => " ." ))[1];
663
667
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 , $! ) ;
665
669
666
670
667
671
my $tpl_sender = $sender || $repoauthor || $repocommitter || ' ' ;
@@ -692,10 +696,10 @@ sub get_patch_subject {
692
696
}
693
697
694
698
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 , $! ) ;
696
700
697
701
open $c , " <" , $compose_filename
698
- or die " Failed to open $compose_filename : " . $! ;
702
+ or die sprintf (__( " Failed to open %s : %s " ), $compose_filename , $! ) ;
699
703
700
704
my $need_8bit_cte = file_has_nonascii($compose_filename );
701
705
my $in_body = 0;
@@ -769,7 +773,9 @@ sub ask {
769
773
return $resp ;
770
774
}
771
775
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 ));
773
779
if (defined $yesno && $yesno =~ / y/i ) {
774
780
return $resp ;
775
781
}
@@ -811,9 +817,9 @@ sub file_declares_8bit_cte {
811
817
if (!$force ) {
812
818
for my $f (@files ) {
813
819
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 "
815
821
. " 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 ) ;
817
823
}
818
824
}
819
825
}
@@ -848,7 +854,7 @@ sub expand_aliases {
848
854
sub expand_one_alias {
849
855
my $alias = shift ;
850
856
if ($EXPANDED_ALIASES {$alias }) {
851
- die " fatal: alias '$alias ' expands to itself\n " ;
857
+ die sprintf (__( " fatal: alias '%s ' expands to itself\n " ), $alias ) ;
852
858
}
853
859
local $EXPANDED_ALIASES {$alias } = 1;
854
860
return $aliases {$alias } ? expand_aliases(@{$aliases {$alias }}) : $alias ;
@@ -910,15 +916,15 @@ sub extract_valid_address {
910
916
sub extract_valid_address_or_die {
911
917
my $address = shift ;
912
918
$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 )
914
920
if !$address ;
915
921
return $address ;
916
922
}
917
923
918
924
sub validate_address {
919
925
my $address = shift ;
920
926
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 ;
922
928
# TRANSLATORS: Make sure to include [q] [d] [e] in your
923
929
# translation. The program will only accept English input
924
930
# at this point.
@@ -1223,7 +1229,7 @@ sub ssl_verify_params {
1223
1229
return (SSL_verify_mode => SSL_VERIFY_PEER(),
1224
1230
SSL_ca_file => $smtp_ssl_cert_path );
1225
1231
} 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 ) ;
1227
1233
}
1228
1234
}
1229
1235
@@ -1386,14 +1392,14 @@ sub send_message {
1386
1392
# supported commands
1387
1393
$smtp -> hello($smtp_domain );
1388
1394
} else {
1389
- die " Server does not support STARTTLS! " . $smtp -> message;
1395
+ die sprintf (__( " Server does not support STARTTLS! %s " ), $smtp -> message) ;
1390
1396
}
1391
1397
}
1392
1398
}
1393
1399
1394
1400
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 " ,
1397
1403
" encryption=$smtp_encryption " ,
1398
1404
" hello=$smtp_domain " ,
1399
1405
defined $smtp_server_port ? " port=$smtp_server_port " : " " ;
@@ -1410,10 +1416,10 @@ sub send_message {
1410
1416
$smtp -> datasend(" $line " ) or die $smtp -> message;
1411
1417
}
1412
1418
$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;
1414
1420
}
1415
1421
if ($quiet ) {
1416
- printf (( $dry_run ? " Dry-" : " " ). " Sent %s \n " , $subject );
1422
+ printf ( $dry_run ? __( " Dry-Sent %s \n " ) : __( " Sent %s \n " ) , $subject );
1417
1423
} else {
1418
1424
print ($dry_run ? __(" Dry-OK. Log says:\n " ) : __(" OK. Log says:\n " ));
1419
1425
if (!file_name_is_absolute($smtp_server )) {
@@ -1443,7 +1449,7 @@ sub send_message {
1443
1449
$message_num = 0;
1444
1450
1445
1451
foreach 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 ) ;
1447
1453
1448
1454
my $author = undef ;
1449
1455
my $sauthor = undef ;
@@ -1665,18 +1671,18 @@ sub recipients_cmd {
1665
1671
1666
1672
my @addresses = ();
1667
1673
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 ) ;
1669
1675
while (my $address = <$fh >) {
1670
1676
$address =~ s / ^\s *// g ;
1671
1677
$address =~ s /\s *$// g ;
1672
1678
$address = sanitize_address($address );
1673
1679
next if ($address eq $sender and $suppress_cc {' self' });
1674
1680
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 ;
1677
1683
}
1678
1684
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 ) ;
1680
1686
return @addresses ;
1681
1687
}
1682
1688
@@ -1730,10 +1736,10 @@ sub unique_email_list {
1730
1736
sub validate_patch {
1731
1737
my $fn = shift ;
1732
1738
open (my $fh , ' <' , $fn )
1733
- or die " unable to open $fn : $! \n " ;
1739
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1734
1740
while (my $line = <$fh >) {
1735
1741
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" ), $. ) ;
1737
1743
}
1738
1744
}
1739
1745
return ;
@@ -1749,10 +1755,11 @@ sub handle_backup {
1749
1755
(substr ($file , 0, $lastlen ) eq $last ) &&
1750
1756
($suffix = substr ($file , $lastlen )) !~ / ^[a-z0-9]/i ) {
1751
1757
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 ) ;
1753
1759
$skip = 1;
1754
1760
} 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 ),
1756
1763
valid_re => qr / ^(?:y|n)/ i ,
1757
1764
default => ' n' );
1758
1765
$skip = ($answer ne ' y' );
@@ -1780,7 +1787,7 @@ sub handle_backup_files {
1780
1787
sub file_has_nonascii {
1781
1788
my $fn = shift ;
1782
1789
open (my $fh , ' <' , $fn )
1783
- or die " unable to open $fn : $! \n " ;
1790
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1784
1791
while (my $line = <$fh >) {
1785
1792
return 1 if $line =~ / [^[:ascii:]]/ ;
1786
1793
}
@@ -1790,7 +1797,7 @@ sub file_has_nonascii {
1790
1797
sub body_or_subject_has_nonascii {
1791
1798
my $fn = shift ;
1792
1799
open (my $fh , ' <' , $fn )
1793
- or die " unable to open $fn : $! \n " ;
1800
+ or die sprintf (__( " unable to open %s : %s \n " ), $fn , $! ) ;
1794
1801
while (my $line = <$fh >) {
1795
1802
last if $line =~ / ^$ / ;
1796
1803
return 1 if $line =~ / ^Subject.*[^[:ascii:]]/ ;
0 commit comments