Skip to content

Commit 44635b4

Browse files
committed
Merge branch 'ab/i18n' into pu
* ab/i18n: (161 commits) po/de.po: complete German translation po/sv.po: add Swedish translation gettextize: git-bisect bisect_next_check "You need to" message gettextize: git-bisect [Y/n] messages gettextize: git-bisect bisect_replay + $1 messages gettextize: git-bisect bisect_reset + $1 messages gettextize: git-bisect bisect_run + $@ messages gettextize: git-bisect die + eval_gettext messages gettextize: git-bisect die + gettext messages gettextize: git-bisect echo + eval_gettext message gettextize: git-bisect echo + gettext messages gettextize: git-bisect gettext + echo message gettextize: git-bisect add git-sh-i18n gettextize: git-stash drop_stash say/die messages gettextize: git-stash "unknown option" message gettextize: git-stash die + eval_gettext $1 messages gettextize: git-stash die + eval_gettext $* messages gettextize: git-stash die + eval_gettext messages gettextize: git-stash die + gettext messages gettextize: git-stash say + gettext messages ... Conflicts: Documentation/CodingGuidelines Makefile builtin/commit.c builtin/init-db.c builtin/merge.c builtin/notes.c builtin/revert.c fast-import.c git-bisect.sh git-pull.sh git-submodule.sh t/t3501-revert-cherry-pick.sh wt-status.c
2 parents 555046d + 8a66182 commit 44635b4

File tree

125 files changed

+18222
-1143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+18222
-1143
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
/git-rm
128128
/git-send-email
129129
/git-send-pack
130+
/git-sh-i18n
130131
/git-sh-setup
131132
/git-shell
132133
/git-shortlog
@@ -218,3 +219,4 @@
218219
*.pdb
219220
/Debug/
220221
/Release/
222+
/share/

Documentation/CodingGuidelines

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ For shell scripts specifically (not exhaustive):
7777
are ERE elements not BRE (note that \? and \+ are not even part
7878
of BRE -- making them accessible from BRE is a GNU extension).
7979

80+
- Use Git's gettext wrappers in git-sh-i18n to make the user
81+
interface translatable. See "Marking strings for translation" in
82+
po/README.
83+
8084
For C programs:
8185

8286
- We use tabs to indent, and interpret tabs as taking up to
@@ -140,6 +144,10 @@ For C programs:
140144
- When we pass <string, length> pair to functions, we should try to
141145
pass them in that order.
142146

147+
- Use Git's gettext wrappers to make the user interface
148+
translatable. See "Marking strings for translation" in po/README.
149+
150+
143151
Writing Documentation:
144152

145153
Every user-visible change should be reflected in the documentation.

INSTALL

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ Issues of note:
9393
history graphically, and in git-gui. If you don't want gitk or
9494
git-gui, you can use NO_TCLTK.
9595

96+
- A gettext library is used by default for localizing Git. The
97+
primary target is GNU libintl, but the Solaris gettext
98+
implementation also works.
99+
100+
We need a gettext.h on the system for C code, gettext.sh (or
101+
Solaris gettext(1)) for shell scripts, and libintl-perl for Perl
102+
programs.
103+
104+
Set NO_GETTEXT to disable localization support and make Git only
105+
use English. Under autoconf the configure script will do this
106+
automatically if it can't find libintl on the system.
107+
96108
- Some platform specific issues are dealt with Makefile rules,
97109
but depending on your specific installation, you may not
98110
have all the libraries/tools needed, or you may have

