Skip to content

Commit c9d9616

Browse files
vascoolgitster
authored andcommitted
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>
1 parent 186b52c commit c9d9616

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

git-add--interactive.perl

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,29 +1055,55 @@ sub color_diff {
10551055
} @_;
10561056
}
10571057

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+
10581082
sub edit_hunk_manually {
10591083
my ($oldtext) = @_;
10601084

10611085
my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
10621086
my $fh;
10631087
open $fh, '>', $hunkfile
10641088
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");
10661090
print $fh @$oldtext;
1067-
my $participle = $patch_mode_flavour{PARTICIPLE};
10681091
my $is_reverse = $patch_mode_flavour{IS_REVERSE};
10691092
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.
10801099
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
10811107
close $fh;
10821108

10831109
chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
@@ -1089,7 +1115,7 @@ sub edit_hunk_manually {
10891115

10901116
open $fh, '<', $hunkfile
10911117
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>;
10931119
close $fh;
10941120
unlink $hunkfile;
10951121

0 commit comments

Comments
 (0)