nls: Update translations.
[jackhill/guix/guix.git] / doc / local.mk
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
3 # Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
4 # Copyright © 2013 Andreas Enge <andreas@enge.fr>
5 # Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
6 # Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
7 # Copyright © 2018, 2021 Julien Lepiller <julien@lepiller.eu>
8 #
9 # This file is part of GNU Guix.
10 #
11 # GNU Guix is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or (at
14 # your option) any later version.
15 #
16 # GNU Guix is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 # If adding a language, update the following variables, and info_TEXINFOS.
25 MANUAL_LANGUAGES = de es fa fr it ko pt_BR ru sk zh_CN
26 COOKBOOK_LANGUAGES = de fa fr ko ru sk zh_Hans
27
28 # Arg1: A list of languages codes.
29 # Arg2: The file name stem.
30 lang_to_texinfo = $(foreach lang,$(1),%D%/$(2).$(lang).texi)
31
32 # Automake does not understand GNU Make non-standard extensions,
33 # unfortunately, so we cannot use the above patsubst-based function here.
34 info_TEXINFOS = %D%/guix.texi \
35 %D%/guix.de.texi \
36 %D%/guix.es.texi \
37 %D%/guix.fa.texi \
38 %D%/guix.fr.texi \
39 %D%/guix.it.texi \
40 %D%/guix.ko.texi \
41 %D%/guix.pt_BR.texi \
42 %D%/guix.ru.texi \
43 %D%/guix.sk.texi \
44 %D%/guix.zh_CN.texi \
45 %D%/guix-cookbook.texi \
46 %D%/guix-cookbook.de.texi \
47 %D%/guix-cookbook.fa.texi \
48 %D%/guix-cookbook.fr.texi \
49 %D%/guix-cookbook.ko.texi \
50 %D%/guix-cookbook.ru.texi \
51 %D%/guix-cookbook.sk.texi \
52 %D%/guix-cookbook.zh_Hans.texi
53
54 %C%_guix_TEXINFOS = \
55 %D%/contributing.texi \
56 %D%/fdl-1.3.texi
57
58 DOT_FILES = \
59 %D%/images/bootstrap-graph.dot \
60 %D%/images/bootstrap-packages.dot \
61 %D%/images/coreutils-graph.dot \
62 %D%/images/coreutils-bag-graph.dot \
63 %D%/images/gcc-core-mesboot0-graph.dot \
64 %D%/images/service-graph.dot \
65 %D%/images/shepherd-graph.dot
66
67 DOT_VECTOR_GRAPHICS = \
68 $(DOT_FILES:%.dot=%.eps) \
69 $(DOT_FILES:%.dot=%.pdf)
70
71 EXTRA_DIST += \
72 %D%/htmlxref.cnf \
73 $(DOT_FILES) \
74 $(DOT_VECTOR_GRAPHICS) \
75 %D%/images/coreutils-size-map.eps \
76 %D%/environment-gdb.scm \
77 %D%/package-hello.scm \
78 %D%/package-hello.json
79
80 OS_CONFIG_EXAMPLES_TEXI = \
81 %D%/os-config-bare-bones.texi \
82 %D%/os-config-desktop.texi \
83 %D%/os-config-lightweight-desktop.texi
84
85 TRANSLATED_INFO = \
86 $(call lang_to_texinfo,$(MANUAL_LANGUAGES),guix) \
87 $(call lang_to_texinfo,$(MANUAL_LANGUAGES),contributing) \
88 $(call lang_to_texinfo,$(COOKBOOK_LANGUAGES),guix-cookbook)
89
90 # Bundle this file so that makeinfo finds it in out-of-source-tree builds.
91 BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
92 EXTRA_DIST += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
93 MAINTAINERCLEANFILES = $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
94
95 PO4A_PARAMS := -M UTF-8 -L UTF-8 #master and localized encoding
96 PO4A_PARAMS += -k 0 # produce an output even if the translation is not complete
97 PO4A_PARAMS += -f texinfo # texinfo format
98
99 # When a change to guix.texi occurs, it is not translated immediately.
100 # Because @pxref and @xref commands are reference to a section by name, they
101 # should be translated. If a modification adds a reference to a section, this
102 # reference is not translated, which means it references a section that does not
103 # exist.
104 # This command loops through the translated files looking for references. For
105 # each of these references, it tries to find the translation and replaces the
106 # reference name, even in untranslated strings.
107 # The last sed is a multiline sed because some references span multiple lines.
108 define xref_command
109 cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
110 tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
111 sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
112 if [ -n "$$e" ]; then \
113 line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
114 ((line++)) ;\
115 if [ "$$line" != "1" ]; then \
116 translation=$$(head -n "$$line" "$<" | tail -1 | grep msgstr | sed 's|msgstr "\([^"]*\)"|\1|') ;\
117 if [ "$$translation" != "" ]; then \
118 sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n ]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
119 fi ;\
120 fi ;\
121 fi ;\
122 done
123 endef
124
125 $(srcdir)/%D%/guix.%.texi: po/doc/guix-manual.%.po $(srcdir)/%D%/contributing.%.texi
126 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
127 -sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
128 -$(AM_V_POXREF)$(xref_command)
129 -mv "$@.tmp" "$@"
130
131 $(srcdir)/%D%/guix-cookbook.%.texi: po/doc/guix-cookbook.%.po
132 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix-cookbook.texi" -p "$<" -l "$@.tmp"
133 -sed -i "s|guix-cookbook\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
134 -$(AM_V_POXREF)$(xref_command)
135 -mv "$@.tmp" "$@"
136
137 $(srcdir)/%D%/contributing.%.texi: po/doc/guix-manual.%.po
138 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$<" -l "$@.tmp"
139 -$(AM_V_POXREF)$(xref_command)
140 -mv "$@.tmp" "$@"
141
142 %D%/os-config-%.texi: gnu/system/examples/%.tmpl
143 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
144 cp "$<" "$@"
145
146 infoimagedir = $(infodir)/images
147 dist_infoimage_DATA = \
148 $(DOT_FILES:%.dot=%.png) \
149 %D%/images/coreutils-size-map.png \
150 %D%/images/installer-network.png \
151 %D%/images/installer-partitions.png \
152 %D%/images/installer-resume.png
153
154 # Ask for warnings about cross-referenced manuals that are not listed in
155 # htmlxref.cnf.
156 AM_MAKEINFOHTMLFLAGS = --set-customization-variable CHECK_HTMLXREF=true
157
158 # Try hard to obtain an image size and aspect that's reasonable for inclusion
159 # in an Info or PDF document.
160 DOT_OPTIONS = \
161 -Gratio=.9 -Gnodesep=.005 -Granksep=.00005 \
162 -Nfontsize=9 -Nheight=.1 -Nwidth=.1
163
164 .dot.png:
165 $(AM_V_DOT)$(DOT) -Tpng $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
166 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
167
168 .dot.pdf:
169 $(AM_V_DOT)$(DOT) -Tpdf $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
170 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
171
172 .dot.eps:
173 $(AM_V_DOT)$(DOT) -Teps $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
174 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
175
176 .png.eps:
177 $(AM_V_GEN)convert "$<" "$@-tmp.eps"; \
178 mv "$@-tmp.eps" "$@"
179
180 # We cannot add new dependencies to `%D%/guix.pdf' & co. (info "(automake)
181 # Extending"). Using the `-local' rules is imperfect, because they may be
182 # triggered after the main rule. Oh, well.
183 pdf-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.pdf)
184 info-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.png)
185 ps-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.eps) \
186 $(top_srcdir)/%D%/images/coreutils-size-map.eps
187 dvi-local: ps-local
188
189 ## ----------- ##
190 ## Man pages. ##
191 ## ----------- ##
192
193 # The man pages are generated using GNU Help2man. In makefiles rules they
194 # depend not on the binary, but on the source files. This usage allows a
195 # manual page to be generated by the maintainer and included in the
196 # distribution without requiring the end-user to have 'help2man' installed.
197 # They are built in $(srcdir) like info manuals.
198
199 sub_commands_mans = \
200 $(srcdir)/%D%/guix-archive.1 \
201 $(srcdir)/%D%/guix-build.1 \
202 $(srcdir)/%D%/guix-challenge.1 \
203 $(srcdir)/%D%/guix-deploy.1 \
204 $(srcdir)/%D%/guix-download.1 \
205 $(srcdir)/%D%/guix-edit.1 \
206 $(srcdir)/%D%/guix-environment.1 \
207 $(srcdir)/%D%/guix-gc.1 \
208 $(srcdir)/%D%/guix-hash.1 \
209 $(srcdir)/%D%/guix-import.1 \
210 $(srcdir)/%D%/guix-lint.1 \
211 $(srcdir)/%D%/guix-package.1 \
212 $(srcdir)/%D%/guix-publish.1 \
213 $(srcdir)/%D%/guix-pull.1 \
214 $(srcdir)/%D%/guix-refresh.1 \
215 $(srcdir)/%D%/guix-size.1 \
216 $(srcdir)/%D%/guix-system.1 \
217 $(srcdir)/%D%/guix-time-machine.1 \
218 $(srcdir)/%D%/guix-weather.1
219
220 # Assume that cross-compiled commands cannot be executed.
221 if !CROSS_COMPILING
222
223 dist_man1_MANS = \
224 $(srcdir)/%D%/guix.1 \
225 $(sub_commands_mans)
226
227 endif
228
229 gen_man = \
230 LANGUAGE= $(top_builddir)/pre-inst-env $(HELP2MAN) \
231 $(HELP2MANFLAGS)
232
233 HELP2MANFLAGS = --source=GNU --info-page=$(PACKAGE_TARNAME)
234
235 $(srcdir)/%D%/guix.1: scripts/guix.in $(sub_commands_mans)
236 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
237
238 # The 'case' ensures the man pages are only generated if the corresponding
239 # source script (the first prerequisite) has been changed. The $(GOBJECTS)
240 # prerequisite is solely meant to force these docs to be made only after all
241 # Guile modules have been compiled.
242 $(srcdir)/%D%/guix-%.1: guix/scripts/%.scm $(GOBJECTS)
243 -@case '$?' in \
244 *$<*) $(AM_V_P) && set -x || echo " HELP2MAN $@"; \
245 $(gen_man) --output="$@" "guix $*";; \
246 *) : ;; \
247 esac
248
249 if BUILD_DAEMON
250 if !CROSS_COMPILING
251
252 dist_man1_MANS += $(srcdir)/%D%/guix-daemon.1
253
254 $(srcdir)/%D%/guix-daemon.1: guix-daemon$(EXEEXT)
255 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
256
257 endif
258 endif