Makefile

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ all::
3434
# Define NO_EXPAT if you do not have expat installed. git-http-push is
3535
# not built, and you cannot push using http:// and https:// transports.
3636
#
37+
# Define NO_GETTEXT if you don't want to build with Git with gettext
38+
# support. Building it requires GNU libintl or another gettext
39+
# implementation, and additionally libintl-perl at runtime.
40+
#
41+
# Define NEEDS_LIBINTL if you haven't set NO_GETTEXT and your system
42+
# needs to be explicitly linked to -lintl. It's defined automatically
43+
# on platforms where we don't expect glibc (Linux, Hurd,
44+
# GNU/kFreeBSD), which includes libintl.
45+
#
46+
# Define HAVE_LIBCHARSET_H if you haven't set NO_GETTEXT and you can't
47+
# trust the langinfo.h's nl_langinfo(CODESET) function to return the
48+
# current character set. GNU and Solaris have a nl_langinfo(CODESET),
49+
# FreeBSD can use either, but MinGW and some others need to use
50+
# libcharset.h's locale_charset() instead.
51+
#
52+
# Define GNU_GETTEXT if you're using the GNU implementation of
53+
# libintl. We define this everywhere except on Solaris, which has its
54+
# own gettext implementation. If GNU_GETTEXT is set we'll use GNU
55+
# extensions like `msgfmt --check'.
56+
#
57+
# Define GETTEXT_POISON to turn all strings that use gettext into
58+
# gibberish. This option should only be used by the Git developers to
59+
# check that the Git gettext implementation itself is sane.
60+
#
3761
# Define EXPATDIR=/foo/bar if your expat header and library files are in
3862
# /foo/bar/include and /foo/bar/lib directories.
3963
#
@@ -289,6 +313,7 @@ infodir = share/info
289313
gitexecdir = libexec/git-core
290314
sharedir = $(prefix)/share
291315
gitwebdir = $(sharedir)/gitweb
316+
localedir = $(sharedir)/locale
292317
template_dir = share/git-core/templates
293318
htmldir = share/doc/git-doc
294319
ifeq ($(prefix),/usr)
@@ -304,7 +329,7 @@ lib = lib
304329
# DESTDIR=
305330
pathsep = :
306331

307-
export prefix bindir sharedir sysconfdir gitwebdir
332+
export prefix bindir sharedir sysconfdir gitwebdir localedir
308333

309334
CC = gcc
310335
AR = ar
@@ -319,6 +344,8 @@ TCLTK_PATH = wish
319344
PTHREAD_LIBS = -lpthread
320345
PTHREAD_CFLAGS =
321346
GCOV = gcov
347+
XGETTEXT = xgettext
348+
MSGFMT = msgfmt
322349

323350
export TCL_PATH TCLTK_PATH
324351

@@ -380,6 +407,7 @@ SCRIPT_SH += git-web--browse.sh
380407
SCRIPT_LIB += git-mergetool--lib
381408
SCRIPT_LIB += git-parse-remote
382409
SCRIPT_LIB += git-sh-setup
410+
SCRIPT_LIB += git-sh-i18n
383411

384412
SCRIPT_PERL += git-add--interactive.perl
385413
SCRIPT_PERL += git-difftool.perl
@@ -557,6 +585,7 @@ LIB_H += userdiff.h
557585
LIB_H += utf8.h
558586
LIB_H += xdiff-interface.h
559587
LIB_H += xdiff/xdiff.h
588+
LIB_H += gettext.h
560589

561590
LIB_OBJS += abspath.o
562591
LIB_OBJS += advice.o
@@ -598,6 +627,9 @@ LIB_OBJS += entry.o
598627
LIB_OBJS += environment.o
599628
LIB_OBJS += exec_cmd.o
600629
LIB_OBJS += fsck.o
630+
ifndef NO_GETTEXT
631+
LIB_OBJS += gettext.o
632+
endif
601633
LIB_OBJS += graph.o
602634
LIB_OBJS += grep.o
603635
LIB_OBJS += hash.o
@@ -774,6 +806,22 @@ EXTLIBS =
774806
# Platform specific tweaks
775807
#
776808

