Skip to content

Commit 91810ab

Browse files
committed
Merge branch 'ab/i18n-scripts-basic'
* ab/i18n-scripts-basic: Makefile: add xgettext target for *.sh files git-sh-i18n.sh: add GIT_GETTEXT_POISON support git-sh-i18n.sh: add no-op gettext() and eval_gettext() wrappers git-sh-i18n--envsubst: our own envsubst(1) for eval_gettext()
2 parents be5ab43 + adc3b2b commit 91810ab

7 files changed

Lines changed: 602 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@
127127
/git-rm
128128
/git-send-email
129129
/git-send-pack
130+
/git-sh-i18n
131+
/git-sh-i18n--envsubst
130132
/git-sh-setup
133+
/git-sh-i18n
131134
/git-shell
132135
/git-shortlog
133136
/git-show
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
git-sh-i18n--envsubst(1)
2+
========================
3+
4+
NAME
5+
----
6+
git-sh-i18n--envsubst - Git's own envsubst(1) for i18n fallbacks
7+
8+
DESCRIPTION
9+
-----------
10+
11+
This is not a command the end user would want to run. Ever.
12+
This documentation is meant for people who are studying the
13+
plumbing scripts and/or are writing new ones.
14+
15+
git-sh-i18n--envsubst is Git's stripped-down copy of the GNU
16+
`envsubst(1)` program that comes with the GNU gettext package. It's
17+
used internally by linkgit:git-sh-i18n[1] to interpolate the variables
18+
passed to the the `eval_gettext` function.
19+
20+
No promises are made about the interface, or that this
21+
program won't disappear without warning in the next version
22+
of Git. Don't use it.
23+
24+
GIT
25+
---
26+
Part of the linkgit:git[1] suite

Documentation/git-sh-i18n.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
git-sh-i18n(1)
2+
==============
3+
4+
NAME
5+
----
6+
git-sh-i18n - Git's i18n setup code for shell scripts
7+
8+
SYNOPSIS
9+
--------
10+
'. "$(git --exec-path)/git-sh-i18n"'
11+
12+
DESCRIPTION
13+
-----------
14+
15+
This is not a command the end user would want to run. Ever.
16+
This documentation is meant for people who are studying the
17+
Porcelain-ish scripts and/or are writing new ones.
18+
19+
The 'git sh-i18n scriptlet is designed to be sourced (using
20+
`.`) by Git's porcelain programs implemented in shell
21+
script. It provides wrappers for the GNU `gettext` and
22+
`eval_gettext` functions accessible through the `gettext.sh`
23+
script, and provides pass-through fallbacks on systems
24+
without GNU gettext.
25+
26+
FUNCTIONS
27+
---------
28+
29+
gettext::
30+
Currently a dummy fall-through function implemented as a wrapper
31+
around `printf(1)`. Will be replaced by a real gettext
32+
implementation in a later version.
33+
34+
eval_gettext::
35+
Currently a dummy fall-through function implemented as a wrapper
36+
around `printf(1)` with variables expanded by the
37+
linkgit:git-sh-i18n--envsubst[1] helper. Will be replaced by a
38+
real gettext implementation in a later version.
39+
40+
GIT
41+
---
42+
Part of the linkgit:git[1] suite

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ SCRIPT_LIB += git-rebase--am
373373
SCRIPT_LIB += git-rebase--interactive
374374
SCRIPT_LIB += git-rebase--merge
375375
SCRIPT_LIB += git-sh-setup
376+
SCRIPT_LIB += git-sh-i18n
376377

377378
SCRIPT_PERL += git-add--interactive.perl
378379
SCRIPT_PERL += git-difftool.perl
@@ -406,6 +407,7 @@ PROGRAM_OBJS += shell.o
406407
PROGRAM_OBJS += show-index.o
407408
PROGRAM_OBJS += upload-pack.o
408409
PROGRAM_OBJS += http-backend.o
410+
PROGRAM_OBJS += sh-i18n--envsubst.o
409411

410412
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
411413

@@ -2037,10 +2039,14 @@ XGETTEXT_FLAGS = \
20372039
--from-code=UTF-8
20382040
XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
20392041
--keyword=_ --keyword=N_ --keyword="Q_:1,2"
2042+
XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell
20402043
LOCALIZED_C := $(C_OBJ:o=c)
2044+
LOCALIZED_SH := $(SCRIPT_SH)
20412045

20422046
po/git.pot: $(LOCALIZED_C)
2043-
$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) && \
2047+
$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)
2048+
$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \
2049+
$(LOCALIZED_SH)
20442050
mv $@+ $@
20452051

20462052
pot: po/git.pot

git-sh-i18n.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
4+
#
5+
# This is a skeleton no-op implementation of gettext for Git. It'll be
6+
# replaced by something that uses gettext.sh in a future patch series.
7+
8+
if test -z "$GIT_GETTEXT_POISON"
9+
then
10+
gettext () {
11+
printf "%s" "$1"
12+
}
13+
14+
eval_gettext () {
15+
printf "%s" "$1" | (
16+
export PATH $(git sh-i18n--envsubst --variables "$1");
17+
git sh-i18n--envsubst "$1"
18+
)
19+
}
20+
else
21+
gettext () {
22+
printf "%s" "# GETTEXT POISON #"
23+
}
24+
25+
eval_gettext () {
26+
printf "%s" "# GETTEXT POISON #"
27+
}
28+
fi
29+

0 commit comments

Comments
 (0)