i18n: add--interactive: mark edit_hunk_manually message for translation

Mark message of edit_hunk_manually displayed in the editing file when user chooses 'e' option. The message had to be unfolded to allow translation of the $participle verb. Some messages end up being exactly the same for some use cases, but left it for easier change in the future, e.g., wanting to change wording of one particular use case. The comment character is now used according to the git configuration core.commentchar. 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 c9d9616471b42e995ccc5f78dfa09c64c6755fbf
1 file changed +39 -13
git-add--interactive.perl
+39 -13
@@ -1055,6 +1055,30 @@ sub color_diff {
1055 } @_;
1056 }
1057
1058 +my %edit_hunk_manually_modes = (
1059 + stage => N__(
1060 +"If the patch applies cleanly, the edited hunk will immediately be
1061 +marked for staging."),
1062 + stash => N__(
1063 +"If the patch applies cleanly, the edited hunk will immediately be
1064 +marked for stashing."),
1065 + reset_head => N__(
1066 +"If the patch applies cleanly, the edited hunk will immediately be
1067 +marked for unstaging."),
1068 + reset_nothead => N__(
1069 +"If the patch applies cleanly, the edited hunk will immediately be
1070 +marked for applying."),
1071 + checkout_index => N__(
1072 +"If the patch applies cleanly, the edited hunk will immediately be
1073 +marked for discarding"),
1074 + checkout_head => N__(
1075 +"If the patch applies cleanly, the edited hunk will immediately be
1076 +marked for discarding."),
1077 + checkout_nothead => N__(
1078 +"If the patch applies cleanly, the edited hunk will immediately be
1079 +marked for applying."),
1080 +);
1081 +
1082 sub edit_hunk_manually {
1083 my ($oldtext) = @_;
1084
@@ -1062,22 +1086,24 @@ sub edit_hunk_manually {
1086 my $fh;
1087 open $fh, '>', $hunkfile
1088 or die sprintf(__("failed to open hunk edit file for writing: %s"), $!);
1065 - print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
1089 + print $fh Git::comment_lines __("Manual hunk edit mode -- see bottom for a quick guide.\n");
1090 print $fh @$oldtext;
1067 - my $participle = $patch_mode_flavour{PARTICIPLE};
1091 my $is_reverse = $patch_mode_flavour{IS_REVERSE};
1092 my ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');
1070 - print $fh <<EOF;
1071 -# ---
1072 -# To remove '$remove_minus' lines, make them ' ' lines (context).
1073 -# To remove '$remove_plus' lines, delete them.
1074 -# Lines starting with # will be removed.
1075 -#
1076 -# If the patch applies cleanly, the edited hunk will immediately be
1077 -# marked for $participle. If it does not apply cleanly, you will be given
1078 -# an opportunity to edit again. If all lines of the hunk are removed,
1079 -# then the edit is aborted and the hunk is left unchanged.
1093 + my $comment_line_char = Git::get_comment_line_char;
1094 + print $fh Git::comment_lines sprintf(__ <<EOF, $remove_minus, $remove_plus, $comment_line_char),
1095 +---
1096 +To remove '%s' lines, make them ' ' lines (context).
1097 +To remove '%s' lines, delete them.
1098 +Lines starting with %s will be removed.
1099 EOF
1100 +__($edit_hunk_manually_modes{$patch_mode}),
1101 +# TRANSLATORS: 'it' refers to the patch mentioned in the previous messages.
1102 +__ <<EOF2 ;
1103 +If it does not apply cleanly, you will be given an opportunity to
1104 +edit again. If all lines of the hunk are removed, then the edit is
1105 +aborted and the hunk is left unchanged.
1106 +EOF2
1107 close $fh;
1108
1109 chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
@@ -1089,7 +1115,7 @@ EOF
1115
1116 open $fh, '<', $hunkfile
1117 or die sprintf(__("failed to open hunk edit file for reading: %s"), $!);
1092 - my @newtext = grep { !/^#/ } <$fh>;
1118 + my @newtext = grep { !/^$comment_line_char/ } <$fh>;
1119 close $fh;
1120 unlink $hunkfile;
1121