git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v7 11/16] i18n: add--interactive: mark status words for translation

From
Vasco Almeida <vascomalmeida@sapo.pt>
Date
Dec 14, 2016, 12:54 UTC
Message-ID
<20161214125439.8822-12-vascomalmeida@sapo.pt>
In-Reply-To
<20161214125439.8822-1-vascomalmeida@sapo.pt>

Mark words 'nothing', 'unchanged' and 'binary' used to display what has been staged or not, in "git add -i" status command.

Alternatively one could mark N__('nothing') no-op in order to xgettext(1) extract the string and then trigger the translation at run time only with __($print->{FILE}), but that has the side effect of triggering retrieval of translations for the changes indicator too (e.g. +2/-1) which may or may not be a problem.

To avoid that potential problem, mark only where there is certain to trigger translation only of those words but in this case we must also retrieve the translation for the eq tests, since the value assigned was of the translation, not the English source.

Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
 git-add--interactive.perl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index d3785e8d7..4e0ab5a9b 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -295,7 +295,7 @@ sub list_modified {
 			my ($change, $bin);
 			$file = unquote_path($file);
 			if ($add eq '-' && $del eq '-') {
-				$change = 'binary';
+				$change = __('binary');
 				$bin = 1;
 			}
 			else {
@@ -304,7 +304,7 @@ sub list_modified {
 			$data{$file} = {
 				INDEX => $change,
 				BINARY => $bin,
-				FILE => 'nothing',
+				FILE => __('nothing'),
 			}
 		}
 		elsif (($adddel, $file) =
@@ -320,7 +320,7 @@ sub list_modified {
 			$file = unquote_path($file);
 			my ($change, $bin);
 			if ($add eq '-' && $del eq '-') {
-				$change = 'binary';
+				$change = __('binary');
 				$bin = 1;
 			}
 			else {
@@ -340,7 +340,7 @@ sub list_modified {
 			$file = unquote_path($2);
 			if (!exists $data{$file}) {
 				$data{$file} = +{
-					INDEX => 'unchanged',
+					INDEX => __('unchanged'),
 					BINARY => 0,
 				};
 			}
@@ -355,10 +355,10 @@ sub list_modified {
 
 		if ($only) {
 			if ($only eq 'index-only') {
-				next if ($it->{INDEX} eq 'unchanged');
+				next if ($it->{INDEX} eq __('unchanged'));
 			}
 			if ($only eq 'file-only') {
-				next if ($it->{FILE} eq 'nothing');
+				next if ($it->{FILE} eq __('nothing'));
 			}
 		}
 		push @return, +{
-- 
2.11.0.44.g7d42c6c
Previous: Vasco AlmeidaNext: Vasco Almeida
Message 4 of 18 in “Mark strings in Perl scripts for translation”
  1. 00/16 Mark strings in Perl scripts for translationVasco Almeida, Dec 14, 2016
  2. 02/16 i18n: add--interactive: mark strings for translationVasco Almeida, Dec 14, 2016
  3. 06/16 i18n: add--interactive: mark plural stringsVasco Almeida, Dec 14, 2016
  4. 11/16 i18n: add--interactive: mark status words for translationVasco Almeida, Dec 14, 2016
  5. 05/16 i18n: clean.c: match string with git-add--interactive.perlVasco Almeida, Dec 14, 2016
  6. 12/16 i18n: send-email: mark strings for translationVasco Almeida, Dec 14, 2016
  7. 03/16 i18n: add--interactive: mark simple here-documents for translationVasco Almeida, Dec 14, 2016
  8. 09/16 i18n: add--interactive: mark edit_hunk_manually message for translationVasco Almeida, Dec 14, 2016
  9. 08/16 i18n: add--interactive: i18n of help_patch_cmdVasco Almeida, Dec 14, 2016
  10. 01/16 Git.pm: add subroutines for commenting linesVasco Almeida, Dec 14, 2016
  11. 10/16 i18n: add--interactive: remove %patch_modes entriesVasco Almeida, Dec 14, 2016
  12. 14/16 i18n: send-email: mark string with interpolation for translationVasco Almeida, Dec 14, 2016
  13. 07/16 i18n: add--interactive: mark patch prompt for translationVasco Almeida, Dec 14, 2016
  14. 04/16 i18n: add--interactive: mark strings with interpolation for translationVasco Almeida, Dec 14, 2016
  15. 13/16 i18n: send-email: mark warnings and errors for translationVasco Almeida, Dec 14, 2016
  16. 16/16 i18n: difftool: mark warnings for translationVasco Almeida, Dec 14, 2016
  17. 15/16 i18n: send-email: mark composing message for translationVasco Almeida, Dec 14, 2016
  18. Junio C HamanoDec 14, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.