i18n: add--interactive: mark strings for translation
Mark simple strings (without interpolation) for translation. Brackets around first parameter of ternary operator is necessary because otherwise xgettext fails to extract strings marked for translation from the rest of the file. 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
258e7790b3a57c3b1e8c1fdc3e2d1697b9e0b184
1 file changed
+42
-34
git-add--interactive.perl
+42
-34
@@ -4,6 +4,7 @@ use 5.008;
4
use strict;
5
use warnings;
6
use Git;
7
+use Git::I18N;
8
9
binmode(STDOUT, ":raw");
10
@@ -252,8 +253,9 @@ sub list_untracked {
253
run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
254
}
255
255
-my $status_fmt = '%12s %12s %s';
256
-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
256
+# TRANSLATORS: you can adjust this to align "git add -i" status menu
257
+my $status_fmt = __('%12s %12s %s');
258
+my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'));
259
260
{
261
my $initial;
@@ -679,7 +681,7 @@ sub update_cmd {
681
my @mods = list_modified('file-only');
682
return if (!@mods);
683
682
- my @update = list_and_choose({ PROMPT => 'Update',
684
+ my @update = list_and_choose({ PROMPT => __('Update'),
685
HEADER => $status_head, },
686
@mods);
687
if (@update) {
@@ -691,7 +693,7 @@ sub update_cmd {
693
}
694
695
sub revert_cmd {
694
- my @update = list_and_choose({ PROMPT => 'Revert',
696
+ my @update = list_and_choose({ PROMPT => __('Revert'),
697
HEADER => $status_head, },
698
list_modified());
699
if (@update) {
@@ -725,13 +727,13 @@ sub revert_cmd {
727
}
728
729
sub add_untracked_cmd {
728
- my @add = list_and_choose({ PROMPT => 'Add untracked' },
730
+ my @add = list_and_choose({ PROMPT => __('Add untracked') },
731
list_untracked());
732
if (@add) {
733
system(qw(git update-index --add --), @add);
734
say_n_paths('added', @add);
735
} else {
734
- print "No untracked files.\n";
736
+ print __("No untracked files.\n");
737
}
738
print "\n";
739
}
@@ -1163,8 +1165,14 @@ sub edit_hunk_loop {
1165
}
1166
else {
1167
prompt_yesno(
1166
- 'Your edited hunk does not apply. Edit again '
1167
- . '(saying "no" discards!) [y/n]? '
1168
+ # TRANSLATORS: do not translate [y/n]
1169
+ # The program will only accept that input
1170
+ # at this point.
1171
+ # Consider translating (saying "no" discards!) as
1172
+ # (saying "n" for "no" discards!) if the translation
1173
+ # of the word "no" does not start with n.
1174
+ __('Your edited hunk does not apply. Edit again '
1175
+ . '(saying "no" discards!) [y/n]? ')
1176
) or return undef;
1177
}
1178
}
@@ -1210,11 +1218,11 @@ sub apply_patch_for_checkout_commit {
1218
run_git_apply 'apply '.$reverse, @_;
1219
return 1;
1220
} elsif (!$applies_index) {
1213
- print colored $error_color, "The selected hunks do not apply to the index!\n";
1214
- if (prompt_yesno "Apply them to the worktree anyway? ") {
1221
+ print colored $error_color, __("The selected hunks do not apply to the index!\n");
1222
+ if (prompt_yesno __("Apply them to the worktree anyway? ")) {
1223
return run_git_apply 'apply '.$reverse, @_;
1224
} else {
1217
- print colored $error_color, "Nothing was applied.\n";
1225
+ print colored $error_color, __("Nothing was applied.\n");
1226
return 0;
1227
}
1228
} else {
@@ -1234,9 +1242,9 @@ sub patch_update_cmd {
1242
1243
if (!@mods) {
1244
if (@all_mods) {
1237
- print STDERR "Only binary files changed.\n";
1245
+ print STDERR __("Only binary files changed.\n");
1246
} else {
1239
- print STDERR "No changes.\n";
1247
+ print STDERR __("No changes.\n");
1248
}
1249
return 0;
1250
}
@@ -1244,7 +1252,7 @@ sub patch_update_cmd {
1252
@them = @mods;
1253
}
1254
else {
1247
- @them = list_and_choose({ PROMPT => 'Patch update',
1255
+ @them = list_and_choose({ PROMPT => __('Patch update'),
1256
HEADER => $status_head, },
1257
@mods);
1258
}
@@ -1394,12 +1402,12 @@ sub patch_update_file {
1402
my $response = $1;
1403
my $no = $ix > 10 ? $ix - 10 : 0;
1404
while ($response eq '') {
1397
- my $extra = "";
1405
$no = display_hunks(\@hunk, $no);
1406
if ($no < $num) {
1400
- $extra = " (<ret> to see more)";
1407
+ print __("go to which hunk (<ret> to see more)? ");
1408
+ } else {
1409
+ print __("go to which hunk? ");
1410
}
1402
- print "go to which hunk$extra? ";
1411
$response = <STDIN>;
1412
if (!defined $response) {
1413
$response = '';
@@ -1436,7 +1444,7 @@ sub patch_update_file {
1444
elsif ($line =~ m|^/(.*)|) {
1445
my $regex = $1;
1446
if ($1 eq "") {
1439
- print colored $prompt_color, "search for regex? ";
1447
+ print colored $prompt_color, __("search for regex? ");
1448
$regex = <STDIN>;
1449
if (defined $regex) {
1450
chomp $regex;
@@ -1459,7 +1467,7 @@ sub patch_update_file {
1467
$iy++;
1468
$iy = 0 if ($iy >= $num);
1469
if ($ix == $iy) {
1462
- error_msg "No hunk matches the given pattern\n";
1470
+ error_msg __("No hunk matches the given pattern\n");
1471
last;
1472
}
1473
}
@@ -1471,7 +1479,7 @@ sub patch_update_file {
1479
$ix--;
1480
}
1481
else {
1474
- error_msg "No previous hunk\n";
1482
+ error_msg __("No previous hunk\n");
1483
}
1484
next;
1485
}
@@ -1480,7 +1488,7 @@ sub patch_update_file {
1488
$ix++;
1489
}
1490
else {
1483
- error_msg "No next hunk\n";
1491
+ error_msg __("No next hunk\n");
1492
}
1493
next;
1494
}
@@ -1493,13 +1501,13 @@ sub patch_update_file {
1501
}
1502
}
1503
else {
1496
- error_msg "No previous hunk\n";
1504
+ error_msg __("No previous hunk\n");
1505
}
1506
next;
1507
}
1508
elsif ($line =~ /^j/) {
1509
if ($other !~ /j/) {
1502
- error_msg "No next hunk\n";
1510
+ error_msg __("No next hunk\n");
1511
next;
1512
}
1513
}
@@ -1557,18 +1565,18 @@ sub diff_cmd {
1565
my @mods = list_modified('index-only');
1566
@mods = grep { !($_->{BINARY}) } @mods;
1567
return if (!@mods);
1560
- my (@them) = list_and_choose({ PROMPT => 'Review diff',
1568
+ my (@them) = list_and_choose({ PROMPT => __('Review diff'),
1569
IMMEDIATE => 1,
1570
HEADER => $status_head, },
1571
@mods);
1572
return if (!@them);
1565
- my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
1573
+ my $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';
1574
system(qw(git diff -p --cached), $reference, '--',
1575
map { $_->{VALUE} } @them);
1576
}
1577
1578
sub quit_cmd {
1571
- print "Bye.\n";
1579
+ print __("Bye.\n");
1580
exit(0);
1581
}
1582
@@ -1591,32 +1599,32 @@ sub process_args {
1599
if ($1 eq 'reset') {
1600
$patch_mode = 'reset_head';
1601
$patch_mode_revision = 'HEAD';
1594
- $arg = shift @ARGV or die "missing --";
1602
+ $arg = shift @ARGV or die __("missing --");
1603
if ($arg ne '--') {
1604
$patch_mode_revision = $arg;
1605
$patch_mode = ($arg eq 'HEAD' ?
1606
'reset_head' : 'reset_nothead');
1599
- $arg = shift @ARGV or die "missing --";
1607
+ $arg = shift @ARGV or die __("missing --");
1608
}
1609
} elsif ($1 eq 'checkout') {
1602
- $arg = shift @ARGV or die "missing --";
1610
+ $arg = shift @ARGV or die __("missing --");
1611
if ($arg eq '--') {
1612
$patch_mode = 'checkout_index';
1613
} else {
1614
$patch_mode_revision = $arg;
1615
$patch_mode = ($arg eq 'HEAD' ?
1616
'checkout_head' : 'checkout_nothead');
1609
- $arg = shift @ARGV or die "missing --";
1617
+ $arg = shift @ARGV or die __("missing --");
1618
}
1619
} elsif ($1 eq 'stage' or $1 eq 'stash') {
1620
$patch_mode = $1;
1613
- $arg = shift @ARGV or die "missing --";
1621
+ $arg = shift @ARGV or die __("missing --");
1622
} else {
1623
die "unknown --patch mode: $1";
1624
}
1625
} else {
1626
$patch_mode = 'stage';
1619
- $arg = shift @ARGV or die "missing --";
1627
+ $arg = shift @ARGV or die __("missing --");
1628
}
1629
die "invalid argument $arg, expecting --"
1630
unless $arg eq "--";
@@ -1638,10 +1646,10 @@ sub main_loop {
1646
[ 'help', \&help_cmd, ],
1647
);
1648
while (1) {
1641
- my ($it) = list_and_choose({ PROMPT => 'What now',
1649
+ my ($it) = list_and_choose({ PROMPT => __('What now'),
1650
SINGLETON => 1,
1651
LIST_FLAT => 4,
1644
- HEADER => '*** Commands ***',
1652
+ HEADER => __('*** Commands ***'),
1653
ON_EOF => \&quit_cmd,
1654
IMMEDIATE => 1 }, @cmd);
1655
if ($it) {