gettextize: git-pull
cover gettextize: git-pull
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(-)
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 1/8 gettextize: git-pull add git-sh-i18n
--- git-pull.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
git-pull.sh +1 -0
@@ -9,6 +9,7 @@ LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEA SUBDIRECTORY_OK=Yes OPTIONS_SPEC= . git-sh-setup +. git-sh-i18n set_reflog_action "pull $*" require_work_tree cd_to_toplevel
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 2/8 gettextize: git-pull die messages
In reply to Ævar Arnfjörð Bjarmason--- git-pull.sh | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
git-pull.sh +10 -10
@@ -18,20 +18,20 @@ cd_to_toplevel die_conflict () { git diff-index --cached --name-status -r --ignore-submodules HEAD -- if [ $(git config --bool --get advice.resolveConflict || echo true) = "true" ]; then - die "Pull is not possible because you have unmerged files. + die "$(gettext "Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm <file>' -as appropriate to mark resolution, or use 'git commit -a'." +as appropriate to mark resolution, or use '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 [ $(git config --bool --get advice.resolveConflict || echo true) = "true" ]; then - die "You have not concluded your merge (MERGE_HEAD exists). -Please, commit your changes before you can merge." + die "$(gettext "You have not concluded your merge (MERGE_HEAD exists). +Please, commit your changes before you can merge.")" 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 branch if test -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")" fi else git update-index --ignore-submodules --refresh && git diff-files --ignore-submodules --quiet && git diff-index --ignore-submodules --cached --quiet HEAD -- || - 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")" fi oldremoteref= && . git-parse-remote &&
@@ -258,11 +258,11 @@ case "$merge_head" in ?*' '?*) if test -z "$orig_head" then - die "Cannot merge multiple branches into empty head" + die "$(gettext "Cannot merge multiple branches into empty head")" fi if test true = "$rebase" then - die "Cannot rebase onto multiple branches" + die "$(gettext "Cannot rebase onto multiple branches")" fi ;; esac
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 3/8 gettextize: git-pull eval_gettext + die message
In reply to Ævar Arnfjörð Bjarmason--- git-pull.sh | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
git-pull.sh +4 -4
@@ -238,12 +238,12 @@ then echo >&2 "Warning: commit $orig_head." git update-index -q --refresh git read-tree -u -m "$orig_head" "$curr_head" || - die 'Cannot fast-forward your working tree. + die "$(eval_gettext "Cannot fast-forward your working tree. After making sure that you saved anything precious from -$ git diff '$orig_head' +\$ git diff \$orig_head output, run -$ git reset --hard -to recover.' +\$ git reset --hard +to recover.")" fi
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
Re: [PATCH/RFC 3/8] gettextize: git-pull eval_gettext + die message
git-pull.sh then · line 246
Quoted 7 lines · Ævar Arnfjörð Bjarmason
-$ git diff '$orig_head'
+\$ git diff \$orig_head
output, run
-$ git reset --hardgit-pull.sh +2
-1-to recover.' +\$ git reset --hard +to recover.")"
"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?
PATCH 4/8 gettextize: git-pull eval_gettext + warning message
In reply to Ævar Arnfjörð Bjarmason--- git-pull.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
git-pull.sh +3 -3
@@ -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-forwarding your working tree from +Warning: commit \$orig_head.")" git update-index -q --refresh git read-tree -u -m "$orig_head" "$curr_head" || die "$(eval_gettext "Cannot fast-forward your working tree.
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 5/8 gettextize: git-pull split up "no candidate" message
In reply to Ævar Arnfjörð Bjarmason--- git-pull.sh | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
git-pull.sh +6 -5
@@ -147,13 +147,14 @@ error_on_no_merge_candidates () { if [ $# -gt 1 ]; then if [ "$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. +Generally this means that you provided a wildcard refspec which had no +matches on the remote end."; echo else - printf "There are no candidates for merging " + gettext "There are no candidates for merging against among the refs that you just fetched. +Generally this means that you provided a wildcard refspec which had no +matches on the remote end."; echo fi - 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 [ $# -gt 0 ] && [ "$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"
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 6/8 gettextize: git-pull "You asked to pull" message
In reply to Ævar Arnfjörð BjarmasonGettextize 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.
--- git-pull.sh | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
git-pull.sh +6 -3
@@ -156,9 +156,12 @@ Generally this means that you provided a wildcard refspec which had no matches on the remote end."; echo fi elif [ $# -gt 0 ] && [ "$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 +a branch. Because this is not the default configured remote +for your current branch, you must specify a branch on the command line."; echo elif [ -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."
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 7/8 gettextize: git-pull "[...] not currently on a branch" message
In reply to Ævar Arnfjörð Bjarmason--- git-pull.sh | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
git-pull.sh +5 -5
@@ -163,11 +163,11 @@ matches on the remote end."; echo a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line."; echo elif [ -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' in your configuration file. +Please specify which remote branch you want to use on the command +line and try again (e.g. 'git pull <repository> <refspec>'). +See git-pull(1) for details."; echo elif [ -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"
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty
PATCH 8/8 gettextize: git-pull "rebase against" / "merge with" messages
In reply to Ævar Arnfjörð BjarmasonGettextize 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.
--- git-pull.sh | 84 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 52 insertions(+), 32 deletions(-)
git-pull.sh +52 -32
@@ -132,15 +132,6 @@ error_on_no_merge_candidates () { esac done - if test true = "$rebase" - then - op_type=rebase - op_prep=against - else - op_type=merge - op_prep=with - fi - curr_branch=${curr_branch#refs/heads/} upstream=$(git config "branch.$curr_branch.merge") remote=$(git config "branch.$curr_branch.remote")
@@ -169,30 +160,59 @@ Please specify which remote branch you want to use on the command line and try again (e.g. 'git pull <repository> <refspec>'). See git-pull(1) for details."; echo elif [ -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>" - test rebase = "$op_type" && - echo " rebase = true" - echo - echo " [remote \"<nickname>\"]" - echo " url = <url>" - echo " fetch = <refspec>" - echo - echo "See git-config(1) for details." + if test true = "$rebase" + then + eval_gettext "You asked me to pull without telling me which branch you +want to rebase against, and 'branch.\${curr_branch}.merge' in +your configuration file does not tell me, either. Please +specify which branch you want to use on the command line and +try again (e.g. 'git pull <repository> <refspec>'). +See git-pull(1) for details. + +If you often rebase against the same branch, you may want to +use something like the following in your configuration file: + + [branch \"\${curr_branch}\"] + remote = <nickname> + merge = <remote-ref> + rebase = true + + [remote \"<nickname>\"] + url = <url> + fetch = <refspec> + +See git-config(1) for details."; echo + else + eval_gettext "You asked me to pull without telling me which branch you +want to merge with, and 'branch.\${curr_branch}.merge' in +your configuration file does not tell me, either. Please +specify which branch you want to use on the command line and +try again (e.g. 'git pull <repository> <refspec>'). +See git-pull(1) for details. + +If you often merge with the same branch, you may want to +use something like the following in your configuration file: + + [branch \"\${curr_branch}\"] + remote = <nickname> + merge = <remote-ref> + + [remote \"<nickname>\"] + url = <url> + fetch = <refspec> + +See git-config(1) for details."; echo + fi else - 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/}" + if test true = "$rebase" + then + eval_gettext "Your configuration specifies to rebase against the ref '\$upstream_branch' +from the remote, but no such ref was fetched."; echo + else + eval_gettext "Your configuration specifies to merge with the ref '\$upstream_branch' +from the remote, but no such ref was fetched."; echo + fi fi exit 1 }
Signature · 1 line
1.7.3.rc1.110.g6776a.dirty