From: Vasco Almeida <vascomalmeida@sapo.pt>
To: git@vger.kernel.org
Cc: "Vasco Almeida" <vascomalmeida@sapo.pt>,
"Jiang Xin" <worldhello.net@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>
Subject: [PATCH v2 13/22] i18n: git-sh-setup.sh: mark strings for translation
Date: Mon, 23 May 2016 19:27:32 +0000 [thread overview]
Message-ID: <1464031661-18988-14-git-send-email-vascomalmeida@sapo.pt> (raw)
In-Reply-To: <1464031661-18988-1-git-send-email-vascomalmeida@sapo.pt>
Positional arguments, such as $0, $1, etc, need to be stored on shell
variables for use in translatable strings, according to gettext manual.
Add git-sh-setup.sh to LOCALIZED_SH variable in Makefile to enable
extraction of string marked for translation by xgettext.
Although git-sh-setup.sh is a shell library to be sourced by other shell
scripts, it is necessary to source git-sh-i18n at this point, because
some scripts don't do it themselves. Not sourcing git-sh-i18n would lead
to failure due to, for instance, gettextln not being found.
Source "$(git --exec-path)"/git-sh-i18n instead of simply git-sh-i18n,
because latter case would fail test t2300-cd-to-toplevel.sh.
Signed-off-by: Vasco Almeida <vascomalmeida@sapo.pt>
---
Makefile | 4 +++-
git-sh-setup.sh | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index bc3d41e..d31fcf2 100644
--- a/Makefile
+++ b/Makefile
@@ -2062,7 +2062,9 @@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
--keyword=gettextln --keyword=eval_gettextln
XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
-LOCALIZED_SH = $(SCRIPT_SH) git-parse-remote.sh
+LOCALIZED_SH = $(SCRIPT_SH)
+LOCALIZED_SH += git-parse-remote.sh
+LOCALIZED_SH += git-sh-setup.sh
LOCALIZED_PERL = $(SCRIPT_PERL)
ifdef XGETTEXT_INCLUDE_TESTS
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index c48139a..55efa23 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -2,6 +2,10 @@
# to set up some variables pointing at the normal git directories and
# a few helper shell functions.
+# Some shell scripts source git-sh-setup (i.e. this scriplet) but
+# don't source git-sh-i18n which is needed here for gettext support.
+. "$(git --exec-path)"/git-sh-i18n
+
# Having this variable in your environment would break scripts because
# you would cause "cd" to be taken to unexpected places. If you
# like CDPATH, define it for your interactive shell sessions without
@@ -83,14 +87,14 @@ if test -n "$OPTIONS_SPEC"; then
else
dashless=$(basename -- "$0" | sed -e 's/-/ /')
usage() {
- die "usage: $dashless $USAGE"
+ die "$(gettext usage:) $dashless $USAGE"
}
if [ -z "$LONG_USAGE" ]
then
- LONG_USAGE="usage: $dashless $USAGE"
+ LONG_USAGE="$(gettext usage:) $dashless $USAGE"
else
- LONG_USAGE="usage: $dashless $USAGE
+ LONG_USAGE="$(gettext usage:) $dashless $USAGE
$LONG_USAGE"
fi
@@ -182,48 +186,72 @@ is_bare_repository () {
cd_to_toplevel () {
cdup=$(git rev-parse --show-toplevel) &&
cd "$cdup" || {
- echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+ gettextln "Cannot chdir to \$cdup, the toplevel of the working tree" >&2
exit 1
}
}
require_work_tree_exists () {
+ program_name=$0
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
- die "fatal: $0 cannot be used without a working tree."
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
fi
}
require_work_tree () {
+ program_name=$0
test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
- die "fatal: $0 cannot be used without a working tree."
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
}
require_clean_work_tree () {
+ action=$1
+ hint=$2
git rev-parse --verify HEAD >/dev/null || exit 1
git update-index -q --ignore-submodules --refresh
err=0
if ! git diff-files --quiet --ignore-submodules
then
- echo >&2 "Cannot $1: You have unstaged changes."
+ case "$action" in
+ rebase)
+ gettextln "Cannot rebase: You have unstaged changes." >&2
+ ;;
+ "pull with rebase")
+ gettextln "Cannot pull with rebase: You have unstaged changes." >&2
+ ;;
+ *)
+ eval_gettextln "Cannot \$action: You have unstaged changes." >&2
+ ;;
+ esac
err=1
fi
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
then
- if [ $err = 0 ]
+ if test $err = 0
then
- echo >&2 "Cannot $1: Your index contains uncommitted changes."
+ case "$action" in
+ rebase)
+ gettextln "Cannot rebase: Your index contains uncommitted changes." >&2
+ ;;
+ "pull with rebase")
+ gettextln "Cannot pull with rebase: Your index contains uncommitted changes." >&2
+ ;;
+ *)
+ eval_gettextln "Cannot \$action: Your index contains uncommitted changes." >&2
+ ;;
+ esac
else
- echo >&2 "Additionally, your index contains uncommitted changes."
+ gettextln "Additionally, your index contains uncommitted changes." >&2
fi
err=1
fi
- if [ $err = 1 ]
+ if test $err = 1
then
- test -n "$2" && echo >&2 "$2"
+ test -n "$hint" && echo "$2" >&2
exit 1
fi
}
@@ -336,12 +364,12 @@ git_dir_init () {
then
test -z "$(git rev-parse --show-cdup)" || {
exit=$?
- echo >&2 "You need to run this command from the toplevel of the working tree."
+ gettextln "You need to run this command from the toplevel of the working tree." >&2
exit $exit
}
fi
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
- echo >&2 "Unable to determine absolute path of git directory"
+ gettextln "Unable to determine absolute path of git directory" >&2
exit 1
}
: ${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}
--
2.7.3
next prev parent reply other threads:[~2016-05-23 19:30 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-23 19:27 [PATCH v2 00/22] i18n and test updates Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 01/22] i18n: builtin/remote.c: fix mark for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 02/22] i18n: advice: mark string about detached head " Vasco Almeida
2016-05-30 11:03 ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 03/22] i18n: advice: internationalize message for conflicts Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 04/22] i18n: transport: mark strings for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 05/22] i18n: sequencer: mark entire sentences " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 06/22] i18n: sequencer: mark string " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 07/22] i18n: merge-octopus: mark messages " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 08/22] merge-octupus: use die shell function from git-sh-setup.sh Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 09/22] i18n: rebase: fix marked string to use eval_gettext variant Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 10/22] i18n: rebase: mark placeholder for translation Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 11/22] i18n: bisect: simplify error message for i18n Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 12/22] t6030: update to use test_i18ncmp Vasco Almeida
2016-05-23 19:27 ` Vasco Almeida [this message]
2016-05-26 22:46 ` [PATCH v2 13/22] i18n: git-sh-setup.sh: mark strings for translation Junio C Hamano
2016-05-27 10:17 ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 14/22] i18n: rebase-interactive: " Vasco Almeida
2016-05-26 22:36 ` Junio C Hamano
2016-05-27 10:08 ` Vasco Almeida
2016-05-27 16:58 ` Junio C Hamano
2016-05-23 19:27 ` [PATCH v2 15/22] i18n: rebase-interactive: mark here-doc " Vasco Almeida
2016-05-25 13:13 ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 16/22] i18n: rebase-interactive: mark comments of squash " Vasco Almeida
2016-05-26 22:35 ` Junio C Hamano
2016-05-27 10:36 ` Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 17/22] i18n: setup: mark strings " Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 18/22] tests: use test_i18n* functions to suppress false positives Vasco Almeida
2016-05-27 17:08 ` Junio C Hamano
2016-05-27 19:34 ` Vasco Almeida
2016-05-27 19:51 ` Junio C Hamano
2016-05-23 19:27 ` [PATCH v2 19/22] tests: unpack-trees: update to use test_i18n* functions Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 20/22] t9003: become resilient to GETTEXT_POISON Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 21/22] t4153: fix negated test_i18ngrep call Vasco Almeida
2016-05-23 19:27 ` [PATCH v2 22/22] t5523: use test_i18ngrep for negation Vasco Almeida
2016-05-27 17:11 ` [PATCH v2 00/22] i18n and test updates Junio C Hamano
2016-05-28 8:18 ` Vasco Almeida
2016-05-30 0:03 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464031661-18988-14-git-send-email-vascomalmeida@sapo.pt \
--to=vascomalmeida@sapo.pt \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
--cc=worldhello.net@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).