809+
# Platform specific defaults. Where we'd only like some feature on the
810+
# minority of systems, e.g. if linking to a library isn't needed
811+
# because its features are included in the GNU C library.
812+
ifndef NO_GETTEXT
813+
# Systems that use GNU gettext and glibc are the exception
814+
NEEDS_LIBINTL = YesPlease
815+
816+
# Systems that don't use GNU gettext are the exception. Only
817+
# Solaris has a mature non-GNU gettext implementation.
818+
GNU_GETTEXT = YesPlease
819+
820+
# Since we assume a GNU gettext by default we also assume a
821+
# GNU-like langinfo.h by default
822+
HAVE_LIBCHARSET_H =
823+
endif
824+
777825
# We choose to avoid "if .. else if .. else .. endif endif"
778826
# because maintaining the nesting to match is a pain. If
779827
# we had "elif" things would have been much nicer...
@@ -789,11 +837,13 @@ ifeq ($(uname_S),Linux)
789837
NO_STRLCPY = YesPlease
790838
NO_MKSTEMPS = YesPlease
791839
HAVE_PATHS_H = YesPlease
840+
NEEDS_LIBINTL =
792841
endif
793842
ifeq ($(uname_S),GNU/kFreeBSD)
794843
NO_STRLCPY = YesPlease
795844
NO_MKSTEMPS = YesPlease
796845
HAVE_PATHS_H = YesPlease
846+
NEEDS_LIBINTL =
797847
endif
798848
ifeq ($(uname_S),UnixWare)
799849
CC = cc
@@ -860,6 +910,9 @@ ifeq ($(uname_S),SunOS)
860910
NO_MKSTEMPS = YesPlease
861911
NO_REGEX = YesPlease
862912
NO_FNMATCH_CASEFOLD = YesPlease
913+
ifndef NO_GETTEXT
914+
GNU_GETTEXT =
915+
endif
863916
ifeq ($(uname_R),5.6)
864917
SOCKLEN_T = int
865918
NO_HSTRERROR = YesPlease
@@ -986,6 +1039,7 @@ ifeq ($(uname_S),GNU)
9861039
NO_STRLCPY=YesPlease
9871040
NO_MKSTEMPS = YesPlease
9881041
HAVE_PATHS_H = YesPlease
1042+
NEEDS_LIBINTL =
9891043
endif
9901044
ifeq ($(uname_S),IRIX)
9911045
NO_SETENV = YesPlease
@@ -1180,6 +1234,9 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT))
11801234
EXTLIBS += /mingw/lib/libz.a
11811235
NO_R_TO_GCC_LINKER = YesPlease
11821236
INTERNAL_QSORT = YesPlease
1237+
ifndef NO_GETTEXT
1238+
HAVE_LIBCHARSET_H = YesPlease
1239+
endif
11831240
else
11841241
NO_CURL = YesPlease
11851242
endif
@@ -1540,6 +1597,22 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
15401597
export GIT_TEST_CMP_USE_COPIED_CONTEXT
15411598
endif
15421599

1600+
ifdef NO_GETTEXT
1601+
COMPAT_CFLAGS += -DNO_GETTEXT
1602+
endif
1603+
1604+
ifdef NEEDS_LIBINTL
1605+
EXTLIBS += -lintl
1606+
endif
1607+
1608+
ifdef GNU_GETTEXT
1609+
MSGFMT += --check
1610+
endif
1611+
1612+
ifdef GETTEXT_POISON
1613+
COMPAT_CFLAGS += -DGETTEXT_POISON
1614+
endif
1615+
15431616
ifeq ($(TCLTK_PATH),)
15441617
NO_TCLTK=NoThanks
15451618
endif
@@ -1570,6 +1643,7 @@ ifndef V
15701643
QUIET_GEN = @echo ' ' GEN $@;
15711644
QUIET_LNCP = @echo ' ' LN/CP $@;
15721645
QUIET_GCOV = @echo ' ' GCOV $@;
1646+
QUIET_MSGFMT = @echo ' ' MSGFMT $@;
15731647
QUIET_SUBDIR0 = +@subdir=
15741648
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
15751649
$(MAKE) $(PRINT_DIR) -C $$subdir
@@ -1599,7 +1673,9 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
15991673
htmldir_SQ = $(subst ','\'',$(htmldir))
16001674
prefix_SQ = $(subst ','\'',$(prefix))
16011675
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
1676+
sharedir_SQ = $(subst ','\'',$(sharedir))
16021677

