git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Vasco Almeida <vascomalmeida@sapo.pt>
To: git@vger.kernel.org
Cc: "Vasco Almeida" <vascomalmeida@sapo.pt>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Jean-Noël AVILA" <jn.avila@free.fr>,
	"Jakub Narębski" <jnareb@gmail.com>,
	"David Aguilar" <davvid@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v4 01/14] i18n: add--interactive: mark strings for translation
Date: Mon, 10 Oct 2016 12:54:36 +0000	[thread overview]
Message-ID: <20161010125449.7929-2-vascomalmeida@sapo.pt> (raw)
In-Reply-To: <20161010125449.7929-1-vascomalmeida@sapo.pt>
In-Reply-To: <20161005172110.30801-1-vascomalmeida@sapo.pt>

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>
---
 git-add--interactive.perl | 76 ++++++++++++++++++++++++++---------------------
 1 file changed, 42 insertions(+), 34 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index ee3d812..cf216ec 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -4,6 +4,7 @@ use 5.008;
 use strict;
 use warnings;
 use Git;
+use Git::I18N;
 
 binmode(STDOUT, ":raw");
 
@@ -253,8 +254,9 @@ sub list_untracked {
 	run_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);
 }
 
-my $status_fmt = '%12s %12s %s';
-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
+# TRANSLATORS: you can adjust this to align "git add -i" status menu
+my $status_fmt = __('%12s %12s %s');
+my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'));
 
 {
 	my $initial;
@@ -680,7 +682,7 @@ sub update_cmd {
 	my @mods = list_modified('file-only');
 	return if (!@mods);
 
-	my @update = list_and_choose({ PROMPT => 'Update',
+	my @update = list_and_choose({ PROMPT => __('Update'),
 				       HEADER => $status_head, },
 				     @mods);
 	if (@update) {
@@ -692,7 +694,7 @@ sub update_cmd {
 }
 
 sub revert_cmd {
-	my @update = list_and_choose({ PROMPT => 'Revert',
+	my @update = list_and_choose({ PROMPT => __('Revert'),
 				       HEADER => $status_head, },
 				     list_modified());
 	if (@update) {
@@ -726,13 +728,13 @@ sub revert_cmd {
 }
 
 sub add_untracked_cmd {
-	my @add = list_and_choose({ PROMPT => 'Add untracked' },
+	my @add = list_and_choose({ PROMPT => __('Add untracked') },
 				  list_untracked());
 	if (@add) {
 		system(qw(git update-index --add --), @add);
 		say_n_paths('added', @add);
 	} else {
-		print "No untracked files.\n";
+		print __("No untracked files.\n");
 	}
 	print "\n";
 }
@@ -1166,8 +1168,14 @@ sub edit_hunk_loop {
 		}
 		else {
 			prompt_yesno(
-				'Your edited hunk does not apply. Edit again '
-				. '(saying "no" discards!) [y/n]? '
+				# TRANSLATORS: do not translate [y/n]
+				# The program will only accept that input
+				# at this point.
+				# Consider translating (saying "no" discards!) as
+				# (saying "n" for "no" discards!) if the translation
+				# of the word "no" does not start with n.
+				__('Your edited hunk does not apply. Edit again '
+				   . '(saying "no" discards!) [y/n]? ')
 				) or return undef;
 		}
 	}
@@ -1213,11 +1221,11 @@ sub apply_patch_for_checkout_commit {
 		run_git_apply 'apply '.$reverse, @_;
 		return 1;
 	} elsif (!$applies_index) {
-		print colored $error_color, "The selected hunks do not apply to the index!\n";
-		if (prompt_yesno "Apply them to the worktree anyway? ") {
+		print colored $error_color, __("The selected hunks do not apply to the index!\n");
+		if (prompt_yesno __("Apply them to the worktree anyway? ")) {
 			return run_git_apply 'apply '.$reverse, @_;
 		} else {
-			print colored $error_color, "Nothing was applied.\n";
+			print colored $error_color, __("Nothing was applied.\n");
 			return 0;
 		}
 	} else {
@@ -1237,9 +1245,9 @@ sub patch_update_cmd {
 
 	if (!@mods) {
 		if (@all_mods) {
-			print STDERR "Only binary files changed.\n";
+			print STDERR __("Only binary files changed.\n");
 		} else {
-			print STDERR "No changes.\n";
+			print STDERR __("No changes.\n");
 		}
 		return 0;
 	}
@@ -1247,7 +1255,7 @@ sub patch_update_cmd {
 		@them = @mods;
 	}
 	else {
-		@them = list_and_choose({ PROMPT => 'Patch update',
+		@them = list_and_choose({ PROMPT => __('Patch update'),
 					  HEADER => $status_head, },
 					@mods);
 	}
@@ -1397,12 +1405,12 @@ sub patch_update_file {
 				my $response = $1;
 				my $no = $ix > 10 ? $ix - 10 : 0;
 				while ($response eq '') {
-					my $extra = "";
 					$no = display_hunks(\@hunk, $no);
 					if ($no < $num) {
-						$extra = " (<ret> to see more)";
+						print __("go to which hunk (<ret> to see more)? ");
+					} else {
+						print __("go to which hunk? ");
 					}
-					print "go to which hunk$extra? ";
 					$response = <STDIN>;
 					if (!defined $response) {
 						$response = '';
@@ -1439,7 +1447,7 @@ sub patch_update_file {
 			elsif ($line =~ m|^/(.*)|) {
 				my $regex = $1;
 				if ($1 eq "") {
-					print colored $prompt_color, "search for regex? ";
+					print colored $prompt_color, __("search for regex? ");
 					$regex = <STDIN>;
 					if (defined $regex) {
 						chomp $regex;
@@ -1462,7 +1470,7 @@ sub patch_update_file {
 					$iy++;
 					$iy = 0 if ($iy >= $num);
 					if ($ix == $iy) {
-						error_msg "No hunk matches the given pattern\n";
+						error_msg __("No hunk matches the given pattern\n");
 						last;
 					}
 				}
@@ -1474,7 +1482,7 @@ sub patch_update_file {
 					$ix--;
 				}
 				else {
-					error_msg "No previous hunk\n";
+					error_msg __("No previous hunk\n");
 				}
 				next;
 			}
@@ -1483,7 +1491,7 @@ sub patch_update_file {
 					$ix++;
 				}
 				else {
-					error_msg "No next hunk\n";
+					error_msg __("No next hunk\n");
 				}
 				next;
 			}
@@ -1496,13 +1504,13 @@ sub patch_update_file {
 					}
 				}
 				else {
-					error_msg "No previous hunk\n";
+					error_msg __("No previous hunk\n");
 				}
 				next;
 			}
 			elsif ($line =~ /^j/) {
 				if ($other !~ /j/) {
-					error_msg "No next hunk\n";
+					error_msg __("No next hunk\n");
 					next;
 				}
 			}
@@ -1560,18 +1568,18 @@ sub diff_cmd {
 	my @mods = list_modified('index-only');
 	@mods = grep { !($_->{BINARY}) } @mods;
 	return if (!@mods);
-	my (@them) = list_and_choose({ PROMPT => 'Review diff',
+	my (@them) = list_and_choose({ PROMPT => __('Review diff'),
 				     IMMEDIATE => 1,
 				     HEADER => $status_head, },
 				   @mods);
 	return if (!@them);
-	my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
+	my $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';
 	system(qw(git diff -p --cached), $reference, '--',
 		map { $_->{VALUE} } @them);
 }
 
 sub quit_cmd {
-	print "Bye.\n";
+	print __("Bye.\n");
 	exit(0);
 }
 
@@ -1594,32 +1602,32 @@ sub process_args {
 			if ($1 eq 'reset') {
 				$patch_mode = 'reset_head';
 				$patch_mode_revision = 'HEAD';
-				$arg = shift @ARGV or die "missing --";
+				$arg = shift @ARGV or die __("missing --");
 				if ($arg ne '--') {
 					$patch_mode_revision = $arg;
 					$patch_mode = ($arg eq 'HEAD' ?
 						       'reset_head' : 'reset_nothead');
-					$arg = shift @ARGV or die "missing --";
+					$arg = shift @ARGV or die __("missing --");
 				}
 			} elsif ($1 eq 'checkout') {
-				$arg = shift @ARGV or die "missing --";
+				$arg = shift @ARGV or die __("missing --");
 				if ($arg eq '--') {
 					$patch_mode = 'checkout_index';
 				} else {
 					$patch_mode_revision = $arg;
 					$patch_mode = ($arg eq 'HEAD' ?
 						       'checkout_head' : 'checkout_nothead');
-					$arg = shift @ARGV or die "missing --";
+					$arg = shift @ARGV or die __("missing --");
 				}
 			} elsif ($1 eq 'stage' or $1 eq 'stash') {
 				$patch_mode = $1;
-				$arg = shift @ARGV or die "missing --";
+				$arg = shift @ARGV or die __("missing --");
 			} else {
 				die "unknown --patch mode: $1";
 			}
 		} else {
 			$patch_mode = 'stage';
-			$arg = shift @ARGV or die "missing --";
+			$arg = shift @ARGV or die __("missing --");
 		}
 		die "invalid argument $arg, expecting --"
 		    unless $arg eq "--";
@@ -1641,10 +1649,10 @@ sub main_loop {
 		   [ 'help', \&help_cmd, ],
 	);
 	while (1) {
-		my ($it) = list_and_choose({ PROMPT => 'What now',
+		my ($it) = list_and_choose({ PROMPT => __('What now'),
 					     SINGLETON => 1,
 					     LIST_FLAT => 4,
-					     HEADER => '*** Commands ***',
+					     HEADER => __('*** Commands ***'),
 					     ON_EOF => \&quit_cmd,
 					     IMMEDIATE => 1 }, @cmd);
 		if ($it) {
-- 
2.7.4


  parent reply	other threads:[~2016-10-10 12:55 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 17:20 [PATCH v3 00/14] Mark strings in Perl scripts for translation Vasco Almeida
2016-10-05 17:20 ` [PATCH v3 01/14] i18n: add--interactive: mark strings " Vasco Almeida
2016-10-05 17:20 ` [PATCH v3 02/14] i18n: add--interactive: mark simple here-documents " Vasco Almeida
2016-10-05 17:20 ` [PATCH v3 03/14] i18n: add--interactive: mark strings with interpolation " Vasco Almeida
2016-10-05 22:28   ` Junio C Hamano
2016-10-05 17:21 ` [PATCH v3 04/14] i18n: clean.c: match string with git-add--interactive.perl Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 05/14] i18n: add--interactive: mark plural strings Vasco Almeida
2016-10-05 22:41   ` Junio C Hamano
2016-10-05 17:21 ` [PATCH v3 06/14] i18n: add--interactive: mark patch prompt for translation Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 07/14] i18n: add--interactive: i18n of help_patch_cmd Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 08/14] i18n: add--interactive: mark edit_hunk_manually message for translation Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 09/14] i18n: add--interactive: remove %patch_modes entries Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 10/14] i18n: add--interactive: mark status words for translation Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 11/14] i18n: send-email: mark strings " Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 12/14] i18n: send-email: mark warnings and errors " Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 13/14] i18n: send-email: mark string with interpolation " Vasco Almeida
2016-10-05 17:21 ` [PATCH v3 14/14] i18n: difftool: mark warnings " Vasco Almeida
2016-10-05 21:50 ` [PATCH v3 00/14] Mark strings in Perl scripts " Jakub Narębski
2016-10-10 12:54 ` [PATCH v4 " Vasco Almeida
2016-10-27 17:08   ` Junio C Hamano
2016-10-10 12:54 ` Vasco Almeida [this message]
2016-10-19 18:14   ` [PATCH v4 01/14] i18n: add--interactive: mark strings " Junio C Hamano
2016-10-20 16:21     ` Vasco Almeida
2016-10-20 16:25       ` Junio C Hamano
2016-10-10 12:54 ` [PATCH v4 02/14] i18n: add--interactive: mark simple here-documents " Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 03/14] i18n: add--interactive: mark strings with interpolation " Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 04/14] i18n: clean.c: match string with git-add--interactive.perl Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 05/14] i18n: add--interactive: mark plural strings Vasco Almeida
2016-10-19 18:40   ` Junio C Hamano
2016-10-20 16:29     ` Vasco Almeida
2016-10-20 16:35   ` Vasco Almeida
2016-10-20 17:11     ` Junio C Hamano
2016-10-10 12:54 ` [PATCH v4 06/14] i18n: add--interactive: mark patch prompt for translation Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 07/14] i18n: add--interactive: i18n of help_patch_cmd Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 08/14] i18n: add--interactive: mark edit_hunk_manually message for translation Vasco Almeida
2016-11-07 16:04   ` Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 09/14] i18n: add--interactive: remove %patch_modes entries Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 10/14] i18n: add--interactive: mark status words for translation Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 11/14] i18n: send-email: mark strings " Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 12/14] i18n: send-email: mark warnings and errors " Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 13/14] i18n: send-email: mark string with interpolation " Vasco Almeida
2016-10-10 12:54 ` [PATCH v4 14/14] i18n: difftool: mark warnings " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 00/16] Mark strings in Perl scripts " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 01/16] Git.pm: add subroutines for commenting lines Vasco Almeida
2016-11-09  1:06   ` Junio C Hamano
2016-11-09 17:02     ` Vasco Almeida
2016-11-09 22:25       ` Jakub Narębski
2016-11-09 23:16         ` Junio C Hamano
2016-11-08 12:08 ` [PATCH v5 02/16] i18n: add--interactive: mark strings for translation Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 03/16] i18n: add--interactive: mark simple here-documents " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 04/16] i18n: add--interactive: mark strings with interpolation " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 05/16] i18n: clean.c: match string with git-add--interactive.perl Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 06/16] i18n: add--interactive: mark plural strings Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 07/16] i18n: add--interactive: mark patch prompt for translation Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 08/16] i18n: add--interactive: i18n of help_patch_cmd Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 09/16] i18n: add--interactive: mark edit_hunk_manually message for translation Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 10/16] i18n: add--interactive: remove %patch_modes entries Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 11/16] i18n: add--interactive: mark status words for translation Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 12/16] i18n: send-email: mark strings " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 13/16] i18n: send-email: mark warnings and errors " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 14/16] i18n: send-email: mark string with interpolation " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 15/16] i18n: send-email: mark composing message " Vasco Almeida
2016-11-08 12:08 ` [PATCH v5 16/16] i18n: difftool: mark warnings " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 00/16] Mark strings in Perl scripts " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 01/16] Git.pm: add subroutines for commenting lines Vasco Almeida
2016-11-22 14:10   ` Vasco Almeida
2016-11-22 17:42     ` Junio C Hamano
2016-12-09 17:19       ` Vasco Almeida
2016-12-09 17:32         ` Johannes Schindelin
2016-12-09 22:23           ` Junio C Hamano
2016-12-10 10:08             ` Vasco Almeida
2016-12-10 22:09               ` Junio C Hamano
2016-12-13 11:17                 ` Vasco Almeida
2016-12-13 18:15                   ` Junio C Hamano
2016-11-11 12:45 ` [PATCH v6 02/16] i18n: add--interactive: mark strings for translation Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 03/16] i18n: add--interactive: mark simple here-documents " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 04/16] i18n: add--interactive: mark strings with interpolation " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 05/16] i18n: clean.c: match string with git-add--interactive.perl Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 06/16] i18n: add--interactive: mark plural strings Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 07/16] i18n: add--interactive: mark patch prompt for translation Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 08/16] i18n: add--interactive: i18n of help_patch_cmd Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 09/16] i18n: add--interactive: mark edit_hunk_manually message for translation Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 10/16] i18n: add--interactive: remove %patch_modes entries Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 11/16] i18n: add--interactive: mark status words for translation Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 12/16] i18n: send-email: mark strings " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 13/16] i18n: send-email: mark warnings and errors " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 14/16] i18n: send-email: mark string with interpolation " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 15/16] i18n: send-email: mark composing message " Vasco Almeida
2016-11-11 12:45 ` [PATCH v6 16/16] i18n: difftool: mark warnings " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 00/16] Mark strings in Perl scripts " Vasco Almeida
2016-12-14 19:02   ` Junio C Hamano
2016-12-14 12:54 ` [PATCH v7 01/16] Git.pm: add subroutines for commenting lines Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 02/16] i18n: add--interactive: mark strings for translation Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 03/16] i18n: add--interactive: mark simple here-documents " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 04/16] i18n: add--interactive: mark strings with interpolation " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 05/16] i18n: clean.c: match string with git-add--interactive.perl Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 06/16] i18n: add--interactive: mark plural strings Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 07/16] i18n: add--interactive: mark patch prompt for translation Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 08/16] i18n: add--interactive: i18n of help_patch_cmd Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 09/16] i18n: add--interactive: mark edit_hunk_manually message for translation Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 10/16] i18n: add--interactive: remove %patch_modes entries Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 11/16] i18n: add--interactive: mark status words for translation Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 12/16] i18n: send-email: mark strings " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 13/16] i18n: send-email: mark warnings and errors " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 14/16] i18n: send-email: mark string with interpolation " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 15/16] i18n: send-email: mark composing message " Vasco Almeida
2016-12-14 12:54 ` [PATCH v7 16/16] i18n: difftool: mark warnings " Vasco Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161010125449.7929-2-vascomalmeida@sapo.pt \
    --to=vascomalmeida@sapo.pt \
    --cc=avarab@gmail.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jn.avila@free.fr \
    --cc=jnareb@gmail.com \
    --cc=worldhello.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).