Skip to content
Snippets Groups Projects
Unverified Commit b9fe8fd6 authored by Julien Lepiller's avatar Julien Lepiller
Browse files

gnu: doc: Allow documentation to be translated.

* po/doc/contributing.pot: New file.
* po/doc/guix.pot: New file.
* po/doc/local.mk: New file.
* Makefile.am: Include it. Add gettext command. Add silent rules for po4a.
* configure.ac: Look for po4a-translate and po4a-updatepo.
* doc/local.mk: Add rules to generate translated texi files.
(TRANSLATED_INFO): New variable.
(BUILT_SOURCES, EXTRA_DIST, MAINTAINERCLEANFILES): Add it.
* .gitignore: Add generated files.
parent 9490c411
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,21 @@
/configure
/doc/*.1
/doc/.dirstamp
/doc/guix.*.aux
/doc/guix.*.cp
/doc/guix.*.cps
/doc/guix.*.fn
/doc/guix.*.fns
/doc/guix.*.html
/doc/guix.*.info
/doc/guix.*.info-[0-9]
/doc/guix.*.ky
/doc/guix.*.pg
/doc/guix.*.toc
/doc/guix.*.t2p
/doc/guix.*.tp
/doc/guix.*.vr
/doc/guix.*.vrs
/doc/guix.aux
/doc/guix.cp
/doc/guix.cps
......@@ -47,6 +62,7 @@
/doc/os-config-desktop.texi
/doc/stamp-vti
/doc/version.texi
/doc/version-*.texi
/etc/guix-daemon.cil
/etc/guix-daemon.conf
/etc/guix-daemon.service
......@@ -79,6 +95,7 @@
/nix/scripts/list-runtime-roots
/nix/scripts/offload
/nix/scripts/substitute
/po/doc/*.mo
/po/guix/*.gmo
/po/guix/*.insert-header
/po/guix/*.mo
......
......@@ -10,6 +10,7 @@
# Copyright © 2017 Jan Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
# Copyright © 2018 Nils Gillmann <ng0@n0.is>
# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
#
# This file is part of GNU Guix.
#
......@@ -26,6 +27,8 @@
# You should have received a copy of the GNU General Public License
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
MSGMERGE_UPDATE = @MSGMERGE@ --update
bin_SCRIPTS = scripts/guix
# Handle substitution of fully-expanded Autoconf variables.
......@@ -51,6 +54,7 @@ MODULES_NOT_COMPILED = \
guix/man-db.scm
include gnu/local.mk
include po/doc/local.mk
MODULES = \
guix/base16.scm \
......@@ -454,7 +458,7 @@ dist_fishcompletion_DATA = etc/completion/fish/guix.fish
# SELinux policy
dist_selinux_policy_DATA = etc/guix-daemon.cil
EXTRA_DIST = \
EXTRA_DIST += \
HACKING \
ROADMAP \
TODO \
......@@ -792,3 +796,7 @@ AM_V_DOT_0 = @echo " DOT " $@;
AM_V_HELP2MAN = $(AM_V_HELP2MAN_$(V))
AM_V_HELP2MAN_ = $(AM_V_HELP2MAN_$(AM_DEFAULT_VERBOSITY))
AM_V_HELP2MAN_0 = @echo " HELP2MAN" $@;
AM_V_PO4A = $(AM_V_PO4A_$(V))
AM_V_PO4A_ = $(AM_V_PO4A_$(AM_DEFAULT_VERBOSITY))
AM_V_PO4A_0 = @echo " PO4A" $@;
......@@ -263,6 +263,10 @@ AM_MISSING_PROG([DOT], [dot])
dnl Manual pages.
AM_MISSING_PROG([HELP2MAN], [help2man])
dnl Documentation translation.
AM_MISSING_PROG([PO4A_TRANSLATE], [po4a-translate])
AM_MISSING_PROG([PO4A_UPDATEPO], [po4a-updatepo])
dnl Emacs (optional), for 'etc/indent-package.el'.
AC_PATH_PROG([EMACS], [emacs], [/usr/bin/emacs])
AC_SUBST([EMACS])
......
......@@ -4,6 +4,7 @@
# Copyright © 2013 Andreas Enge <andreas@enge.fr>
# Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
# Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
#
# This file is part of GNU Guix.
#
......@@ -51,10 +52,51 @@ OS_CONFIG_EXAMPLES_TEXI = \
%D%/os-config-desktop.texi \
%D%/os-config-lightweight-desktop.texi
TRANSLATED_INFO =
# Bundle this file so that makeinfo finds it in out-of-source-tree builds.
BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI)
EXTRA_DIST += $(OS_CONFIG_EXAMPLES_TEXI)
MAINTAINERCLEANFILES = $(OS_CONFIG_EXAMPLES_TEXI)
BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
EXTRA_DIST += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
MAINTAINERCLEANFILES = $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
PO4A_PARAMS := -M UTF-8 -L UTF-8 #master and localized encoding
PO4A_PARAMS += -k 0 # produce an output even if the translation is not complete
PO4A_PARAMS += -f texinfo # texinfo format
# When a change to guix.texi occurs, it is not translated immediately.
# Because @pxref and @xref commands are reference to a section by name, they
# should be translated. If a modification adds a reference to a section, this
# reference is not translated, which means it references a section that does not
# exist.
# This command loops through the translated files looking for references. For
# each of these references, it tries to find the translation and replaces the
# reference name, even in untranslated strings.
# The last sed is a multiline sed because some references span multiple lines.
define xref_command
cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
((line++)) ;\
if [ "$$line" != "1" ]; then \
translation=$$(head -n $$line "$<" | tail -1 | grep msgstr | sed 's|msgstr "\(.*\)"|\1|') ;\
if [ "$$translation" != "" ]; then \
sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n ]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
fi ;\
fi ;\
done
endef
$(srcdir)/%D%/guix.%.texi: po/doc/guix.%.po $(srcdir)/%D%/contributing.%.texi
-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
-sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
-$(xref_command)
-mv "$@.tmp" "$@"
$(srcdir)/%D%/contributing.%.texi: po/doc/guix.%.po po/doc/contributing.%.po
-$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$(word 2,$^)" -l "$@.tmp"
-$(xref_command)
-mv "$@.tmp" "$@"
%D%/os-config-%.texi: gnu/system/examples/%.tmpl
$(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
......
This diff is collapsed.
This diff is collapsed.
# GNU Guix --- Functional package management for GNU
# Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
#
# This file is part of GNU Guix.
#
# GNU Guix is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GNU Guix is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST =
POT_OPTIONS = --package-name "guix" --package-version "$(VERSION)" \
--copyright-holder "Ludovic Courtès" \
--msgid-bugs-address "ludo@gnu.org"
$(srcdir)/po/doc/guix.%.po: $(srcdir)/po/doc/guix.pot
@lang=`echo $$(basename "$@") | sed -e 's|^guix.||' -e 's|.po$$||'` ;\
if test -f "$@"; then \
test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $@ $<"; \
cd $(srcdir) \
&& { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
'' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $@ $<;; \
*) \
$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $@ $<;; \
esac; \
}; \
touch "$@"; \
else \
echo "File $@ does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
exit 1; \
fi
$(srcdir)/po/doc/contributing.%.po: $(srcdir)/po/doc/contributing.pot
@lang=`echo $$(basename "$@") | sed -e 's|^contributing.||' -e 's|.po$$||'` ;\
if test -f "$@"; then \
test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $@ $<"; \
cd $(srcdir) \
&& { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
'' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $@ $<;; \
*) \
$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $@ $<;; \
esac; \
}; \
touch "$@"; \
else \
echo "File $@ does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
exit 1; \
fi
$(srcdir)/po/doc/contributing.pot-update: doc/contributing.texi
$(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<" \
-p "$$(echo $@ | sed 's|-update||')" $(POT_OPTIONS)
@touch "$$(echo $@ | sed 's|-update||')"
$(srcdir)/po/doc/guix.pot-update: doc/guix.texi
$(AM_V_PO4A)$(PO4A_UPDATEPO) -M UTF-8 -f texinfo -m "$<" \
-p "$$(echo $@ | sed 's|-update||')" $(POT_OPTIONS)
@touch "$$(echo $@ | sed 's|-update||')"
doc-pot-update:
$(MAKE) $(srcdir)/po/doc/guix.pot-update
$(MAKE) $(srcdir)/po/doc/contributing.pot-update
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment