Skip to content

Commit d5b2bbc

Browse files
jnavilagitster
authored andcommitted
l10n: introduce framework for localizing man pages
Providing git in localized version is a good step for general adoption of the tool. But as of now, if one needs to refer to the manual pages, they are still confronted to english. The aim is to provide documentation to users in their own language. The translation of the source asciidoc files is managed via po4a driven by the conf file Documentation/po4a.conf. Only the manpages are generated and installed by using the `install-man-l10n` target of the Makefile. The localized manpages for all the translated languages are installed in the man path in their own language folder, so that they can be accessed by man. Signed-off-by: Jean-Noel Avila <[email protected]>
1 parent 9d77b04 commit d5b2bbc

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Documentation/Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Guard against environment variables
2+
MAN1_L10N_TXT =
23
MAN1_TXT =
34
MAN5_TXT =
45
MAN7_TXT =
@@ -10,6 +11,7 @@ OBSOLETE_HTML =
1011
MAN1_TXT += $(filter-out \
1112
$(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
1213
$(wildcard git-*.txt))
14+
MAN1_L10N_TXT += $(wildcard po/*/man1/git-*.txt)
1315
MAN1_TXT += git.txt
1416
MAN1_TXT += gitk.txt
1517
MAN1_TXT += gitremote-helpers.txt
@@ -86,6 +88,7 @@ DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
8688
DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
8789
DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
8890
DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
91+
DOC_MAN1_L10N = $(patsubst %.txt,%.1,$(MAN1_L10N_TXT))
8992

9093
prefix ?= $(HOME)
9194
bindir ?= $(prefix)/bin
@@ -209,6 +212,7 @@ endif
209212

210213
ifneq ($(findstring $(MAKEFLAGS),s),s)
211214
ifndef V
215+
QUIET_PO4A = @echo ' ' PO4A $@;
212216
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
213217
QUIET_XMLTO = @echo ' ' XMLTO $@;
214218
QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
@@ -234,6 +238,15 @@ man1: $(DOC_MAN1)
234238
man5: $(DOC_MAN5)
235239
man7: $(DOC_MAN7)
236240

241+
man_l10n: po4a man1_p_l10n
242+
po4a: po4a.conf
243+
$(QUIET_PO4A)po4a po4a.conf
244+
245+
man1_p_l10n: po4a
246+
$(MAKE) man1_l10n
247+
248+
man1_l10n: $(DOC_MAN1_L10N)
249+
237250
info: git.info gitman.info
238251

239252
pdf: user-manual.pdf
@@ -247,6 +260,11 @@ install-man: man
247260
$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
248261
$(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
249262
$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
263+
$(MAKE) install-man-l10n
264+
265+
install-man-l10n: $(DOC_MAN1_L10N)
266+
$(INSTALL) -d -m 755 $(DESTDIR)$(mandir)/$(firstword $(subst /man1/, ,$(subst po/,,$<)))/man1
267+
$(INSTALL) -m 644 $< $(DESTDIR)$(mandir)$(subst po,,$<)
250268

251269
install-info: info
252270
$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
@@ -323,6 +341,7 @@ clean:
323341
$(RM) technical/*.html technical/api-index.txt
324342
$(RM) $(cmds_txt) $(mergetools_txt) *.made
325343
$(RM) manpage-base-url.xsl
344+
$(RM) po/*/*.1 po/*/*.txt
326345

327346
$(MAN_HTML): %.html : %.txt asciidoc.conf
328347
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
@@ -339,7 +358,7 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
339358

340359
%.1 %.5 %.7 : %.xml manpage-base-url.xsl
341360
$(QUIET_XMLTO)$(RM) $@ && \
342-
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
361+
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) -o $(dir $<) man $<
343362

344363
%.xml : %.txt asciidoc.conf
345364
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \

Documentation/po4a.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[po4a_langs] fr
2+
[po4a_paths] po/documentation.pot $lang:po/documentation.$lang.po
3+
[options] opt: " -k 80"
4+
5+
[type: asciidoc] ./git-add.txt $lang:./po/$lang/man1/git-add.txt

0 commit comments

Comments
 (0)