This is an RFC on a series that makes git-pull.sh translatable. With
this git-bisect/rebase/stash/submodule are the only mainporcelain
commands that aren't translatable.
I'll be folding this into the next version of the ab/i18n series I'll
be sending to Junio. No need to apply it to the current one.
Ævar Arnfjörð Bjarmason (8):
gettextize: git-pull add git-sh-i18n
gettextize: git-pull die messages
gettextize: git-pull eval_gettext + die message
gettextize: git-pull eval_gettext + warning message
gettextize: git-pull split up "no candidate" message
gettextize: git-pull "You asked to pull" message
gettextize: git-pull "[...] not currently on a branch" message
gettextize: git-pull "rebase against" / "merge with" messages
git-pull.sh | 149 ++++++++++++++++++++++++++++++++++------------------------
1 files changed, 87 insertions(+), 62 deletions(-)
--
1.7.3.rc1.110.g6776a.dirty
Gettextize the "You asked to pull" error message. This message
interpolated $1 which won't work with eval_gettext for obvious
reasons, so I needed to provide an alias for it.
This also made the message easier to translate, and I added a
TRANSLATORS comment to make it even easier.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
git-pull.sh | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
@@ -156,9 +156,12 @@ Generally this means that you provided a wildcard refspec which had no matchesontheremoteend."; echofielif[$#-gt0]&&["$1"!="$remote"];then-echo"You asked to pull from the remote '$1', but did not specify"-echo"a branch. Because this is not the default configured remote"-echo"for your current branch, you must specify a branch on the command line."+requested_remote=$1+# TRANSLATORS: $requested_remote will be a remote name, like+# "origin" or "avar"+eval_gettext"You asked to pull from the remote '\$requested_remote', but did not specify+abranch.Becausethisisnotthedefaultconfiguredremote+foryourcurrentbranch,youmustspecifyabranchonthecommandline."; echoelif[-z"$curr_branch"];thenecho"You are not currently on a branch, so I cannot use any"echo"'branch.<branchname>.merge' in your configuration file."
@@ -163,11 +163,11 @@ matches on the remote end."; echo abranch.Becausethisisnotthedefaultconfiguredremoteforyourcurrentbranch,youmustspecifyabranchonthecommandline."; echoelif[-z"$curr_branch"];then-echo"You are not currently on a branch, so I cannot use any"-echo"'branch.<branchname>.merge' in your configuration file."-echo"Please specify which remote branch you want to use on the command"-echo"line and try again (e.g. 'git pull <repository> <refspec>')."-echo"See git-pull(1) for details."+gettext"You are not currently on a branch, so I cannot use any+'branch.<branchname>.merge'inyourconfigurationfile.+Pleasespecifywhichremotebranchyouwanttouseonthecommand+lineandtryagain(e.g.'git pull <repository> <refspec>').+Seegit-pull(1)fordetails."; echoelif[-z"$upstream"];thenecho"You asked me to pull without telling me which branch you"echo"want to $op_type$op_prep, and 'branch.${curr_branch}.merge' in"
@@ -233,9 +233,9 @@ then# $orig_head commit, but we are merging into $curr_head.# First update the working tree to match $curr_head.-echo>&2"Warning: fetch updated the current branch head."-echo>&2"Warning: fast-forwarding your working tree from"-echo>&2"Warning: commit $orig_head."+echo>&2"$(eval_gettext"Warning: fetch updated the current branch head.+Warning:fast-forwardingyourworkingtreefrom+Warning:commit\$orig_head.")"gitupdate-index-q--refreshgitread-tree-u-m"$orig_head""$curr_head"||die"$(eval_gettext"Cannot fast-forward your working tree.
@@ -147,13 +147,14 @@ error_on_no_merge_candidates () {if[$#-gt1];thenif["$rebase"=true];then-printf"There is no candidate for rebasing against "+gettext"There is no candidate for rebasing against among the refs that you just fetched.+Generallythismeansthatyouprovidedawildcardrefspecwhichhadno+matchesontheremoteend."; echoelse-printf"There are no candidates for merging "+gettext"There are no candidates for merging against among the refs that you just fetched.+Generallythismeansthatyouprovidedawildcardrefspecwhichhadno+matchesontheremoteend."; echofi-echo"among the refs that you just fetched."-echo"Generally this means that you provided a wildcard refspec which had no"-echo"matches on the remote end."elif[$#-gt0]&&["$1"!="$remote"];thenecho"You asked to pull from the remote '$1', but did not specify"echo"a branch. Because this is not the default configured remote"
@@ -18,20 +18,20 @@ cd_to_toplevel die_conflict(){gitdiff-index--cached--name-status-r--ignore-submodulesHEAD--if[$(gitconfig--bool--getadvice.resolveConflict||echotrue)="true"];then-die"Pull is not possible because you have unmerged files.+die"$(gettext"Pull is not possible because you have unmerged files. Please,fixthemupintheworktree,andthenuse'git add/rm <file>'-asappropriatetomarkresolution,oruse'git commit -a'."+asappropriatetomarkresolution,oruse'git commit -a'.")"else-die"Pull is not possible because you have unmerged files."+die"$(gettext"Pull is not possible because you have unmerged files.")"fi} die_merge(){if[$(gitconfig--bool--getadvice.resolveConflict||echotrue)="true"];then-die"You have not concluded your merge (MERGE_HEAD exists).-Please,commityourchangesbeforeyoucanmerge."+die"$(gettext"You have not concluded your merge (MERGE_HEAD exists).+Please,commityourchangesbeforeyoucanmerge.")"else-die"You have not concluded your merge (MERGE_HEAD exists)."+die"$(gettext"You have not concluded your merge (MERGE_HEAD exists).")"fi}
@@ -199,13 +199,13 @@ test true = "$rebase" && {# On an unborn branchiftest-f"$GIT_DIR/index"then-die"updating an unborn branch with changes added to the index"+die"$(gettext"updating an unborn branch with changes added to the index")"fielsegitupdate-index--ignore-submodules--refresh&&gitdiff-files--ignore-submodules--quiet&&gitdiff-index--ignore-submodules--cached--quietHEAD--||-die"refusing to pull with rebase: your working tree is not up-to-date"+die"$(gettext"refusing to pull with rebase: your working tree is not up-to-date")"fioldremoteref=&&.git-parse-remote&&
@@ -258,11 +258,11 @@ case "$merge_head" in ?*' '?*)iftest-z"$orig_head"then-die"Cannot merge multiple branches into empty head"+die"$(gettext"Cannot merge multiple branches into empty head")"fiiftesttrue="$rebase"then-die"Cannot rebase onto multiple branches"+die"$(gettext"Cannot rebase onto multiple branches")"fi;;esac
Gettextize the two messages that used "rebase against" and "merge
with". Split them into two depending on whether we are rebasing or not.
This results in some duplication, but makes it much easier for
translators to translate these messages.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
git-pull.sh | 84 ++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 52 insertions(+), 32 deletions(-)
@@ -169,30 +160,59 @@ Please specify which remote branch you want to use on the command lineandtryagain(e.g.'git pull <repository> <refspec>'). Seegit-pull(1)fordetails."; echoelif[-z"$upstream"];then-echo"You asked me to pull without telling me which branch you"-echo"want to $op_type$op_prep, and 'branch.${curr_branch}.merge' in"-echo"your configuration file does not tell me, either. Please"-echo"specify which branch you want to use on the command line and"-echo"try again (e.g. 'git pull <repository> <refspec>')."-echo"See git-pull(1) for details."-echo-echo"If you often $op_type$op_prep the same branch, you may want to"-echo"use something like the following in your configuration file:"-echo-echo" [branch \"${curr_branch}\"]"-echo" remote = <nickname>"-echo" merge = <remote-ref>"-testrebase="$op_type"&&-echo" rebase = true"-echo-echo" [remote \"<nickname>\"]"-echo" url = <url>"-echo" fetch = <refspec>"-echo-echo"See git-config(1) for details."+iftesttrue="$rebase"+then+eval_gettext"You asked me to pull without telling me which branch you+wanttorebaseagainst,and'branch.\${curr_branch}.merge'in+yourconfigurationfiledoesnottellme,either.Please+specifywhichbranchyouwanttouseonthecommandlineand+tryagain(e.g.'git pull <repository> <refspec>').+Seegit-pull(1)fordetails.++Ifyouoftenrebaseagainstthesamebranch,youmaywantto+usesomethinglikethefollowinginyourconfigurationfile:++[branch\"\${curr_branch}\"]+remote=<nickname>+merge=<remote-ref>+rebase=true++[remote\"<nickname>\"]+url=<url>+fetch=<refspec>++Seegit-config(1)fordetails."; echo+else+eval_gettext"You asked me to pull without telling me which branch you+wanttomergewith,and'branch.\${curr_branch}.merge'in+yourconfigurationfiledoesnottellme,either.Please+specifywhichbranchyouwanttouseonthecommandlineand+tryagain(e.g.'git pull <repository> <refspec>').+Seegit-pull(1)fordetails.++Ifyouoftenmergewiththesamebranch,youmaywantto+usesomethinglikethefollowinginyourconfigurationfile:++[branch\"\${curr_branch}\"]+remote=<nickname>+merge=<remote-ref>++[remote\"<nickname>\"]+url=<url>+fetch=<refspec>++Seegit-config(1)fordetails."; echo+fielse-echo"Your configuration specifies to $op_type$op_prep the ref '${upstream#refs/heads/}'"-echo"from the remote, but no such ref was fetched."+upstream_branch="${upstream#refs/heads/}"+iftesttrue="$rebase"+then+eval_gettext"Your configuration specifies to rebase against the ref '\$upstream_branch'+fromtheremote,butnosuchrefwasfetched."; echo+else+eval_gettext"Your configuration specifies to merge with the ref '\$upstream_branch'+fromtheremote,butnosuchrefwasfetched."; echo+fifiexit1}
@@ -9,6 +9,7 @@ LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEASUBDIRECTORY_OK=YesOPTIONS_SPEC= .git-sh-setup+.git-sh-i18n set_reflog_action"pull $*" require_work_tree cd_to_toplevel
"make pot" rightly whines about this:
git-pull.sh:265: warning: Although being used in a format string
position, the msgid is not a valid Shell format string. Reason:
The string refers to a shell variable whose value may be different
inside shell functions.
Just using "$" instead of "\$" for "$ git ...." works,
i.e. eval_gettext "foo $ bar" instead of eval_gettext "foo \$ bar".
Is that portable? Is " $ " always the same as ' $ ' in POSIX shells?