1678+
LOCALEDIR_SQ = $(subst ','\'',$(localedir))
16031679
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
16041680
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
16051681
PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
@@ -1649,7 +1725,7 @@ ifndef NO_TCLTK
16491725
$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
16501726
endif
16511727
ifndef NO_PERL
1652-
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1728+
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
16531729
endif
16541730
ifndef NO_PYTHON
16551731
$(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
@@ -1695,6 +1771,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
16951771
-e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
16961772
-e 's|@@DIFF@@|$(DIFF_SQ)|' \
16971773
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1774+
-e 's|@@LOCALEDIR@@|$(LOCALEDIR_SQ)|g' \
16981775
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
16991776
-e $(BROKEN_PATH_FIX) \
17001777
$@.sh >$@+
@@ -1970,6 +2047,10 @@ attr.s attr.o: EXTRA_CPPFLAGS = -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"'
19702047

19712048
http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"'
19722049

2050+
ifdef HAVE_LIBCHARSET_H
2051+
gettext.s gettext.o: EXTRA_CPPFLAGS = -DHAVE_LIBCHARSET_H
2052+
endif
2053+
19732054
ifdef NO_EXPAT
19742055
http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
19752056
endif
@@ -2043,6 +2124,41 @@ cscope:
20432124
$(RM) cscope*
20442125
$(FIND) . -name '*.[hcS]' -print | xargs cscope -b
20452126

2127+
XGETTEXT_OPTIONS = \
2128+
--add-comments \
2129+
--msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \
2130+
--from-code=UTF-8 \
2131+
--output=po/git.pot
2132+
2133+
XGETTEXT_OPTIONS_C = $(XGETTEXT_OPTIONS) --keyword=_ --keyword=N_ --language=C
2134+
XGETTEXT_OPTIONS_SH = $(XGETTEXT_OPTIONS) --language=Shell
2135+
XGETTEXT_OPTIONS_PERL = $(XGETTEXT_OPTIONS) --keyword=__ --language=Perl
2136+
2137+
LOCALIZED_C = $(C_OBJ:o=c)
2138+
LOCALIZED_SH = $(SCRIPT_SH)
2139+
LOCALIZED_PERL = $(SCRIPT_PERL)
2140+
2141+
ifdef XGETTEXT_INCLUDE_TESTS
2142+
LOCALIZED_C += t/t0200/test.c
2143+
LOCALIZED_SH += t/t0200/test.sh
2144+
LOCALIZED_PERL += t/t0200/test.perl
2145+
endif
2146+
2147+
pot:
2148+
$(XGETTEXT) $(XGETTEXT_OPTIONS_C) $(LOCALIZED_C)
2149+
$(XGETTEXT) $(XGETTEXT_OPTIONS_SH) --join-existing $(LOCALIZED_SH)
2150+
$(XGETTEXT) $(XGETTEXT_OPTIONS_PERL) --join-existing $(LOCALIZED_PERL)
2151+
2152+
POFILES := $(wildcard po/*.po)
2153+
MOFILES := $(patsubst po/%.po,share/locale/%/LC_MESSAGES/git.mo,$(POFILES))
2154+
MODIRS := $(patsubst po/%.po,share/locale/%/LC_MESSAGES/,$(POFILES))
2155+
ifndef NO_GETTEXT
2156+
all:: $(MOFILES)
2157+
endif
2158+
share/locale/%/LC_MESSAGES/git.mo: po/%.po
2159+
@mkdir -p $(dir $@)
2160+
$(QUIET_MSGFMT)$(MSGFMT) -o $@ $<
2161+
20462162
### Detect prefix changes
20472163
TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\
20482164
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
@@ -2072,6 +2188,8 @@ endif
20722188
ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
20732189
@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
20742190
endif
2191+
@echo NO_GETTEXT=\''$(subst ','\'',$(subst ','\'',$(NO_GETTEXT)))'\' >>$@
2192+
@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
20752193

20762194
### Detect Tck/Tk interpreter path changes
20772195
ifndef NO_TCLTK
@@ -2169,6 +2287,11 @@ install: all
21692287
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
21702288
$(INSTALL) -m 644 $(SCRIPT_LIB) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
21712289
$(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
2290+
ifndef NO_GETTEXT
2291+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sharedir_SQ)/locale'
2292+
(cd share && tar cf - locale) | \
2293+
(cd '$(DESTDIR_SQ)$(sharedir_SQ)' && umask 022 && tar xof -)
2294+
endif
21722295
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
21732296
ifndef NO_PERL
21742297
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
@@ -2326,6 +2449,10 @@ ifndef NO_TCLTK
23262449
$(MAKE) -C git-gui clean
23272450
endif
23282451
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2452+
ifndef NO_GETTEXT
2453+
$(RM) po/git.pot
2454+
$(RM) -r share/
2455+
endif
23292456

23302457
.PHONY: all install clean strip
23312458
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "cache.h"
77
#include "commit.h"
88
#include "notes.h"
9+
#include "gettext.h"
910

1011
#define DEFAULT_MERGE_LOG_LEN 20
1112

0 commit comments

Comments
 (0)