i18n: add--interactive: mark strings with interpolation for translation

Since at this point Git::I18N.perl lacks support for Perl i18n placeholder substitution, use of sprintf following die or error_msg is necessary for placeholder substitution take place. Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Vasco Almeida committed Dec 14, 2016 at 11:54 UTC 13c58c1754393c17fb50b63ae9a3bc07195e520c
1 file changed +13 -12
git-add--interactive.perl
+13 -12
@@ -614,12 +614,12 @@ sub list_and_choose {
614 else {
615 $bottom = $top = find_unique($choice, @stuff);
616 if (!defined $bottom) {
617 - error_msg "Huh ($choice)?\n";
617 + error_msg sprintf(__("Huh (%s)?\n"), $choice);
618 next TOPLOOP;
619 }
620 }
621 if ($opts->{SINGLETON} && $bottom != $top) {
622 - error_msg "Huh ($choice)?\n";
622 + error_msg sprintf(__("Huh (%s)?\n"), $choice);
623 next TOPLOOP;
624 }
625 for ($i = $bottom-1; $i <= $top-1; $i++) {
@@ -716,7 +716,7 @@ sub revert_cmd {
716 $_->{INDEX_ADDDEL} eq 'create') {
717 system(qw(git update-index --force-remove --),
718 $_->{VALUE});
719 - print "note: $_->{VALUE} is untracked now.\n";
719 + printf(__("note: %s is untracked now.\n"), $_->{VALUE});
720 }
721 }
722 }
@@ -1053,7 +1053,7 @@ sub edit_hunk_manually {
1053 my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
1054 my $fh;
1055 open $fh, '>', $hunkfile
1056 - or die "failed to open hunk edit file for writing: " . $!;
1056 + or die sprintf(__("failed to open hunk edit file for writing: %s"), $!);
1057 print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
1058 print $fh @$oldtext;
1059 my $participle = $patch_mode_flavour{PARTICIPLE};
@@ -1080,7 +1080,7 @@ EOF
1080 }
1081
1082 open $fh, '<', $hunkfile
1083 - or die "failed to open hunk edit file for reading: " . $!;
1083 + or die sprintf(__("failed to open hunk edit file for reading: %s"), $!);
1084 my @newtext = grep { !/^#/ } <$fh>;
1085 close $fh;
1086 unlink $hunkfile;
@@ -1233,7 +1233,7 @@ sub apply_patch_for_checkout_commit {
1233
1234 sub patch_update_cmd {
1235 my @all_mods = list_modified($patch_mode_flavour{FILTER});
1236 - error_msg "ignoring unmerged: $_->{VALUE}\n"
1236 + error_msg sprintf(__("ignoring unmerged: %s\n"), $_->{VALUE})
1237 for grep { $_->{UNMERGED} } @all_mods;
1238 @all_mods = grep { !$_->{UNMERGED} } @all_mods;
1239
@@ -1415,7 +1415,8 @@ sub patch_update_file {
1415 chomp $response;
1416 }
1417 if ($response !~ /^\s*\d+\s*$/) {
1418 - error_msg "Invalid number: '$response'\n";
1418 + error_msg sprintf(__("Invalid number: '%s'\n"),
1419 + $response);
1420 } elsif (0 < $response && $response <= $num) {
1421 $ix = $response - 1;
1422 } else {
@@ -1457,7 +1458,7 @@ sub patch_update_file {
1458 if ($@) {
1459 my ($err,$exp) = ($@, $1);
1460 $err =~ s/ at .*git-add--interactive line \d+, <STDIN> line \d+.*$//;
1460 - error_msg "Malformed search regexp $exp: $err\n";
1461 + error_msg sprintf(__("Malformed search regexp %s: %s\n"), $exp, $err);
1462 next;
1463 }
1464 my $iy = $ix;
@@ -1622,18 +1623,18 @@ sub process_args {
1623 $patch_mode = $1;
1624 $arg = shift @ARGV or die __("missing --");
1625 } else {
1625 - die "unknown --patch mode: $1";
1626 + die sprintf(__("unknown --patch mode: %s"), $1);
1627 }
1628 } else {
1629 $patch_mode = 'stage';
1630 $arg = shift @ARGV or die __("missing --");
1631 }
1631 - die "invalid argument $arg, expecting --"
1632 - unless $arg eq "--";
1632 + die sprintf(__("invalid argument %s, expecting --"),
1633 + $arg) unless $arg eq "--";
1634 %patch_mode_flavour = %{$patch_modes{$patch_mode}};
1635 }
1636 elsif ($arg ne "--") {
1636 - die "invalid argument $arg, expecting --";
1637 + die sprintf(__("invalid argument %s, expecting --"), $arg);
1638 }
1639 }
1640