gettextize: git-submodule
cover gettextize: git-submodule
This is an RFC on a series that makes git-submodule.sh translatable. With this git-bisect/rebase/stash 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.
This is based on a master that has the "tests: use test_cmp instead of piping to diff(1)" patch applied. Untangling the two was a pain, and probably unnecessary since by the time this gets merged that patch will be in maint/master.
Ævar Arnfjörð Bjarmason (12):
gettextize: git-submodule add git-sh-i18n
gettextize: git-submodule echo + eval_gettext messages
gettextize: git-submodule say + eval_gettext messages
gettextize: git-submodule die + eval_gettext messages
gettextize: git-submodule $update_module say + die messages
gettextize: git-submodule "cached cannot be used" message
gettextize: git-submodule "Submodule change[...]" messages
gettextize: git-submodule $errmsg messages
gettextize: git-submodule "Entering [...]" message
gettextize: git-submodule "[...] path is ignored" message
gettextize: git-submodule "path not initialized" message
gettextize: git-submodule "blob" and "submodule" messages
git-submodule.sh | 94 +++++++++++++++++++++-------------------- t/t7400-submodule-basic.sh | 4 +- t/t7401-submodule-summary.sh | 12 +++--- t/t7407-submodule-foreach.sh | 4 +- 4 files changed, 58 insertions(+), 56 deletions(-)
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 1/12 gettextize: git-submodule add git-sh-i18n
--- git-submodule.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
git-submodule.sh +1 -0
@@ -14,6 +14,7 @@ USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <r or: $dashless [--quiet] sync [--] [<path>...]" OPTIONS_SPEC= . git-sh-setup +. git-sh-i18n . git-parse-remote require_work_tree
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 2/12 gettextize: git-submodule echo + eval_gettext messages
In reply to Ævar Arnfjörð Bjarmason--- git-submodule.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
git-submodule.sh +2 -2
@@ -219,7 +219,7 @@ cmd_add() then if test -d "$path"/.git -o -f "$path"/.git then - echo "Adding existing repo at '$path' to the index" + echo "$(eval_gettext "Adding existing repo at '\$path' to the index")" else die "'$path' already exists and is not a valid git repo" fi
@@ -626,7 +626,7 @@ cmd_summary() { ;; # removed *) # unexpected type - echo >&2 "unexpected mode $mod_dst" + echo >&2 "$(eval_gettext "unexpected mode \$mod_dst")" continue ;; esac fi
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 3/12 gettextize: git-submodule say + eval_gettext messages
In reply to Ævar Arnfjörð Bjarmason--- git-submodule.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-submodule.sh +1 -1
@@ -840,7 +840,7 @@ cmd_sync() if test -e "$path"/.git then ( - say "Synchronizing submodule url for '$name'" + say "$(eval_gettext "Synchronizing submodule url for '\$name'")" git config submodule."$name".url "$url" clear_local_git_env cd "$path"
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 4/12 gettextize: git-submodule die + eval_gettext messages
In reply to Ævar Arnfjörð Bjarmason--- git-submodule.sh | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-)
git-submodule.sh +20 -20
@@ -35,7 +35,7 @@ resolve_relative_url () { remote=$(get_default_remote) remoteurl=$(git config "remote.$remote.url") || - die "remote ($remote) does not have a url defined in .git/config" + die "$(eval_gettext "remote (\$remote) does not have a url defined in .git/config")" url="$1" remoteurl=${remoteurl%/} while test -n "$url"
@@ -76,7 +76,7 @@ module_name() name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' ) test -z "$name" && - die "No submodule mapping found in .gitmodules for path '$path'" + die "$(eval_gettext "No submodule mapping found in .gitmodules for path '\$path'")" echo "$name" }
@@ -102,11 +102,11 @@ module_clone() if test -d "$path" then rmdir "$path" 2>/dev/null || - die "Directory '$path' exists, but is neither empty nor a git repository" + die "$(eval_gettext "Directory '\$path' exists, but is neither empty nor a git repository")" fi test -e "$path" && - die "A file already exist at path '$path'" + die "$(eval_gettext "A file already exist at path '\$path'")" if test -n "$reference" then
@@ -114,7 +114,7 @@ module_clone() else git-clone -n "$url" "$path" fi || - die "Clone of '$url' into submodule path '$path' failed" + die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" } #
@@ -187,7 +187,7 @@ cmd_add() realrepo=$repo ;; *) - die "repo URL: '$repo' must be absolute or begin with ./|../" + die "$(eval_gettext "repo URL: '\$repo' must be absolute or begin with ./|../")" ;; esac
@@ -204,7 +204,7 @@ cmd_add() s|/*$|| ') git ls-files --error-unmatch "$path" > /dev/null 2>&1 && - die "'$path' already exists in the index" + die "$(eval_gettext "'\$path' already exists in the index")" if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 then
@@ -221,7 +221,7 @@ cmd_add() then echo "$(eval_gettext "Adding existing repo at '\$path' to the index")" else - die "'$path' already exists and is not a valid git repo" + die "$(eval_gettext "'\$path' already exists and is not a valid git repo")" fi case "$repo" in
@@ -244,16 +244,16 @@ cmd_add() '') git checkout -f -q ;; ?*) git checkout -f -q -b "$branch" "origin/$branch" ;; esac - ) || die "Unable to checkout submodule '$path'" + ) || die "$(eval_gettext "Unable to checkout submodule '\$path'")" fi git add $force "$path" || - die "Failed to add submodule '$path'" + die "$(eval_gettext "Failed to add submodule '\$path'")" git config -f .gitmodules submodule."$path".path "$path" && git config -f .gitmodules submodule."$path".url "$repo" && git add --force .gitmodules || - die "Failed to register submodule '$path'" + die "$(eval_gettext "Failed to register submodule '\$path'")" } #
@@ -303,7 +303,7 @@ cmd_foreach() cmd_foreach "--recursive" "$@" fi ) || - die "Stopping at '$path'; script returned non-zero status." + die "$(eval_gettext "Stopping at '\$path'; script returned non-zero status.")" fi done }
@@ -346,7 +346,7 @@ cmd_init() url=$(git config -f .gitmodules submodule."$name".url) test -z "$url" && - die "No url found for submodule path '$path' in .gitmodules" + die "$(eval_gettext "No url found for submodule path '\$path' in .gitmodules")" # Possibly a url relative to parent case "$url" in
@@ -356,14 +356,14 @@ cmd_init() esac git config submodule."$name".url "$url" || - die "Failed to register url for submodule path '$path'" + die "$(eval_gettext "Failed to register url for submodule path '\$path'")" upd="$(git config -f .gitmodules submodule."$name".update)" test -z "$upd" || git config submodule."$name".update "$upd" || - die "Failed to register update mode for submodule path '$path'" + die "$(eval_gettext "Failed to register update mode for submodule path '\$path'")" - say "Submodule '$name' ($url) registered for path '$path'" + say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$path'")" done }
@@ -453,7 +453,7 @@ cmd_update() else subsha1=$(clear_local_git_env; cd "$path" && git rev-parse --verify HEAD) || - die "Unable to find current revision in submodule path '$path'" + die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")" fi if ! test -z "$update"
@@ -473,7 +473,7 @@ cmd_update() then (clear_local_git_env; cd "$path" && git-fetch) || - die "Unable to fetch in submodule path '$path'" + die "$(eval_gettext "Unable to fetch in submodule path '\$path'")" fi case "$update_module" in
@@ -502,7 +502,7 @@ cmd_update() if test -n "$recursive" then (clear_local_git_env; cd "$path" && cmd_update $orig_args) || - die "Failed to recurse into submodule path '$path'" + die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" fi done }
@@ -793,7 +793,7 @@ cmd_status() cd "$path" && cmd_status $orig_args ) || - die "Failed to recurse into submodule path '$path'" + die "$(eval_gettext "Failed to recurse into submodule path '\$path'")" fi done }
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 5/12 gettextize: git-submodule $update_module say + die messages
In reply to Ævar Arnfjörð BjarmasonGettextize $update_module say and die messages. These messages needed to be split up to make them translatable.
--- git-submodule.sh | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
git-submodule.sh +8 -9
@@ -479,24 +479,23 @@ cmd_update() case "$update_module" in rebase) command="git rebase" - action="rebase" - msg="rebased onto" + die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")" + say_msg="$(eval_gettext "Submodule path '\$path': rebased into '\$sha1'")" ;; merge) command="git merge" - action="merge" - msg="merged in" + die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")" + say_msg="$(eval_gettext "Submodule path '\$path': merged in '\$sha1'")" ;; *) command="git checkout $force -q" - action="checkout" - msg="checked out" + die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$path'")" + say_msg="$(eval_gettext "Submodule path '\$path': checked out '\$sha1'")" ;; esac - (clear_local_git_env; cd "$path" && $command "$sha1") || - die "Unable to $action '$sha1' in submodule path '$path'" - say "Submodule path '$path': $msg '$sha1'" + (clear_local_git_env; cd "$path" && $command "$sha1") || die $die_msg + say $say_msg fi if test -n "$recursive"
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 6/12 gettextize: git-submodule "cached cannot be used" message
In reply to Ævar Arnfjörð BjarmasonGettextize the "--cached cannot be used with --files" message. Since this message starts with "--" we have to pass "--" as the first argument. This works with both GNU gettext 0.18.1 (as expected), and the gettext(1) on Solaris 10.
--- git-submodule.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-submodule.sh +1 -1
@@ -585,7 +585,7 @@ cmd_summary() { if [ -n "$files" ] then test -n "$cached" && - die "--cached cannot be used with --files" + die "$(gettext -- "--cached cannot be used with --files")" diff_cmd=diff-files head= fi
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 7/12 gettextize: git-submodule "Submodule change[...]" messages
In reply to Ævar Arnfjörð BjarmasonGettextize the "Submodules changed but not updated" and "Submodule changes to be committed" messages. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 4 ++-- t/t7401-submodule-summary.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
git-submodule.sh +2 -2
@@ -710,9 +710,9 @@ cmd_summary() { done | if test -n "$for_status"; then if [ -n "$files" ]; then - echo "# Submodules changed but not updated:" + gettext "# Submodules changed but not updated:"; echo else - echo "# Submodule changes to be committed:" + gettext "# Submodule changes to be committed:"; echo fi echo "#" sed -e 's|^|# |' -e 's|^# $|#|'
t/t7401-submodule-summary.sh +1 -1
@@ -225,7 +225,7 @@ EOF test_cmp expected actual " -test_expect_success '--for-status' " +test_expect_success NO_GETTEXT_POISON '--for-status' " git submodule summary --for-status HEAD^ >actual && test_cmp actual - <<EOF # Submodule changes to be committed:
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 8/12 gettextize: git-submodule $errmsg messages
In reply to Ævar Arnfjörð BjarmasonGettextize warning messages stored in the $errmsg variable using eval_gettext interpolation. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 6 +++--- t/t7401-submodule-summary.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
git-submodule.sh +3 -3
@@ -643,13 +643,13 @@ cmd_summary() { total_commits= case "$missing_src,$missing_dst" in t,) - errmsg=" Warn: $name doesn't contain commit $sha1_src" + errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_src")" ;; ,t) - errmsg=" Warn: $name doesn't contain commit $sha1_dst" + errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_dst")" ;; t,t) - errmsg=" Warn: $name doesn't contain commits $sha1_src and $sha1_dst" + errmsg="$(eval_gettext " Warn: \$name doesn't contain commits \$sha1_src and \$sha1_dst")" ;; *) errmsg=
t/t7401-submodule-summary.sh +1 -1
@@ -154,7 +154,7 @@ EOF rm -f sm1 && test_create_repo sm1 && head6=$(add_file sm1 foo6 foo7) -test_expect_success 'nonexistent commit' " +test_expect_success NO_GETTEXT_POISON 'nonexistent commit' " git submodule summary >actual && cat >expected <<-EOF && * sm1 $head4...$head6:
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 9/12 gettextize: git-submodule "Entering [...]" message
In reply to Ævar Arnfjörð BjarmasonGettextize the "Entering [...]" message. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 2 +- t/t7407-submodule-foreach.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
git-submodule.sh +1 -1
@@ -291,7 +291,7 @@ cmd_foreach() do if test -e "$path"/.git then - say "Entering '$prefix$path'" + say "$(eval_gettext "Entering '\$prefix\$path'")" name=$(module_name "$path") ( prefix="$prefix$path/"
t/t7407-submodule-foreach.sh +2 -2
@@ -68,7 +68,7 @@ Entering 'sub3' $pwd/clone-foo3-sub3-$sub3sha1 EOF -test_expect_success 'test basic "submodule foreach" usage' ' +test_expect_success NO_GETTEXT_POISON 'test basic "submodule foreach" usage' ' git clone super clone && ( cd clone &&
@@ -153,7 +153,7 @@ Entering 'sub2' Entering 'sub3' EOF -test_expect_success 'test messages from "foreach --recursive"' ' +test_expect_success NO_GETTEXT_POISON 'test messages from "foreach --recursive"' ' ( cd clone2 && git submodule foreach --recursive "true" > ../actual
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 10/12 gettextize: git-submodule "[...] path is ignored" message
In reply to Ævar Arnfjörð BjarmasonGettextize the "The following path is ignored" message. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 6 +++--- t/t7400-submodule-basic.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
git-submodule.sh +3 -3
@@ -208,9 +208,9 @@ cmd_add() if test -z "$force" && ! git add --dry-run --ignore-missing "$path" > /dev/null 2>&1 then - echo >&2 "The following path is ignored by one of your .gitignore files:" && - echo >&2 $path && - echo >&2 "Use -f if you really want to add it." + echo >&2 "$(eval_gettext "The following path is ignored by one of your .gitignore files: +\$path +Use -f if you really want to add it.")" exit 1 fi
t/t7400-submodule-basic.sh +1 -1
@@ -86,7 +86,7 @@ test_expect_success 'submodule add' ' test_cmp empty untracked ' -test_expect_success 'submodule add to .gitignored path fails' ' +test_expect_success NO_GETTEXT_POISON 'submodule add to .gitignored path fails' ' ( cd addtest-ignore && cat <<-\EOF >expect &&
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 11/12 gettextize: git-submodule "path not initialized" message
In reply to Ævar Arnfjörð BjarmasonGettextize the "Submodule path '$path' not initialized" message. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 4 ++-- t/t7400-submodule-basic.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
git-submodule.sh +2 -2
@@ -441,8 +441,8 @@ cmd_update() # Only mention uninitialized submodules when its # path have been specified test "$#" != "0" && - say "Submodule path '$path' not initialized" && - say "Maybe you want to use 'update --init'?" + say "$(eval_gettext "Submodule path '\$path' not initialized +Maybe you want to use 'update --init'?")" continue fi
t/t7400-submodule-basic.sh +1 -1
@@ -349,7 +349,7 @@ test_expect_success 'apply submodule diff' ' test_cmp empty staged ' -test_expect_success 'update --init' ' +test_expect_success NO_GETTEXT_POISON 'update --init' ' mv init init2 && git config -f .gitmodules submodule.example.url "$(pwd)/init2" && git config --remove-section submodule.example &&
Signature · 1 line
1.7.3.rc1.220.gb4d42
PATCH 12/12 gettextize: git-submodule "blob" and "submodule" messages
In reply to Ævar Arnfjörð BjarmasonGettextize the words "blob" and "submodule", which will be interpolated in a message emitted by git-submodule. This is explicitly tested for so we need to skip some tests with NO_GETTEXT_POISON.
--- git-submodule.sh | 6 ++++-- t/t7401-submodule-summary.sh | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-)
git-submodule.sh +4 -2
@@ -674,11 +674,13 @@ cmd_summary() { sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7) if test $status = T then + blob="$(gettext "blob")" + submodule="$(gettext "submodule")" if test $mod_dst = 160000 then - echo "* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:" + echo "* $name $sha1_abbr_src($blob)->$sha1_abbr_dst($submodule)$total_commits:" else - echo "* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:" + echo "* $name $sha1_abbr_src($submodule)->$sha1_abbr_dst($blob)$total_commits:" fi else echo "* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:"
t/t7401-submodule-summary.sh +4 -4
@@ -120,7 +120,7 @@ git add sm1 && rm -f sm1 && mv sm1-bak sm1 -test_expect_success 'typechanged submodule(submodule->blob), --cached' " +test_expect_success NO_GETTEXT_POISON 'typechanged submodule(submodule->blob), --cached' " git submodule summary --cached >actual && cat >expected <<-EOF && * sm1 $head4(submodule)->$head5(blob) (3):
@@ -130,7 +130,7 @@ EOF test_cmp actual expected " -test_expect_success 'typechanged submodule(submodule->blob), --files' " +test_expect_success NO_GETTEXT_POISON 'typechanged submodule(submodule->blob), --files' " git submodule summary --files >actual && cat >expected <<-EOF && * sm1 $head5(blob)->$head4(submodule) (3):
@@ -142,7 +142,7 @@ EOF rm -rf sm1 && git checkout-index sm1 -test_expect_success 'typechanged submodule(submodule->blob)' " +test_expect_success NO_GETTEXT_POISON 'typechanged submodule(submodule->blob)' " git submodule summary >actual && cat >expected <<-EOF && * sm1 $head4(submodule)->$head5(blob):
@@ -165,7 +165,7 @@ EOF " commit_file -test_expect_success 'typechanged submodule(blob->submodule)' " +test_expect_success NO_GETTEXT_POISON 'typechanged submodule(blob->submodule)' " git submodule summary >actual && cat >expected <<-EOF && * sm1 $head5(blob)->$head6(submodule) (2):
Signature · 1 line
1.7.3.rc1.220.gb4d42