{"thread":{"id":"42747","subject":"[PATCH v2 01/11] i18n: add--interactive: mark strings for translation","startedAt":"2016-06-29T15:10:26Z","lastAt":"2016-06-29T15:11:15Z","messageCount":12,"participants":["Vasco Almeida"],"isPatch":true,"patchVersion":2,"patchTotal":11},"messages":[{"id":"290491","messageId":"20160629150945.15015-2-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 01/11] i18n: add--interactive: mark strings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:35Z","receivedAt":"2016-06-29T15:10:26Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark simple strings (without interpolation) for translation.\n\nBrackets around first parameter of ternary operator is necessary because\notherwise xgettext fails to extract strings marked for translation from\nthe rest of the file.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 68 +++++++++++++++++++++++++----------------------\n 1 file changed, 36 insertions(+), 32 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 822f857..fb8e5de 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -4,6 +4,7 @@ use 5.008;\n use strict;\n use warnings;\n use Git;\n+use Git::I18N;\n \n binmode(STDOUT, \":raw\");\n \n@@ -252,7 +253,7 @@ sub list_untracked {\n }\n \n my $status_fmt = '%12s %12s %s';\n-my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');\n+my $status_head = sprintf($status_fmt, __('staged'), __('unstaged'), __('path'));\n \n {\n \tmy $initial;\n@@ -678,7 +679,7 @@ sub update_cmd {\n \tmy @mods = list_modified('file-only');\n \treturn if (!@mods);\n \n-\tmy @update = list_and_choose({ PROMPT => 'Update',\n+\tmy @update = list_and_choose({ PROMPT => __('Update'),\n \t\t\t\t       HEADER => $status_head, },\n \t\t\t\t     @mods);\n \tif (@update) {\n@@ -690,7 +691,7 @@ sub update_cmd {\n }\n \n sub revert_cmd {\n-\tmy @update = list_and_choose({ PROMPT => 'Revert',\n+\tmy @update = list_and_choose({ PROMPT => __('Revert'),\n \t\t\t\t       HEADER => $status_head, },\n \t\t\t\t     list_modified());\n \tif (@update) {\n@@ -724,13 +725,13 @@ sub revert_cmd {\n }\n \n sub add_untracked_cmd {\n-\tmy @add = list_and_choose({ PROMPT => 'Add untracked' },\n+\tmy @add = list_and_choose({ PROMPT => __('Add untracked') },\n \t\t\t\t  list_untracked());\n \tif (@add) {\n \t\tsystem(qw(git update-index --add --), @add);\n \t\tsay_n_paths('added', @add);\n \t} else {\n-\t\tprint \"No untracked files.\\n\";\n+\t\tprint __(\"No untracked files.\\n\");\n \t}\n \tprint \"\\n\";\n }\n@@ -1159,8 +1160,11 @@ sub edit_hunk_loop {\n \t\t}\n \t\telse {\n \t\t\tprompt_yesno(\n-\t\t\t\t'Your edited hunk does not apply. Edit again '\n-\t\t\t\t. '(saying \"no\" discards!) [y/n]? '\n+\t\t\t\t# TRANSLATORS: do not translate [y/n]\n+\t\t\t\t# The program will only accept that input\n+\t\t\t\t# at this point.\n+\t\t\t\t__('Your edited hunk does not apply. Edit again '\n+\t\t\t\t   . '(saying \"no\" discards!) [y/n]? ')\n \t\t\t\t) or return undef;\n \t\t}\n \t}\n@@ -1206,11 +1210,11 @@ sub apply_patch_for_checkout_commit {\n \t\trun_git_apply 'apply '.$reverse, @_;\n \t\treturn 1;\n \t} elsif (!$applies_index) {\n-\t\tprint colored $error_color, \"The selected hunks do not apply to the index!\\n\";\n-\t\tif (prompt_yesno \"Apply them to the worktree anyway? \") {\n+\t\tprint colored $error_color, __(\"The selected hunks do not apply to the index!\\n\");\n+\t\tif (prompt_yesno __(\"Apply them to the worktree anyway? \")) {\n \t\t\treturn run_git_apply 'apply '.$reverse, @_;\n \t\t} else {\n-\t\t\tprint colored $error_color, \"Nothing was applied.\\n\";\n+\t\t\tprint colored $error_color, __(\"Nothing was applied.\\n\");\n \t\t\treturn 0;\n \t\t}\n \t} else {\n@@ -1230,9 +1234,9 @@ sub patch_update_cmd {\n \n \tif (!@mods) {\n \t\tif (@all_mods) {\n-\t\t\tprint STDERR \"Only binary files changed.\\n\";\n+\t\t\tprint STDERR __(\"Only binary files changed.\\n\");\n \t\t} else {\n-\t\t\tprint STDERR \"No changes.\\n\";\n+\t\t\tprint STDERR __(\"No changes.\\n\");\n \t\t}\n \t\treturn 0;\n \t}\n@@ -1390,12 +1394,12 @@ sub patch_update_file {\n \t\t\t\tmy $response = $1;\n \t\t\t\tmy $no = $ix > 10 ? $ix - 10 : 0;\n \t\t\t\twhile ($response eq '') {\n-\t\t\t\t\tmy $extra = \"\";\n \t\t\t\t\t$no = display_hunks(\\@hunk, $no);\n \t\t\t\t\tif ($no < $num) {\n-\t\t\t\t\t\t$extra = \" (<ret> to see more)\";\n+\t\t\t\t\t\tprint __(\"go to which hunk (<ret> to see more)? \");\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\tprint __(\"go to which hunk? \");\n \t\t\t\t\t}\n-\t\t\t\t\tprint \"go to which hunk$extra? \";\n \t\t\t\t\t$response = <STDIN>;\n \t\t\t\t\tif (!defined $response) {\n \t\t\t\t\t\t$response = '';\n@@ -1432,7 +1436,7 @@ sub patch_update_file {\n \t\t\telsif ($line =~ m|^/(.*)|) {\n \t\t\t\tmy $regex = $1;\n \t\t\t\tif ($1 eq \"\") {\n-\t\t\t\t\tprint colored $prompt_color, \"search for regex? \";\n+\t\t\t\t\tprint colored $prompt_color, __(\"search for regex? \");\n \t\t\t\t\t$regex = <STDIN>;\n \t\t\t\t\tif (defined $regex) {\n \t\t\t\t\t\tchomp $regex;\n@@ -1455,7 +1459,7 @@ sub patch_update_file {\n \t\t\t\t\t$iy++;\n \t\t\t\t\t$iy = 0 if ($iy >= $num);\n \t\t\t\t\tif ($ix == $iy) {\n-\t\t\t\t\t\terror_msg \"No hunk matches the given pattern\\n\";\n+\t\t\t\t\t\terror_msg __(\"No hunk matches the given pattern\\n\");\n \t\t\t\t\t\tlast;\n \t\t\t\t\t}\n \t\t\t\t}\n@@ -1467,7 +1471,7 @@ sub patch_update_file {\n \t\t\t\t\t$ix--;\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No previous hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No previous hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1476,7 +1480,7 @@ sub patch_update_file {\n \t\t\t\t\t$ix++;\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No next hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No next hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1489,13 +1493,13 @@ sub patch_update_file {\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t\telse {\n-\t\t\t\t\terror_msg \"No previous hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No previous hunk\\n\");\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n \t\t\telsif ($line =~ /^j/) {\n \t\t\t\tif ($other !~ /j/) {\n-\t\t\t\t\terror_msg \"No next hunk\\n\";\n+\t\t\t\t\terror_msg __(\"No next hunk\\n\");\n \t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t}\n@@ -1553,18 +1557,18 @@ sub diff_cmd {\n \tmy @mods = list_modified('index-only');\n \t@mods = grep { !($_->{BINARY}) } @mods;\n \treturn if (!@mods);\n-\tmy (@them) = list_and_choose({ PROMPT => 'Review diff',\n+\tmy (@them) = list_and_choose({ PROMPT => __('Review diff'),\n \t\t\t\t     IMMEDIATE => 1,\n \t\t\t\t     HEADER => $status_head, },\n \t\t\t\t   @mods);\n \treturn if (!@them);\n-\tmy $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';\n+\tmy $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';\n \tsystem(qw(git diff -p --cached), $reference, '--',\n \t\tmap { $_->{VALUE} } @them);\n }\n \n sub quit_cmd {\n-\tprint \"Bye.\\n\";\n+\tprint __(\"Bye.\\n\");\n \texit(0);\n }\n \n@@ -1587,32 +1591,32 @@ sub process_args {\n \t\t\tif ($1 eq 'reset') {\n \t\t\t\t$patch_mode = 'reset_head';\n \t\t\t\t$patch_mode_revision = 'HEAD';\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\tif ($arg ne '--') {\n \t\t\t\t\t$patch_mode_revision = $arg;\n \t\t\t\t\t$patch_mode = ($arg eq 'HEAD' ?\n \t\t\t\t\t\t       'reset_head' : 'reset_nothead');\n-\t\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\t}\n \t\t\t} elsif ($1 eq 'checkout') {\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\tif ($arg eq '--') {\n \t\t\t\t\t$patch_mode = 'checkout_index';\n \t\t\t\t} else {\n \t\t\t\t\t$patch_mode_revision = $arg;\n \t\t\t\t\t$patch_mode = ($arg eq 'HEAD' ?\n \t\t\t\t\t\t       'checkout_head' : 'checkout_nothead');\n-\t\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t\t}\n \t\t\t} elsif ($1 eq 'stage' or $1 eq 'stash') {\n \t\t\t\t$patch_mode = $1;\n-\t\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t} else {\n \t\t\t\tdie \"unknown --patch mode: $1\";\n \t\t\t}\n \t\t} else {\n \t\t\t$patch_mode = 'stage';\n-\t\t\t$arg = shift @ARGV or die \"missing --\";\n+\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t}\n \t\tdie \"invalid argument $arg, expecting --\"\n \t\t    unless $arg eq \"--\";\n@@ -1634,10 +1638,10 @@ sub main_loop {\n \t\t   [ 'help', \\&help_cmd, ],\n \t);\n \twhile (1) {\n-\t\tmy ($it) = list_and_choose({ PROMPT => 'What now',\n+\t\tmy ($it) = list_and_choose({ PROMPT => __('What now'),\n \t\t\t\t\t     SINGLETON => 1,\n \t\t\t\t\t     LIST_FLAT => 4,\n-\t\t\t\t\t     HEADER => '*** Commands ***',\n+\t\t\t\t\t     HEADER => __('*** Commands ***'),\n \t\t\t\t\t     ON_EOF => \\&quit_cmd,\n \t\t\t\t\t     IMMEDIATE => 1 }, @cmd);\n \t\tif ($it) {\n-- \n2.7.4\n\n"},{"id":"290492","messageId":"20160629150945.15015-4-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 03/11] i18n: add--interactive: mark strings with interpolation for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:37Z","receivedAt":"2016-06-29T15:10:35Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Use of sprintf following die or error_msg is necessary for placeholder\nsubstitution take place.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 26 ++++++++++++++------------\n 1 file changed, 14 insertions(+), 12 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex e11a33d..4e1e857 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -612,12 +612,12 @@ sub list_and_choose {\n \t\t\telse {\n \t\t\t\t$bottom = $top = find_unique($choice, @stuff);\n \t\t\t\tif (!defined $bottom) {\n-\t\t\t\t\terror_msg \"Huh ($choice)?\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\t\tnext TOPLOOP;\n \t\t\t\t}\n \t\t\t}\n \t\t\tif ($opts->{SINGLETON} && $bottom != $top) {\n-\t\t\t\terror_msg \"Huh ($choice)?\\n\";\n+\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\tnext TOPLOOP;\n \t\t\t}\n \t\t\tfor ($i = $bottom-1; $i <= $top-1; $i++) {\n@@ -1048,7 +1048,7 @@ sub edit_hunk_manually {\n \tmy $hunkfile = $repo->repo_path . \"/addp-hunk-edit.diff\";\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n-\t\tor die \"failed to open hunk edit file for writing: \" . $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n \tprint $fh \"# Manual hunk edit mode -- see bottom for a quick guide\\n\";\n \tprint $fh @$oldtext;\n \tmy $participle = $patch_mode_flavour{PARTICIPLE};\n@@ -1075,7 +1075,7 @@ EOF\n \t}\n \n \topen $fh, '<', $hunkfile\n-\t\tor die \"failed to open hunk edit file for reading: \" . $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for reading: %s\"), $!);\n \tmy @newtext = grep { !/^#/ } <$fh>;\n \tclose $fh;\n \tunlink $hunkfile;\n@@ -1225,7 +1225,7 @@ sub apply_patch_for_checkout_commit {\n \n sub patch_update_cmd {\n \tmy @all_mods = list_modified($patch_mode_flavour{FILTER});\n-\terror_msg \"ignoring unmerged: $_->{VALUE}\\n\"\n+\terror_msg sprintf(__(\"ignoring unmerged: %s\\n\"), $_->{VALUE})\n \t\tfor grep { $_->{UNMERGED} } @all_mods;\n \t@all_mods = grep { !$_->{UNMERGED} } @all_mods;\n \n@@ -1407,11 +1407,13 @@ sub patch_update_file {\n \t\t\t\t\tchomp $response;\n \t\t\t\t}\n \t\t\t\tif ($response !~ /^\\s*\\d+\\s*$/) {\n-\t\t\t\t\terror_msg \"Invalid number: '$response'\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Invalid number: '%s'\\n\"),\n+\t\t\t\t\t\t\t     $response);\n \t\t\t\t} elsif (0 < $response && $response <= $num) {\n \t\t\t\t\t$ix = $response - 1;\n \t\t\t\t} else {\n-\t\t\t\t\terror_msg \"Sorry, only $num hunks available.\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Sorry, only %s hunks available.\\n\"),\n+\t\t\t\t\t\t\t     $num);\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1449,7 +1451,7 @@ sub patch_update_file {\n \t\t\t\tif ($@) {\n \t\t\t\t\tmy ($err,$exp) = ($@, $1);\n \t\t\t\t\t$err =~ s/ at .*git-add--interactive line \\d+, <STDIN> line \\d+.*$//;\n-\t\t\t\t\terror_msg \"Malformed search regexp $exp: $err\\n\";\n+\t\t\t\t\terror_msg sprintf(__(\"Malformed search regexp %s: %s\\n\"), $exp, $err);\n \t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t\tmy $iy = $ix;\n@@ -1612,18 +1614,18 @@ sub process_args {\n \t\t\t\t$patch_mode = $1;\n \t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t} else {\n-\t\t\t\tdie \"unknown --patch mode: $1\";\n+\t\t\t\tdie sprintf(__(\"unknown --patch mode: %s\"), $1);\n \t\t\t}\n \t\t} else {\n \t\t\t$patch_mode = 'stage';\n \t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t}\n-\t\tdie \"invalid argument $arg, expecting --\"\n-\t\t    unless $arg eq \"--\";\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"),\n+\t\t\t       $arg) unless $arg eq \"--\";\n \t\t%patch_mode_flavour = %{$patch_modes{$patch_mode}};\n \t}\n \telsif ($arg ne \"--\") {\n-\t\tdie \"invalid argument $arg, expecting --\";\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"), $arg);\n \t}\n }\n \n-- \n2.7.4\n\n"},{"id":"290493","messageId":"20160629150945.15015-1-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":null,"subject":"[PATCH v2 00/11] Mark strings in perl script for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:34Z","receivedAt":"2016-06-29T15:10:39Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark messages in some perl scripts for translation.\n\nSince v1, adds brackets so parameter grouping of sprintf parameters is easier\nto see.\n\nInterdiff included below.\n\nVasco Almeida (11):\n  i18n: add--interactive: mark strings for translation\n  i18n: add--interactive: mark simple here documents for translation\n  i18n: add--interactive: mark strings with interpolation for\n    translation\n  i18n: add--interactive: mark plural strings\n  i18n: add--interactive: mark message for translation\n  i18n: add--interactive: i18n of help_patch_cmd\n  i18n: add--interactive: mark edit_hunk_manually message for\n    translation\n  i18n: send-email: mark strings for translation\n  i18n: send-email: mark warnings and errors for translation\n  i18n: send-email: mark string with interpolation for translation\n  i18n: difftool: mark warnings for translation\n\n Makefile                  |   3 +-\n git-add--interactive.perl | 358 ++++++++++++++++++++++++++++++++++------------\n git-difftool.perl         |  18 +--\n git-send-email.perl       | 160 +++++++++++----------\n perl/Git/I18N.pm          |   4 +-\n t/t0202/test.pl           |  11 +-\n 6 files changed, 376 insertions(+), 178 deletions(-)\n\n---- >8 ----\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 1652a57..235142c 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -614,12 +614,12 @@ sub list_and_choose {\n \t\t\telse {\n \t\t\t\t$bottom = $top = find_unique($choice, @stuff);\n \t\t\t\tif (!defined $bottom) {\n-\t\t\t\t\terror_msg sprintf __(\"Huh (%s)?\\n\"), $choice;\n+\t\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\t\tnext TOPLOOP;\n \t\t\t\t}\n \t\t\t}\n \t\t\tif ($opts->{SINGLETON} && $bottom != $top) {\n-\t\t\t\terror_msg sprintf __(\"Huh (%s)?\\n\"), $choice;\n+\t\t\t\terror_msg sprintf(__(\"Huh (%s)?\\n\"), $choice);\n \t\t\t\tnext TOPLOOP;\n \t\t\t}\n \t\t\tfor ($i = $bottom-1; $i <= $top-1; $i++) {\n@@ -669,17 +669,17 @@ sub say_n_paths {\n \tmy $did = shift @_;\n \tmy $cnt = scalar @_;\n \tif ($did eq 'added') {\n-\t\tprintf Q__(\"added one path\\n\", \"added %d paths\\n\",\n-\t\t\t   $cnt), $cnt;\n+\t\tprintf(Q__(\"added one path\\n\", \"added %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t} elsif ($did eq 'updated') {\n-\t\tprintf Q__(\"updated one path\\n\", \"updated %d paths\\n\",\n-\t\t\t   $cnt), $cnt;\n+\t\tprintf(Q__(\"updated one path\\n\", \"updated %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t} elsif ($did eq 'reversed') {\n-\t\tprintf Q__(\"reversed one path\\n\", \"reversed %d paths\\n\",\n-\t\t\t   $cnt), $cnt;\n+\t\tprintf(Q__(\"reversed one path\\n\", \"reversed %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t} else {\n-\t\tprintf Q__(\"touched one path\\n\", \"touched %d paths\\n\",\n-\t\t\t   $cnt), $cnt;\n+\t\tprintf(Q__(\"touched one path\\n\", \"touched %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t}\n }\n \n@@ -1056,12 +1056,12 @@ sub edit_hunk_manually {\n \tmy $hunkfile = $repo->repo_path . \"/addp-hunk-edit.diff\";\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n-\t\tor die sprintf __(\"failed to open hunk edit file for writing: %s\"), $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n \tprint $fh __(\"# Manual hunk edit mode -- see bottom for a quick guide\\n\");\n \tprint $fh @$oldtext;\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n-\tprint $fh (sprintf __(\n+\tprint $fh sprintf(__(\n \"# ---\n # To remove '%s' lines, make them ' ' lines (context).\n # To remove '%s' lines, delete them.\n@@ -1121,7 +1121,7 @@ sub edit_hunk_manually {\n \t}\n \n \topen $fh, '<', $hunkfile\n-\t\tor die sprintf __(\"failed to open hunk edit file for reading: %s\"), $!;\n+\t\tor die sprintf(__(\"failed to open hunk edit file for reading: %s\"), $!);\n \tmy @newtext = grep { !/^#/ } <$fh>;\n \tclose $fh;\n \tunlink $hunkfile;\n@@ -1314,7 +1314,7 @@ sub apply_patch_for_checkout_commit {\n \n sub patch_update_cmd {\n \tmy @all_mods = list_modified($patch_mode_flavour{FILTER});\n-\terror_msg sprintf __(\"ignoring unmerged: %s\\n\"), $_->{VALUE}\n+\terror_msg sprintf(__(\"ignoring unmerged: %s\\n\"), $_->{VALUE})\n \t\tfor grep { $_->{UNMERGED} } @all_mods;\n \t@all_mods = grep { !$_->{UNMERGED} } @all_mods;\n \n@@ -1458,100 +1458,79 @@ sub patch_update_file {\n \t\tif ($patch_mode eq 'stage') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stage mode change [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stage mode change [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stage deletion [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stage deletion [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stage this hunk [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stage this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'stash') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stash mode change [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stash mode change [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stash deletion [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stash deletion [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Stash this hunk [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Stash this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'reset_head') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Unstage mode change [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Unstage mode change [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Unstage deletion [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Unstage deletion [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Unstage this hunk [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Unstage this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'reset_nothead') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply mode change to index [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply mode change to index [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply deletion to index [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply deletion to index [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply this hunk to index [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply this hunk to index [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'checkout_index') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard mode change from worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard mode change from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard deletion from worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard deletion from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard this hunk from worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard this hunk from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'checkout_head') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t} elsif ($patch_mode eq 'checkout_nothead') {\n \t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t} else {\n \t\t\t  print colored $prompt_color,\n-\t\t\t    sprintf __(\"Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? \"),\n-\t\t\t\t       $other;\n+\t\t\t    sprintf(__(\"Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n \t\t\t}\n \t\t}\n \t\tmy $line = prompt_single_character;\n@@ -1589,13 +1568,13 @@ sub patch_update_file {\n \t\t\t\t\tchomp $response;\n \t\t\t\t}\n \t\t\t\tif ($response !~ /^\\s*\\d+\\s*$/) {\n-\t\t\t\t\terror_msg sprintf __(\"Invalid number: '%s'\\n\"),\n-\t\t\t\t\t\t      $response;\n+\t\t\t\t\terror_msg sprintf(__(\"Invalid number: '%s'\\n\"),\n+\t\t\t\t\t\t\t     $response);\n \t\t\t\t} elsif (0 < $response && $response <= $num) {\n \t\t\t\t\t$ix = $response - 1;\n \t\t\t\t} else {\n-\t\t\t\t\terror_msg sprintf __(\"Sorry, only %s hunks available.\\n\"),\n-\t\t\t\t\t\t      $num;\n+\t\t\t\t\terror_msg sprintf(__(\"Sorry, only %s hunks available.\\n\"),\n+\t\t\t\t\t\t\t     $num);\n \t\t\t\t}\n \t\t\t\tnext;\n \t\t\t}\n@@ -1633,7 +1612,7 @@ sub patch_update_file {\n \t\t\t\tif ($@) {\n \t\t\t\t\tmy ($err,$exp) = ($@, $1);\n \t\t\t\t\t$err =~ s/ at .*git-add--interactive line \\d+, <STDIN> line \\d+.*$//;\n-\t\t\t\t\terror_msg sprintf __(\"Malformed search regexp %s: %s\\n\"), $exp, $err;\n+\t\t\t\t\terror_msg sprintf(__(\"Malformed search regexp %s: %s\\n\"), $exp, $err);\n \t\t\t\t\tnext;\n \t\t\t\t}\n \t\t\t\tmy $iy = $ix;\n@@ -1690,10 +1669,10 @@ sub patch_update_file {\n \t\t\telsif ($other =~ /s/ && $line =~ /^s/) {\n \t\t\t\tmy @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});\n \t\t\t\tif (1 < @split) {\n-\t\t\t\t\tprint colored $header_color, sprintf\n+\t\t\t\t\tprint colored $header_color, sprintf(\n \t\t\t\t\t\tQ__(\"Split into %d hunk.\\n\",\n \t\t\t\t\t\t    \"Split into %d hunks.\\n\",\n-\t\t\t\t\t\t    scalar(@split)), scalar(@split);\n+\t\t\t\t\t\t    scalar(@split)), scalar(@split));\n \t\t\t\t}\n \t\t\t\tsplice (@hunk, $ix, 1, @split);\n \t\t\t\t$num = scalar @hunk;\n@@ -1798,19 +1777,19 @@ sub process_args {\n \t\t\t\t$patch_mode = $1;\n \t\t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t\t} else {\n-\t\t\t\tdie sprintf __(\"unknown --patch mode: %s\"), $1;\n+\t\t\t\tdie sprintf(__(\"unknown --patch mode: %s\"), $1);\n \t\t\t}\n \t\t} else {\n \t\t\t$patch_mode = 'stage';\n \t\t\t$arg = shift @ARGV or die __(\"missing --\");\n \t\t}\n-\t\tdie sprintf __(\"invalid argument %s, expecting --\"),\n-\t\t\t       $arg unless $arg eq \"--\";\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"),\n+\t\t\t       $arg) unless $arg eq \"--\";\n \t\t%patch_mode_flavour = %{$patch_modes{$patch_mode}};\n \t\t$cmd = 1;\n \t}\n \telsif ($arg ne \"--\") {\n-\t\tdie sprintf __(\"invalid argument %s, expecting --\"), $arg;\n+\t\tdie sprintf(__(\"invalid argument %s, expecting --\"), $arg);\n \t}\n }\n \ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex fe7f003..de8d783 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -452,11 +452,11 @@ sub dir_diff\n \t\t}\n \n \t\tif (exists $wt_modified{$file} and exists $tmp_modified{$file}) {\n-\t\t\twarn sprintf __(\n-\"warning: Both files modified:\n-'%s/%s' and '%s/%s'.\n-warning: Working tree file has been left.\n-warning:\\n\"), $workdir, $file, $b, $file;\n+\t\t\twarn sprintf(__(\n+\t\t\t\t\"warning: Both files modified:\\n\" .\n+\t\t\t\t\"'%s/%s' and '%s/%s'.\\n\" .\n+\t\t\t\t\"warning: Working tree file has been left.\\n\" .\n+\t\t\t\t\"warning:\\n\"), $workdir, $file, $b, $file);\n \t\t\t$error = 1;\n \t\t} elsif (exists $tmp_modified{$file}) {\n \t\t\tmy $mode = stat(\"$b/$file\")->mode;\n@@ -468,9 +468,9 @@ warning:\\n\"), $workdir, $file, $b, $file;\n \t\t}\n \t}\n \tif ($error) {\n-\t\twarn sprintf __(\n-\"warning: Temporary files exist in '%s'.\n-warning: You may want to cleanup or recover these.\\n\"), $tmpdir;\n+\t\twarn sprintf(__(\n+\t\t\t\"warning: Temporary files exist in '%s'.\\n\" .\n+\t\t\t\"warning: You may want to cleanup or recover these.\\n\"), $tmpdir);\n \t\texit(1);\n \t} else {\n \t\texit_cleanup($tmpdir, $rc);\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex f445a5e..c29381b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -434,7 +434,7 @@ $smtp_encryption = '' unless (defined $smtp_encryption);\n my(%suppress_cc);\n if (@suppress_cc) {\n \tforeach my $entry (@suppress_cc) {\n-\t\tdie sprintf __(\"Unknown --suppress-cc field: '%s'\\n\"), $entry\n+\t\tdie sprintf(__(\"Unknown --suppress-cc field: '%s'\\n\"), $entry)\n \t\t\tunless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;\n \t\t$suppress_cc{$entry} = 1;\n \t}\n@@ -585,12 +585,12 @@ sub is_format_patch_arg {\n \t\tif (defined($format_patch)) {\n \t\t\treturn $format_patch;\n \t\t}\n-\t\tdie sprintf __(\n+\t\tdie sprintf(__(\n \"File '%s' exists but it could also be the range of commits\n to produce patches for.  Please disambiguate by...\n \n     * Saying \\\"./%s\\\" if you mean a file; or\n-    * Giving --format-patch option if you mean a range.\"), $f, $f;\n+    * Giving --format-patch option if you mean a range.\"), $f, $f);\n \t} catch Git::Error::Command with {\n \t\t# Not a valid revision.  Treat it as a filename.\n \t\treturn 0;\n@@ -606,7 +606,7 @@ while (defined(my $f = shift @ARGV)) {\n \t\t@ARGV = ();\n \t} elsif (-d $f and !is_format_patch_arg($f)) {\n \t\topendir my $dh, $f\n-\t\t\tor die sprintf __(\"Failed to opendir %s: %s\"), $f, $!;\n+\t\t\tor die sprintf(__(\"Failed to opendir %s: %s\"), $f, $!);\n \n \t\tpush @files, grep { -f $_ } map { catfile($f, $_) }\n \t\t\t\tsort readdir $dh;\n@@ -628,8 +628,8 @@ if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n \t\t\tmy $error = validate_patch($f);\n-\t\t\t$error and die sprintf __(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n-\t\t\t\t\t\t  $f, $error;\n+\t\t\t$error and die sprintf(__(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n+\t\t\t\t\t\t  $f, $error);\n \t\t}\n \t}\n }\n@@ -652,7 +652,7 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie sprintf __(\"No subject line in %s ?\"), $fn;\n+\tdie sprintf(__(\"No subject line in %s ?\"), $fn);\n }\n \n if ($compose) {\n@@ -662,7 +662,7 @@ if ($compose) {\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n \topen my $c, \">\", $compose_filename\n-\t\tor die sprintf __(\"Failed to open for writing %s: %s\"), $compose_filename, $!;\n+\t\tor die sprintf(__(\"Failed to open for writing %s: %s\"), $compose_filename, $!);\n \n \n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n@@ -693,10 +693,10 @@ EOT\n \t}\n \n \topen my $c2, \">\", $compose_filename . \".final\"\n-\t\tor die sprintf __(\"Failed to open %s.final : %s\"), $compose_filename, $!;\n+\t\tor die sprintf(__(\"Failed to open %s.final : %s\"), $compose_filename, $!);\n \n \topen $c, \"<\", $compose_filename\n-\t\tor die sprintf __(\"Failed to open %s : %s\"), $compose_filename, $!;\n+\t\tor die sprintf(__(\"Failed to open %s : %s\"), $compose_filename, $!);\n \n \tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n \tmy $in_body = 0;\n@@ -772,7 +772,7 @@ sub ask {\n \t\tif ($confirm_only) {\n \t\t\t# TRANSLATORS: Keep [y/N] as is.\n \t\t\tmy $yesno = $term->readline(\n-\t\t\t\tsprintf __(\"Are you sure you want to use <%s> [y/N]? \"), $resp);\n+\t\t\t\tsprintf(__(\"Are you sure you want to use <%s> [y/N]? \"), $resp));\n \t\t\tif (defined $yesno && $yesno =~ /y/i) {\n \t\t\t\treturn $resp;\n \t\t\t}\n@@ -851,7 +851,7 @@ my %EXPANDED_ALIASES;\n sub expand_one_alias {\n \tmy $alias = shift;\n \tif ($EXPANDED_ALIASES{$alias}) {\n-\t\tdie sprintf __(\"fatal: alias '%s' expands to itself\\n\"), $alias;\n+\t\tdie sprintf(__(\"fatal: alias '%s' expands to itself\\n\"), $alias);\n \t}\n \tlocal $EXPANDED_ALIASES{$alias} = 1;\n \treturn $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;\n@@ -1226,7 +1226,7 @@ sub ssl_verify_params {\n \t\treturn (SSL_verify_mode => SSL_VERIFY_PEER(),\n \t\t\tSSL_ca_file => $smtp_ssl_cert_path);\n \t} else {\n-\t\tdie sprintf __(\"CA path \\\"%s\\\" does not exist\"), $smtp_ssl_cert_path;\n+\t\tdie sprintf(__(\"CA path \\\"%s\\\" does not exist\"), $smtp_ssl_cert_path);\n \t}\n }\n \n@@ -1388,7 +1388,7 @@ Message-Id: $message_id\n \t\t\t\t\t# supported commands\n \t\t\t\t\t$smtp->hello($smtp_domain);\n \t\t\t\t} else {\n-\t\t\t\t\tdie sprintf __(\"Server does not support STARTTLS! %s\"), $smtp->message;\n+\t\t\t\t\tdie sprintf(__(\"Server does not support STARTTLS! %s\"), $smtp->message);\n \t\t\t\t}\n \t\t\t}\n \t\t}\n@@ -1445,7 +1445,7 @@ $subject = $initial_subject;\n $message_num = 0;\n \n foreach my $t (@files) {\n-\topen my $fh, \"<\", $t or die sprintf __(\"can't open file %s\"), $t;\n+\topen my $fh, \"<\", $t or die sprintf(__(\"can't open file %s\"), $t);\n \n \tmy $author = undef;\n \tmy $sauthor = undef;\n@@ -1678,7 +1678,7 @@ sub recipients_cmd {\n \t\t       $prefix, $what, $address, $cmd) unless $quiet;\n \t\t}\n \tclose $fh\n-\t    or die sprintf __(\"(%s) failed to close pipe to '%s'\"), $prefix, $cmd;\n+\t    or die sprintf(__(\"(%s) failed to close pipe to '%s'\"), $prefix, $cmd);\n \treturn @addresses;\n }\n \n@@ -1732,10 +1732,10 @@ sub unique_email_list {\n sub validate_patch {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die sprintf __(\"unable to open %s: %s\\n\"), $fn, $!;\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tif (length($line) > 998) {\n-\t\t\treturn sprintf __(\"%s: patch contains a line longer than 998 characters\"), $.;\n+\t\t\treturn sprintf(__(\"%s: patch contains a line longer than 998 characters\"), $.);\n \t\t}\n \t}\n \treturn;\n@@ -1744,7 +1744,7 @@ sub validate_patch {\n sub file_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die sprintf __(\"unable to open %s: %s\\n\"), $fn, $!;\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\treturn 1 if $line =~ /[^[:ascii:]]/;\n \t}\n@@ -1754,7 +1754,7 @@ sub file_has_nonascii {\n sub body_or_subject_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die sprintf __(\"unable to open %s: %s\\n\"), $fn, $!;\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tlast if $line =~ /^$/;\n \t\treturn 1 if $line =~ /^Subject.*[^[:ascii:]]/;\n---- >8 ----\n\n-- \n2.7.4\n\n"},{"id":"290494","messageId":"20160629150945.15015-5-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 04/11] i18n: add--interactive: mark plural strings","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:38Z","receivedAt":"2016-06-29T15:10:49Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark plural strings for translation.  Unfold each action case in one\nentire sentence.\n\nPass new keyword for xgettext to extract.\n\nUpdate test to include new subrotine Q__() for plural strings handling.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n Makefile                  |  3 ++-\n git-add--interactive.perl | 24 ++++++++++++++++--------\n perl/Git/I18N.pm          |  4 +++-\n t/t0202/test.pl           | 11 ++++++++++-\n 4 files changed, 31 insertions(+), 11 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex de5a030..eedf1fa 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2061,7 +2061,8 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n \t--keyword=_ --keyword=N_ --keyword=\"Q_:1,2\"\n XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \\\n \t--keyword=gettextln --keyword=eval_gettextln\n-XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl\n+XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \\\n+\t--keyword=__ --keyword=\"Q__:1,2\"\n LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH) git-parse-remote.sh\n LOCALIZED_PERL = $(SCRIPT_PERL)\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 4e1e857..08badfa 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -666,12 +666,18 @@ sub status_cmd {\n sub say_n_paths {\n \tmy $did = shift @_;\n \tmy $cnt = scalar @_;\n-\tprint \"$did \";\n-\tif (1 < $cnt) {\n-\t\tprint \"$cnt paths\\n\";\n-\t}\n-\telse {\n-\t\tprint \"one path\\n\";\n+\tif ($did eq 'added') {\n+\t\tprintf(Q__(\"added one path\\n\", \"added %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} elsif ($did eq 'updated') {\n+\t\tprintf(Q__(\"updated one path\\n\", \"updated %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} elsif ($did eq 'reversed') {\n+\t\tprintf(Q__(\"reversed one path\\n\", \"reversed %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n+\t} else {\n+\t\tprintf(Q__(\"touched one path\\n\", \"touched %d paths\\n\",\n+\t\t\t   $cnt), $cnt);\n \t}\n }\n \n@@ -1508,8 +1514,10 @@ sub patch_update_file {\n \t\t\telsif ($other =~ /s/ && $line =~ /^s/) {\n \t\t\t\tmy @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY});\n \t\t\t\tif (1 < @split) {\n-\t\t\t\t\tprint colored $header_color, \"Split into \",\n-\t\t\t\t\tscalar(@split), \" hunks.\\n\";\n+\t\t\t\t\tprint colored $header_color, sprintf(\n+\t\t\t\t\t\tQ__(\"Split into %d hunk.\\n\",\n+\t\t\t\t\t\t    \"Split into %d hunks.\\n\",\n+\t\t\t\t\t\t    scalar(@split)), scalar(@split));\n \t\t\t\t}\n \t\t\t\tsplice (@hunk, $ix, 1, @split);\n \t\t\t\t$num = scalar @hunk;\ndiff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm\nindex f889fd6..5a75dd5 100644\n--- a/perl/Git/I18N.pm\n+++ b/perl/Git/I18N.pm\n@@ -13,7 +13,7 @@ BEGIN {\n \t}\n }\n \n-our @EXPORT = qw(__);\n+our @EXPORT = qw(__ Q__);\n our @EXPORT_OK = @EXPORT;\n \n sub __bootstrap_locale_messages {\n@@ -44,6 +44,7 @@ BEGIN\n \teval {\n \t\t__bootstrap_locale_messages();\n \t\t*__ = \\&Locale::Messages::gettext;\n+\t\t*Q__ = \\&Locale::Messages::ngettext;\n \t\t1;\n \t} or do {\n \t\t# Tell test.pl that we couldn't load the gettext library.\n@@ -51,6 +52,7 @@ BEGIN\n \n \t\t# Just a fall-through no-op\n \t\t*__ = sub ($) { $_[0] };\n+\t\t*Q__ = sub ($$$) { $_[2] == 1 ? $_[0] : $_[1] };\n \t};\n }\n \ndiff --git a/t/t0202/test.pl b/t/t0202/test.pl\nindex 2c10cb4..98aa9a3 100755\n--- a/t/t0202/test.pl\n+++ b/t/t0202/test.pl\n@@ -4,7 +4,7 @@ use lib (split(/:/, $ENV{GITPERLLIB}));\n use strict;\n use warnings;\n use POSIX qw(:locale_h);\n-use Test::More tests => 8;\n+use Test::More tests => 11;\n use Git::I18N;\n \n my $has_gettext_library = $Git::I18N::__HAS_LIBRARY;\n@@ -31,6 +31,7 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \t# more gettext wrapper functions.\n \tmy %prototypes = (qw(\n \t\t__\t$\n+\t\tQ__\t$$$\n \t));\n \twhile (my ($sub, $proto) = each %prototypes) {\n \t\tis(prototype(\\&{\"Git::I18N::$sub\"}), $proto, \"sanity: $sub has a $proto prototype\");\n@@ -46,6 +47,14 @@ is_deeply(\\@Git::I18N::EXPORT, \\@Git::I18N::EXPORT_OK, \"sanity: Git::I18N export\n \tmy ($got, $expect) = (('TEST: A Perl test string') x 2);\n \n \tis(__($got), $expect, \"Passing a string through __() in the C locale works\");\n+\n+\tmy ($got_singular, $got_plural, $expect_singular, $expect_plural) =\n+\t\t(('TEST: 1 file', 'TEST: n files') x 2);\n+\n+\tis(Q__($got_singular, $got_plural, 1), $expect_singular,\n+\t\t\"Get singular string through Q__() in C locale\");\n+\tis(Q__($got_singular, $got_plural, 2), $expect_plural,\n+\t\t\"Get plural string through Q__() in C locale\");\n }\n \n # Test a basic message on different locales\n-- \n2.7.4\n\n"},{"id":"290495","messageId":"20160629150945.15015-3-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 02/11] i18n: add--interactive: mark simple here documents for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:36Z","receivedAt":"2016-06-29T15:10:53Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark messages in here document without interpolation for translation.\n\nMarking for translation by removing here documents this way, rather than\ntake advantage of \"print __ << EOF\" way, makes other instances of help\nmessages in clean.c match the first two in this file.  Otherwise,\nreusing here document would add a trailer newline to the message, making\nthem not match 100%, hence creating two entries in pot template for\ntranslation rather than a single entry.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex fb8e5de..e11a33d 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -636,25 +636,25 @@ sub list_and_choose {\n }\n \n sub singleton_prompt_help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n-Prompt help:\n+\tprint colored $help_color, __(\n+\"Prompt help:\n 1          - select a numbered item\n foo        - select item based on unique prefix\n-           - (empty) select nothing\n-EOF\n+           - (empty) select nothing\"),\n+\"\\n\";\n }\n \n sub prompt_help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n-Prompt help:\n+\tprint colored $help_color, __(\n+\"Prompt help:\n 1          - select a single item\n 3-5        - select a range of items\n 2-3,6-9    - select multiple ranges\n foo        - select item based on unique prefix\n -...       - unselect specified items\n *          - choose all items\n-           - (empty) finish selecting\n-EOF\n+           - (empty) finish selecting\"),\n+\"\\n\";\n }\n \n sub status_cmd {\n@@ -1573,14 +1573,14 @@ sub quit_cmd {\n }\n \n sub help_cmd {\n-\tprint colored $help_color, <<\\EOF ;\n-status        - show paths with changes\n+\tprint colored $help_color, __(\n+\"status        - show paths with changes\n update        - add working tree state to the staged set of changes\n revert        - revert staged set of changes back to the HEAD version\n patch         - pick hunks and update selectively\n diff\t      - view diff between HEAD and index\n-add untracked - add contents of untracked files to the staged set of changes\n-EOF\n+add untracked - add contents of untracked files to the staged set of changes\"),\n+\"\\n\";\n }\n \n sub process_args {\n-- \n2.7.4\n\n"},{"id":"290496","messageId":"20160629150945.15015-6-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 05/11] i18n: add--interactive: mark message for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:39Z","receivedAt":"2016-06-29T15:10:54Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark message assembled in place for translation, unfolding each use case\nfor each entry in the %patch_modes hash table.\n\nPreviously, this script relied on whether $patch_mode was set to run the\ncommand patch_update_cmd() or show status and loop the main loop. Now,\nit uses $cmd to indicate we must run patch_update_cmd() and $patch_mode\nis used to tell which flavor of the %patch_modes are we on.  This is\nintroduced in order to be able to mark and unfold the message prompt\nknowing in which context we are.\n\nThe tracking of context was done previously by point %patch_mode_flavour\nhash table to the correct entry of %patch_modes, focusing only on value\nof %patch_modes. Now, we are also interested in the key ('staged',\n'stash', 'checkout_head', ...).\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 91 ++++++++++++++++++++++++++++++++++++++++++-----\n 1 file changed, 83 insertions(+), 8 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 08badfa..5b89b97 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -91,6 +91,7 @@ sub colored {\n }\n \n # command line options\n+my $cmd;\n my $patch_mode;\n my $patch_mode_revision;\n \n@@ -171,7 +172,8 @@ my %patch_modes = (\n \t},\n );\n \n-my %patch_mode_flavour = %{$patch_modes{stage}};\n+$patch_mode = 'stage';\n+my %patch_mode_flavour = %{$patch_modes{$patch_mode}};\n \n sub run_cmd_pipe {\n \tif ($^O eq 'MSWin32') {\n@@ -1372,12 +1374,84 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color, $patch_mode_flavour{VERB},\n-\t\t  ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :\n-\t\t   $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :\n-\t\t   ' this hunk'),\n-\t\t  $patch_mode_flavour{TARGET},\n-\t\t  \" [y,n,q,a,d,/$other,?]? \";\n+\t\tif ($patch_mode eq 'stage') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stage mode change [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stage deletion [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stage this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'stash') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stash mode change [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stash deletion [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Stash this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'reset_head') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Unstage mode change [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Unstage deletion [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Unstage this hunk [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'reset_nothead') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply mode change to index [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply deletion to index [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply this hunk to index [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'checkout_index') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard mode change from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard deletion from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard this hunk from worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'checkout_head') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard mode change from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard deletion from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Discard this hunk from index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t} elsif ($patch_mode eq 'checkout_nothead') {\n+\t\t\tif ($hunk[$ix]{TYPE} eq 'mode') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply mode change to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} elsif ($hunk[$ix]{TYPE} eq 'deletion') {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply deletion to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t} else {\n+\t\t\t  print colored $prompt_color,\n+\t\t\t    sprintf(__(\"Apply this hunk to index and worktree [y,n,q,a,d,/%s,?]? \"), $other);\n+\t\t\t}\n+\t\t}\n \t\tmy $line = prompt_single_character;\n \t\tlast unless defined $line;\n \t\tif ($line) {\n@@ -1631,6 +1705,7 @@ sub process_args {\n \t\tdie sprintf(__(\"invalid argument %s, expecting --\"),\n \t\t\t       $arg) unless $arg eq \"--\";\n \t\t%patch_mode_flavour = %{$patch_modes{$patch_mode}};\n+\t\t$cmd = 1;\n \t}\n \telsif ($arg ne \"--\") {\n \t\tdie sprintf(__(\"invalid argument %s, expecting --\"), $arg);\n@@ -1667,7 +1742,7 @@ sub main_loop {\n \n process_args();\n refresh();\n-if ($patch_mode) {\n+if ($cmd) {\n \tpatch_update_cmd();\n }\n else {\n-- \n2.7.4\n\n"},{"id":"290497","messageId":"20160629150945.15015-7-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 06/11] i18n: add--interactive: i18n of help_patch_cmd","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:40Z","receivedAt":"2016-06-29T15:10:55Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark help message of help_patch_cmd for translation.  The message must\nbe unfolded to be free of variables so we can have high quality\ntranslations.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 65 +++++++++++++++++++++++++++++++++++++++--------\n 1 file changed, 54 insertions(+), 11 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 5b89b97..acbfa4e 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1179,15 +1179,58 @@ sub edit_hunk_loop {\n }\n \n sub help_patch_cmd {\n-\tmy $verb = lc $patch_mode_flavour{VERB};\n-\tmy $target = $patch_mode_flavour{TARGET};\n-\tprint colored $help_color, <<EOF ;\n-y - $verb this hunk$target\n-n - do not $verb this hunk$target\n-q - quit; do not $verb this hunk or any of the remaining ones\n-a - $verb this hunk and all later hunks in the file\n-d - do not $verb this hunk or any of the later hunks in the file\n-g - select a hunk to go to\n+\tif ($patch_mode eq 'stage') {\n+\t\tprint colored $help_color, __(\n+\"y - stage this hunk\n+n - do not stage this hunk\n+q - quit; do not stage this hunk or any of the remaining ones\n+a - stage this hunk and all later hunks in the file\n+d - do not stage this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'stash') {\n+\t\tprint colored $help_color, __(\n+\"y - stash this hunk\n+n - do not stash this hunk\n+q - quit; do not stash this hunk or any of the remaining ones\n+a - stash this hunk and all later hunks in the file\n+d - do not stash this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'reset_head') {\n+\t\tprint colored $help_color, __(\n+\"y - unstage this hunk\n+n - do not unstage this hunk\n+q - quit; do not unstage this hunk or any of the remaining ones\n+a - unstage this hunk and all later hunks in the file\n+d - do not unstage this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'reset_nothead') {\n+\t\tprint colored $help_color, __(\n+\"y - apply this hunk to index\n+n - do not apply this hunk to index\n+q - quit; do not apply this hunk or any of the remaining ones\n+a - apply this hunk and all later hunks in the file\n+d - do not apply this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'checkout_index') {\n+\t\tprint colored $help_color, __(\n+\"y - discard this hunk from worktree\n+n - do not discard this hunk from worktree\n+q - quit; do not discard this hunk or any of the remaining ones\n+a - discard this hunk and all later hunks in the file\n+d - do not discard this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'checkout_head') {\n+\t\tprint colored $help_color, __(\n+\"y - discard this hunk from index and worktree\n+n - do not discard this hunk from index and worktree\n+q - quit; do not discard this hunk or any of the remaining ones\n+a - discard this hunk and all later hunks in the file\n+d - do not discard this hunk or any of the later hunks in the file\");\n+\t} elsif ($patch_mode eq 'checkout_nothead') {\n+\t\tprint colored $help_color, __(\n+\"y - apply this hunk to index and worktree\n+n - do not apply this hunk to index and worktree\n+q - quit; do not apply this hunk or any of the remaining ones\n+a - apply this hunk and all later hunks in the file\n+d - do not apply this hunk or any of the later hunks in the file\");\n+\t}\n+\tprint colored $help_color, \"\\n\", __(\n+\"g - select a hunk to go to\n / - search for a hunk matching the given regex\n j - leave this hunk undecided, see next undecided hunk\n J - leave this hunk undecided, see next hunk\n@@ -1195,8 +1238,8 @@ k - leave this hunk undecided, see previous undecided hunk\n K - leave this hunk undecided, see previous hunk\n s - split the current hunk into smaller hunks\n e - manually edit the current hunk\n-? - print help\n-EOF\n+? - print help\"),\n+\"\\n\";\n }\n \n sub apply_patch {\n-- \n2.7.4\n\n"},{"id":"290498","messageId":"20160629150945.15015-9-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 08/11] i18n: send-email: mark strings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:42Z","receivedAt":"2016-06-29T15:10:57Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark strings often displayed to user for translation.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 53 +++++++++++++++++++++++++++++++----------------------\n 1 file changed, 31 insertions(+), 22 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6958785..2521832 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -28,6 +28,7 @@ use File::Temp qw/ tempdir tempfile /;\n use File::Spec::Functions qw(catfile);\n use Error qw(:try);\n use Git;\n+use Git::I18N;\n \n Getopt::Long::Configure qw/ pass_through /;\n \n@@ -795,12 +796,12 @@ foreach my $f (@files) {\n }\n \n if (!defined $auto_8bit_encoding && scalar %broken_encoding) {\n-\tprint \"The following files are 8bit, but do not declare \" .\n-\t\t\"a Content-Transfer-Encoding.\\n\";\n+\tprint __(\"The following files are 8bit, but do not declare \" .\n+\t\t \"a Content-Transfer-Encoding.\\n\");\n \tforeach my $f (sort keys %broken_encoding) {\n \t\tprint \"    $f\\n\";\n \t}\n-\t$auto_8bit_encoding = ask(\"Which 8bit encoding should I declare [UTF-8]? \",\n+\t$auto_8bit_encoding = ask(__(\"Which 8bit encoding should I declare [UTF-8]? \"),\n \t\t\t\t  valid_re => qr/.{4}/, confirm_only => 1,\n \t\t\t\t  default => \"UTF-8\");\n }\n@@ -827,7 +828,7 @@ if (defined $sender) {\n # But it's a no-op to run sanitize_address on an already sanitized address.\n $sender = sanitize_address($sender);\n \n-my $to_whom = \"To whom should the emails be sent (if anyone)?\";\n+my $to_whom = __(\"To whom should the emails be sent (if anyone)?\");\n my $prompting = 0;\n if (!@initial_to && !defined $to_cmd) {\n \tmy $to = ask(\"$to_whom \",\n@@ -857,7 +858,7 @@ sub expand_one_alias {\n \n if ($thread && !defined $initial_reply_to && $prompting) {\n \t$initial_reply_to = ask(\n-\t\t\"Message-ID to be used as In-Reply-To for the first email (if any)? \",\n+\t\t__(\"Message-ID to be used as In-Reply-To for the first email (if any)? \"),\n \t\tdefault => \"\",\n \t\tvalid_re => qr/\\@.*\\./, confirm_only => 1);\n }\n@@ -916,7 +917,10 @@ sub validate_address {\n \tmy $address = shift;\n \twhile (!extract_valid_address($address)) {\n \t\tprint STDERR \"error: unable to extract a valid address from: $address\\n\";\n-\t\t$_ = ask(\"What to do with this address? ([q]uit|[d]rop|[e]dit): \",\n+\t\t# TRANSLATORS: Make sure to include [q] [d] [e] in your\n+\t\t# translation. The program will only accept English input\n+\t\t# at this point.\n+\t\t$_ = ask(__(\"What to do with this address? ([q]uit|[d]rop|[e]dit): \"),\n \t\t\tvalid_re => qr/^(?:quit|q|drop|d|edit|e)/i,\n \t\t\tdefault => 'q');\n \t\tif (/^d/i) {\n@@ -1291,17 +1295,22 @@ Message-Id: $message_id\n \t\tif ($needs_confirm eq \"inform\") {\n \t\t\t$confirm_unconfigured = 0; # squelch this message for the rest of this run\n \t\t\t$ask_default = \"y\"; # assume yes on EOF since user hasn't explicitly asked for confirmation\n-\t\t\tprint \"    The Cc list above has been expanded by additional\\n\";\n-\t\t\tprint \"    addresses found in the patch commit message. By default\\n\";\n-\t\t\tprint \"    send-email prompts before sending whenever this occurs.\\n\";\n-\t\t\tprint \"    This behavior is controlled by the sendemail.confirm\\n\";\n-\t\t\tprint \"    configuration setting.\\n\";\n-\t\t\tprint \"\\n\";\n-\t\t\tprint \"    For additional information, run 'git send-email --help'.\\n\";\n-\t\t\tprint \"    To retain the current behavior, but squelch this message,\\n\";\n-\t\t\tprint \"    run 'git config --global sendemail.confirm auto'.\\n\\n\";\n+\t\t\tprint __(\n+\"    The Cc list above has been expanded by additional\n+    addresses found in the patch commit message. By default\n+    send-email prompts before sending whenever this occurs.\n+    This behavior is controlled by the sendemail.confirm\n+    configuration setting.\n+\n+    For additional information, run 'git send-email --help'.\n+    To retain the current behavior, but squelch this message,\n+    run 'git config --global sendemail.confirm auto'.\"),\n+\"\\n\\n\";\n \t\t}\n-\t\t$_ = ask(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \",\n+\t\t# TRANSLATORS: Make sure to include [y] [n] [q] [a] in your\n+\t\t# translation. The program will only accept English input\n+\t\t# at this point.\n+\t\t$_ = ask(__(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \"),\n \t\t         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,\n \t\t         default => $ask_default);\n \t\tdie \"Send this email reply required\" unless defined $_;\n@@ -1403,7 +1412,7 @@ Message-Id: $message_id\n \tif ($quiet) {\n \t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n \t} else {\n-\t\tprint (($dry_run ? \"Dry-\" : \"\").\"OK. Log says:\\n\");\n+\t\tprint (($dry_run ? \"Dry-\" : \"\"). __(\"OK. Log says:\\n\"));\n \t\tif (!file_name_is_absolute($smtp_server)) {\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t\tprint \"MAIL FROM:<$raw_from>\\n\";\n@@ -1478,13 +1487,13 @@ foreach my $t (@files) {\n \t\t\t\t$sauthor = sanitize_address($author);\n \t\t\t\tnext if $suppress_cc{'author'};\n \t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n-\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n \t\t\t}\n \t\t\telsif (/^To:\\s+(.*)$/i) {\n \t\t\t\tforeach my $addr (parse_address_line($1)) {\n-\t\t\t\t\tprintf(\"(mbox) Adding to: %s from line '%s'\\n\",\n+\t\t\t\t\tprintf(__(\"(mbox) Adding to: %s from line '%s'\\n\"),\n \t\t\t\t\t\t$addr, $_) unless $quiet;\n \t\t\t\t\tpush @to, $addr;\n \t\t\t\t}\n@@ -1498,7 +1507,7 @@ foreach my $t (@files) {\n \t\t\t\t\t} else {\n \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n \t\t\t\t\t}\n-\t\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t\t$addr, $_) unless $quiet;\n \t\t\t\t\tpush @cc, $addr;\n \t\t\t\t}\n@@ -1532,7 +1541,7 @@ foreach my $t (@files) {\n \t\t\t# So let's support that, too.\n \t\t\t$input_format = 'lots';\n \t\t\tif (@cc == 0 && !$suppress_cc{'cc'}) {\n-\t\t\t\tprintf(\"(non-mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\tprintf(__(\"(non-mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$_, $_) unless $quiet;\n \t\t\t\tpush @cc, $_;\n \t\t\t} elsif (!defined $subject) {\n@@ -1555,7 +1564,7 @@ foreach my $t (@files) {\n \t\t\t\tnext if $suppress_cc{'bodycc'} and $what =~ /Cc/i;\n \t\t\t}\n \t\t\tpush @cc, $c;\n-\t\t\tprintf(\"(body) Adding cc: %s from line '%s'\\n\",\n+\t\t\tprintf(__(\"(body) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t$c, $_) unless $quiet;\n \t\t}\n \t}\n-- \n2.7.4\n\n"},{"id":"290499","messageId":"20160629150945.15015-8-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 07/11] i18n: add--interactive: mark edit_hunk_manually message for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:41Z","receivedAt":"2016-06-29T15:10:58Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark message of edit_hunk_manually displayed in the editing file when\nuser chooses 'e' option.  The message had to be unfolded to allow\ntranslation of the $participle verb.\n\nSome messages end up being exactly the same for some uses cases, but\nleft it for easier change in the future, e.g., wanting to change wording\nof one particular use case.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-add--interactive.perl | 60 ++++++++++++++++++++++++++++++++++++++---------\n 1 file changed, 49 insertions(+), 11 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex acbfa4e..235142c 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1057,22 +1057,60 @@ sub edit_hunk_manually {\n \tmy $fh;\n \topen $fh, '>', $hunkfile\n \t\tor die sprintf(__(\"failed to open hunk edit file for writing: %s\"), $!);\n-\tprint $fh \"# Manual hunk edit mode -- see bottom for a quick guide\\n\";\n+\tprint $fh __(\"# Manual hunk edit mode -- see bottom for a quick guide\\n\");\n \tprint $fh @$oldtext;\n-\tmy $participle = $patch_mode_flavour{PARTICIPLE};\n \tmy $is_reverse = $patch_mode_flavour{IS_REVERSE};\n \tmy ($remove_plus, $remove_minus) = $is_reverse ? ('-', '+') : ('+', '-');\n-\tprint $fh <<EOF;\n-# ---\n-# To remove '$remove_minus' lines, make them ' ' lines (context).\n-# To remove '$remove_plus' lines, delete them.\n+\tprint $fh sprintf(__(\n+\"# ---\n+# To remove '%s' lines, make them ' ' lines (context).\n+# To remove '%s' lines, delete them.\n # Lines starting with # will be removed.\n-#\n-# If the patch applies cleanly, the edited hunk will immediately be\n-# marked for $participle. If it does not apply cleanly, you will be given\n+#\"), $remove_minus, $remove_plus),\n+\"\\n\";\n+\tif ($patch_mode eq 'stage') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for staging. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'stash') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for stashing. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'reset_head') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for unstaging. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'reset_nothead') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for applying. If it does not apply cleanly, you will be given\n # an opportunity to edit again. If all lines of the hunk are removed,\n-# then the edit is aborted and the hunk is left unchanged.\n-EOF\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'checkout_index') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for discarding. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'checkout_head') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for discarding. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t} elsif ($patch_mode eq 'checkout_nothead') {\n+\t\tprint $fh __(\n+\"# If the patch applies cleanly, the edited hunk will immediately be\n+# marked for applying. If it does not apply cleanly, you will be given\n+# an opportunity to edit again. If all lines of the hunk are removed,\n+# then the edit is aborted and the hunk is left unchanged.\");\n+\t}\n \tclose $fh;\n \n \tchomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));\n-- \n2.7.4\n\n"},{"id":"290500","messageId":"20160629150945.15015-10-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 09/11] i18n: send-email: mark warnings and errors for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:43Z","receivedAt":"2016-06-29T15:11:04Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark warnings, errors and other messages for translation.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 36 ++++++++++++++++++------------------\n 1 file changed, 18 insertions(+), 18 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 2521832..e7f712e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -118,20 +118,20 @@ sub format_2822_time {\n \tmy $localmin = $localtm[1] + $localtm[2] * 60;\n \tmy $gmtmin = $gmttm[1] + $gmttm[2] * 60;\n \tif ($localtm[0] != $gmttm[0]) {\n-\t\tdie \"local zone differs from GMT by a non-minute interval\\n\";\n+\t\tdie __(\"local zone differs from GMT by a non-minute interval\\n\");\n \t}\n \tif ((($gmttm[6] + 1) % 7) == $localtm[6]) {\n \t\t$localmin += 1440;\n \t} elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {\n \t\t$localmin -= 1440;\n \t} elsif ($gmttm[6] != $localtm[6]) {\n-\t\tdie \"local time offset greater than or equal to 24 hours\\n\";\n+\t\tdie __(\"local time offset greater than or equal to 24 hours\\n\");\n \t}\n \tmy $offset = $localmin - $gmtmin;\n \tmy $offhour = $offset / 60;\n \tmy $offmin = abs($offset % 60);\n \tif (abs($offhour) >= 24) {\n-\t\tdie (\"local time offset greater than or equal to 24 hours\\n\");\n+\t\tdie __(\"local time offset greater than or equal to 24 hours\\n\");\n \t}\n \n \treturn sprintf(\"%s, %2d %s %d %02d:%02d:%02d %s%02d%02d\",\n@@ -199,13 +199,13 @@ sub do_edit {\n \t\tmap {\n \t\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $_);\n \t\t\tif (($? & 127) || ($? >> 8)) {\n-\t\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t\t\tdie(__(\"the editor exited uncleanly, aborting everything\"));\n \t\t\t}\n \t\t} @_;\n \t} else {\n \t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n \t\tif (($? & 127) || ($? >> 8)) {\n-\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t\tdie(__(\"the editor exited uncleanly, aborting everything\"));\n \t\t}\n \t}\n }\n@@ -299,7 +299,7 @@ my $help;\n my $rc = GetOptions(\"h\" => \\$help,\n                     \"dump-aliases\" => \\$dump_aliases);\n usage() unless $rc;\n-die \"--dump-aliases incompatible with other options\\n\"\n+die __(\"--dump-aliases incompatible with other options\\n\")\n     if !$help and $dump_aliases and @ARGV;\n $rc = GetOptions(\n \t\t    \"sender|from=s\" => \\$sender,\n@@ -362,7 +362,7 @@ unless ($rc) {\n     usage();\n }\n \n-die \"Cannot run git format-patch from outside a repository\\n\"\n+die __(\"Cannot run git format-patch from outside a repository\\n\")\n \tif $format_patch and not $repo;\n \n # Now, let's fill any that aren't set in with defaults:\n@@ -617,7 +617,7 @@ while (defined(my $f = shift @ARGV)) {\n }\n \n if (@rev_list_opts) {\n-\tdie \"Cannot run git format-patch from outside a repository\\n\"\n+\tdie __(\"Cannot run git format-patch from outside a repository\\n\")\n \t\tunless $repo;\n \tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n }\n@@ -636,7 +636,7 @@ if (@files) {\n \t\tprint $_,\"\\n\" for (@files);\n \t}\n } else {\n-\tprint STDERR \"\\nNo patch files specified!\\n\\n\";\n+\tprint STDERR __(\"\\nNo patch files specified!\\n\\n\");\n \tusage();\n }\n \n@@ -728,7 +728,7 @@ EOT\n \t\t\t$sender = $1;\n \t\t\tnext;\n \t\t} elsif (/^(?:To|Cc|Bcc):/i) {\n-\t\t\tprint \"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\";\n+\t\t\tprint __(\"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\");\n \t\t\tnext;\n \t\t}\n \t\tprint $c2 $_;\n@@ -737,7 +737,7 @@ EOT\n \tclose $c2;\n \n \tif ($summary_empty) {\n-\t\tprint \"Summary email is empty, skipping it\\n\";\n+\t\tprint __(\"Summary email is empty, skipping it\\n\");\n \t\t$compose = -1;\n \t}\n } elsif ($annotate) {\n@@ -1313,7 +1313,7 @@ Message-Id: $message_id\n \t\t$_ = ask(__(\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \"),\n \t\t         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,\n \t\t         default => $ask_default);\n-\t\tdie \"Send this email reply required\" unless defined $_;\n+\t\tdie __(\"Send this email reply required\") unless defined $_;\n \t\tif (/^n/i) {\n \t\t\treturn 0;\n \t\t} elsif (/^q/i) {\n@@ -1339,7 +1339,7 @@ Message-Id: $message_id\n \t} else {\n \n \t\tif (!defined $smtp_server) {\n-\t\t\tdie \"The required SMTP server is not properly defined.\"\n+\t\t\tdie __(\"The required SMTP server is not properly defined.\")\n \t\t}\n \n \t\tif ($smtp_encryption eq 'ssl') {\n@@ -1410,7 +1410,7 @@ Message-Id: $message_id\n \t\t$smtp->code =~ /250|200/ or die \"Failed to send $subject\\n\".$smtp->message;\n \t}\n \tif ($quiet) {\n-\t\tprintf (($dry_run ? \"Dry-\" : \"\").\"Sent %s\\n\", $subject);\n+\t\tprintf (($dry_run ? \"Dry-\" : \"\"). __(\"Sent %s\\n\"), $subject);\n \t} else {\n \t\tprint (($dry_run ? \"Dry-\" : \"\"). __(\"OK. Log says:\\n\"));\n \t\tif (!file_name_is_absolute($smtp_server)) {\n@@ -1424,10 +1424,10 @@ Message-Id: $message_id\n \t\t}\n \t\tprint $header, \"\\n\";\n \t\tif ($smtp) {\n-\t\t\tprint \"Result: \", $smtp->code, ' ',\n+\t\t\tprint __(\"Result: \"), $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t\t} else {\n-\t\t\tprint \"Result: OK\\n\";\n+\t\t\tprint __(\"Result: OK\\n\");\n \t\t}\n \t}\n \n@@ -1700,7 +1700,7 @@ sub apply_transfer_encoding {\n \t$message = MIME::Base64::decode($message)\n \t\tif ($from eq 'base64');\n \n-\tdie \"cannot send message as 7bit\"\n+\tdie __(\"cannot send message as 7bit\")\n \t\tif ($to eq '7bit' and $message =~ /[^[:ascii:]]/);\n \treturn $message\n \t\tif ($to eq '7bit' or $to eq '8bit');\n@@ -1708,7 +1708,7 @@ sub apply_transfer_encoding {\n \t\tif ($to eq 'quoted-printable');\n \treturn MIME::Base64::encode($message, \"\\n\")\n \t\tif ($to eq 'base64');\n-\tdie \"invalid transfer encoding\";\n+\tdie __(\"invalid transfer encoding\");\n }\n \n sub unique_email_list {\n-- \n2.7.4\n\n"},{"id":"290501","messageId":"20160629150945.15015-11-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 10/11] i18n: send-email: mark string with interpolation for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:44Z","receivedAt":"2016-06-29T15:11:07Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Mark warnings, errors and other messages that are interpolated for\ntranslation.\n\nWe must call sprintf() before calling die() and in few other\ncircumstances in order to interpolation take place.\n\nSigned-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-send-email.perl | 71 ++++++++++++++++++++++++++++-------------------------\n 1 file changed, 38 insertions(+), 33 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e7f712e..c29381b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -279,10 +279,13 @@ sub signal_handler {\n \t# tmp files from --compose\n \tif (defined $compose_filename) {\n \t\tif (-e $compose_filename) {\n-\t\t\tprint \"'$compose_filename' contains an intermediate version of the email you were composing.\\n\";\n+\t\t\tprintf __(\"'%s' contains an intermediate version \".\n+\t\t\t\t  \"of the email you were composing.\\n\"),\n+\t\t\t\t  $compose_filename;\n \t\t}\n \t\tif (-e ($compose_filename . \".final\")) {\n-\t\t\tprint \"'$compose_filename.final' contains the composed email.\\n\"\n+\t\t\tprintf __(\"'%s.final' contains the composed email.\\n\"),\n+\t\t\t\t  $compose_filename;\n \t\t}\n \t}\n \n@@ -431,7 +434,7 @@ $smtp_encryption = '' unless (defined $smtp_encryption);\n my(%suppress_cc);\n if (@suppress_cc) {\n \tforeach my $entry (@suppress_cc) {\n-\t\tdie \"Unknown --suppress-cc field: '$entry'\\n\"\n+\t\tdie sprintf(__(\"Unknown --suppress-cc field: '%s'\\n\"), $entry)\n \t\t\tunless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;\n \t\t$suppress_cc{$entry} = 1;\n \t}\n@@ -460,7 +463,7 @@ my $confirm_unconfigured = !defined $confirm;\n if ($confirm_unconfigured) {\n \t$confirm = scalar %suppress_cc ? 'compose' : 'auto';\n };\n-die \"Unknown --confirm setting: '$confirm'\\n\"\n+die sprintf(__(\"Unknown --confirm setting: '%s'\\n\"), $confirm)\n \tunless $confirm =~ /^(?:auto|cc|compose|always|never)/;\n \n # Debugging, print out the suppressions.\n@@ -492,16 +495,16 @@ my %aliases;\n sub parse_sendmail_alias {\n \tlocal $_ = shift;\n \tif (/\"/) {\n-\t\tprint STDERR \"warning: sendmail alias with quotes is not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: sendmail alias with quotes is not supported: %s\\n\"), $_;\n \t} elsif (/:include:/) {\n-\t\tprint STDERR \"warning: `:include:` not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: `:include:` not supported: %s\\n\"), $_;\n \t} elsif (/[\\/|]/) {\n-\t\tprint STDERR \"warning: `/file` or `|pipe` redirection not supported: $_\\n\";\n+\t\tprintf STDERR __(\"warning: `/file` or `|pipe` redirection not supported: %s\\n\"), $_;\n \t} elsif (/^(\\S+?)\\s*:\\s*(.+)$/) {\n \t\tmy ($alias, $addr) = ($1, $2);\n \t\t$aliases{$alias} = [ split_addrs($addr) ];\n \t} else {\n-\t\tprint STDERR \"warning: sendmail line is not recognized: $_\\n\";\n+\t\tprintf STDERR __(\"warning: sendmail line is not recognized: %s\\n\"), $_;\n \t}\n }\n \n@@ -582,13 +585,12 @@ sub is_format_patch_arg {\n \t\tif (defined($format_patch)) {\n \t\t\treturn $format_patch;\n \t\t}\n-\t\tdie(<<EOF);\n-File '$f' exists but it could also be the range of commits\n+\t\tdie sprintf(__(\n+\"File '%s' exists but it could also be the range of commits\n to produce patches for.  Please disambiguate by...\n \n-    * Saying \"./$f\" if you mean a file; or\n-    * Giving --format-patch option if you mean a range.\n-EOF\n+    * Saying \\\"./%s\\\" if you mean a file; or\n+    * Giving --format-patch option if you mean a range.\"), $f, $f);\n \t} catch Git::Error::Command with {\n \t\t# Not a valid revision.  Treat it as a filename.\n \t\treturn 0;\n@@ -604,7 +606,7 @@ while (defined(my $f = shift @ARGV)) {\n \t\t@ARGV = ();\n \t} elsif (-d $f and !is_format_patch_arg($f)) {\n \t\topendir my $dh, $f\n-\t\t\tor die \"Failed to opendir $f: $!\";\n+\t\t\tor die sprintf(__(\"Failed to opendir %s: %s\"), $f, $!);\n \n \t\tpush @files, grep { -f $_ } map { catfile($f, $_) }\n \t\t\t\tsort readdir $dh;\n@@ -626,7 +628,8 @@ if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n \t\t\tmy $error = validate_patch($f);\n-\t\t\t$error and die \"fatal: $f: $error\\nwarning: no patches were sent\\n\";\n+\t\t\t$error and die sprintf(__(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n+\t\t\t\t\t\t  $f, $error);\n \t\t}\n \t}\n }\n@@ -649,7 +652,7 @@ sub get_patch_subject {\n \t\treturn \"GIT: $1\\n\";\n \t}\n \tclose $fh;\n-\tdie \"No subject line in $fn ?\";\n+\tdie sprintf(__(\"No subject line in %s ?\"), $fn);\n }\n \n if ($compose) {\n@@ -659,7 +662,7 @@ if ($compose) {\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n \t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n \topen my $c, \">\", $compose_filename\n-\t\tor die \"Failed to open for writing $compose_filename: $!\";\n+\t\tor die sprintf(__(\"Failed to open for writing %s: %s\"), $compose_filename, $!);\n \n \n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n@@ -690,10 +693,10 @@ EOT\n \t}\n \n \topen my $c2, \">\", $compose_filename . \".final\"\n-\t\tor die \"Failed to open $compose_filename.final : \" . $!;\n+\t\tor die sprintf(__(\"Failed to open %s.final : %s\"), $compose_filename, $!);\n \n \topen $c, \"<\", $compose_filename\n-\t\tor die \"Failed to open $compose_filename : \" . $!;\n+\t\tor die sprintf(__(\"Failed to open %s : %s\"), $compose_filename, $!);\n \n \tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n \tmy $in_body = 0;\n@@ -767,7 +770,9 @@ sub ask {\n \t\t\treturn $resp;\n \t\t}\n \t\tif ($confirm_only) {\n-\t\t\tmy $yesno = $term->readline(\"Are you sure you want to use <$resp> [y/N]? \");\n+\t\t\t# TRANSLATORS: Keep [y/N] as is.\n+\t\t\tmy $yesno = $term->readline(\n+\t\t\t\tsprintf(__(\"Are you sure you want to use <%s> [y/N]? \"), $resp));\n \t\t\tif (defined $yesno && $yesno =~ /y/i) {\n \t\t\t\treturn $resp;\n \t\t\t}\n@@ -846,7 +851,7 @@ my %EXPANDED_ALIASES;\n sub expand_one_alias {\n \tmy $alias = shift;\n \tif ($EXPANDED_ALIASES{$alias}) {\n-\t\tdie \"fatal: alias '$alias' expands to itself\\n\";\n+\t\tdie sprintf(__(\"fatal: alias '%s' expands to itself\\n\"), $alias);\n \t}\n \tlocal $EXPANDED_ALIASES{$alias} = 1;\n \treturn $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;\n@@ -908,7 +913,7 @@ sub extract_valid_address {\n sub extract_valid_address_or_die {\n \tmy $address = shift;\n \t$address = extract_valid_address($address);\n-\tdie \"error: unable to extract a valid address from: $address\\n\"\n+\tdie sprintf(__(\"error: unable to extract a valid address from: %s\\n\"), $address)\n \t\tif !$address;\n \treturn $address;\n }\n@@ -916,7 +921,7 @@ sub extract_valid_address_or_die {\n sub validate_address {\n \tmy $address = shift;\n \twhile (!extract_valid_address($address)) {\n-\t\tprint STDERR \"error: unable to extract a valid address from: $address\\n\";\n+\t\tprintf STDERR __(\"error: unable to extract a valid address from: %s\\n\"), $address;\n \t\t# TRANSLATORS: Make sure to include [q] [d] [e] in your\n \t\t# translation. The program will only accept English input\n \t\t# at this point.\n@@ -1221,7 +1226,7 @@ sub ssl_verify_params {\n \t\treturn (SSL_verify_mode => SSL_VERIFY_PEER(),\n \t\t\tSSL_ca_file => $smtp_ssl_cert_path);\n \t} else {\n-\t\tdie \"CA path \\\"$smtp_ssl_cert_path\\\" does not exist\";\n+\t\tdie sprintf(__(\"CA path \\\"%s\\\" does not exist\"), $smtp_ssl_cert_path);\n \t}\n }\n \n@@ -1383,7 +1388,7 @@ Message-Id: $message_id\n \t\t\t\t\t# supported commands\n \t\t\t\t\t$smtp->hello($smtp_domain);\n \t\t\t\t} else {\n-\t\t\t\t\tdie \"Server does not support STARTTLS! \".$smtp->message;\n+\t\t\t\t\tdie sprintf(__(\"Server does not support STARTTLS! %s\"), $smtp->message);\n \t\t\t\t}\n \t\t\t}\n \t\t}\n@@ -1440,7 +1445,7 @@ $subject = $initial_subject;\n $message_num = 0;\n \n foreach my $t (@files) {\n-\topen my $fh, \"<\", $t or die \"can't open file $t\";\n+\topen my $fh, \"<\", $t or die sprintf(__(\"can't open file %s\"), $t);\n \n \tmy $author = undef;\n \tmy $sauthor = undef;\n@@ -1669,11 +1674,11 @@ sub recipients_cmd {\n \t\t$address = sanitize_address($address);\n \t\tnext if ($address eq $sender and $suppress_cc{'self'});\n \t\tpush @addresses, $address;\n-\t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n-\t\t       $what, $address, $cmd) unless $quiet;\n+\t\tprintf(__(\"(%s) Adding %s: %s from: '%s'\\n\"),\n+\t\t       $prefix, $what, $address, $cmd) unless $quiet;\n \t\t}\n \tclose $fh\n-\t    or die \"($prefix) failed to close pipe to '$cmd'\";\n+\t    or die sprintf(__(\"(%s) failed to close pipe to '%s'\"), $prefix, $cmd);\n \treturn @addresses;\n }\n \n@@ -1727,10 +1732,10 @@ sub unique_email_list {\n sub validate_patch {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tif (length($line) > 998) {\n-\t\t\treturn \"$.: patch contains a line longer than 998 characters\";\n+\t\t\treturn sprintf(__(\"%s: patch contains a line longer than 998 characters\"), $.);\n \t\t}\n \t}\n \treturn;\n@@ -1739,7 +1744,7 @@ sub validate_patch {\n sub file_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\treturn 1 if $line =~ /[^[:ascii:]]/;\n \t}\n@@ -1749,7 +1754,7 @@ sub file_has_nonascii {\n sub body_or_subject_has_nonascii {\n \tmy $fn = shift;\n \topen(my $fh, '<', $fn)\n-\t\tor die \"unable to open $fn: $!\\n\";\n+\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\n \t\tlast if $line =~ /^$/;\n \t\treturn 1 if $line =~ /^Subject.*[^[:ascii:]]/;\n-- \n2.7.4\n\n"},{"id":"290502","messageId":"20160629150945.15015-12-vascomalmeida@sapo.pt","threadId":"42747","inReplyTo":"20160629150945.15015-1-vascomalmeida@sapo.pt","subject":"[PATCH v2 11/11] i18n: difftool: mark warnings for translation","fromName":"Vasco Almeida","fromEmail":"vascomalmeida@sapo.pt","sentAt":"2016-06-29T15:09:45Z","receivedAt":"2016-06-29T15:11:15Z","isPatch":true,"sender":{"key":"vascomalmeida@sapo.pt","avatar":"https://avatars.githubusercontent.com/u/9001556?v=4"},"body":"Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>\n---\n git-difftool.perl | 18 ++++++++++--------\n 1 file changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex ebd13ba..de8d783 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -22,6 +22,7 @@ use File::Path qw(mkpath rmtree);\n use File::Temp qw(tempdir);\n use Getopt::Long qw(:config pass_through);\n use Git;\n+use Git::I18N;\n \n sub usage\n {\n@@ -144,7 +145,7 @@ sub setup_dir_diff\n \tmy $i = 0;\n \twhile ($i < $#rawdiff) {\n \t\tif ($rawdiff[$i] =~ /^::/) {\n-\t\t\twarn << 'EOF';\n+\t\t\twarn __ <<'EOF';\n Combined diff formats ('-c' and '--cc') are not supported in\n directory diff mode ('-d' and '--dir-diff').\n EOF\n@@ -451,11 +452,11 @@ sub dir_diff\n \t\t}\n \n \t\tif (exists $wt_modified{$file} and exists $tmp_modified{$file}) {\n-\t\t\tmy $errmsg = \"warning: Both files modified: \";\n-\t\t\t$errmsg .= \"'$workdir/$file' and '$b/$file'.\\n\";\n-\t\t\t$errmsg .= \"warning: Working tree file has been left.\\n\";\n-\t\t\t$errmsg .= \"warning:\\n\";\n-\t\t\twarn $errmsg;\n+\t\t\twarn sprintf(__(\n+\t\t\t\t\"warning: Both files modified:\\n\" .\n+\t\t\t\t\"'%s/%s' and '%s/%s'.\\n\" .\n+\t\t\t\t\"warning: Working tree file has been left.\\n\" .\n+\t\t\t\t\"warning:\\n\"), $workdir, $file, $b, $file);\n \t\t\t$error = 1;\n \t\t} elsif (exists $tmp_modified{$file}) {\n \t\t\tmy $mode = stat(\"$b/$file\")->mode;\n@@ -467,8 +468,9 @@ sub dir_diff\n \t\t}\n \t}\n \tif ($error) {\n-\t\twarn \"warning: Temporary files exist in '$tmpdir'.\\n\";\n-\t\twarn \"warning: You may want to cleanup or recover these.\\n\";\n+\t\twarn sprintf(__(\n+\t\t\t\"warning: Temporary files exist in '%s'.\\n\" .\n+\t\t\t\"warning: You may want to cleanup or recover these.\\n\"), $tmpdir);\n \t\texit(1);\n \t} else {\n \t\texit_cleanup($tmpdir, $rc);\n-- \n2.7.4\n\n"}]}