An Internationalized Software Project With Auto Tools | ||
---|---|---|
Prev | Adding HTML Help Documentation | Next |
# mkdir doc # touch doc/Makefile.am # touch doc/testproj.xsl # touch doc/testproj.xml # touch doc/test_chapter.xml # touch doc/apicture.png # touch doc/generated_files.mk |
Makefile.am |
SUBDIRS = src po doc ACLOCAL_AMFLAGS = -I m4 ... force-update-doc: cd doc && $(MAKE) $(AM_MAKEFLAGS) force-update-doc .PHONY: check-gettext update-po update-gmo force-update-gmo force-update-doc |
configure.ac |
AC_PREREQ(2.59) AC_INIT(testproj, 0.1, j.t.kirk@ncc-1701.ufp) AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AM_GNU_GETTEXT([external]) AC_ARG_WITH(helpdir,[AC_HELP_STRING([--with-helpdir=dir], [Installation directory of the html help [${datadir}/doc/testproj]])], [helpdir="$withval"],[helpdir='${datadir}/doc/${PACKAGE}']) AC_SUBST(helpdir) # Checks for programs. AC_PROG_CXX can_build_documentation=yes AC_PATH_PROG([xsltproc],[xsltproc]) if test -z "$xsltproc" ; then AC_MSG_WARN([xsltproc was not found. If you want to change and compile the documentation, \ please install libxslt (http://xmlsoft.org/XSLT/)]) can_build_documentation=no fi AC_CHECK_FILE([doc/docbook/htmlhelp/htmlhelp.xsl], , [AC_MSG_WARN([htmlhelp sytle sheet was not found. \ If you want to change and compile the documentation, please install docbook-xsl \ (http://docbook.sourceforge.net/) and create a symlink in doc]) ; can_build_documentation=no]) AC_MSG_CHECKING([whether documentation can be changed and compiled]) AC_MSG_RESULT($can_build_documentation) AC_SUBST(can_build_documentation) # Checks for libraries. # Checks for header files. # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_CONFIG_FILES([Makefile src/Makefile src/testmodule/Makefile po/Makefile.in m4/Makefile \ doc/Makefile]) AC_OUTPUT |
src/Makefile.am |
... localedir = $(datadir)/locale DEFS = -DLOCALEDIR=\"$(localedir)\" -DHELPDIR=\"$(helpdir)\" @DEFS@ |
src/main.cpp |
#include <stdio.h> #include <locale.h> #include "testmodule/testfunc.h" #include "i18n.h" const char * helpdir = HELPDIR; ... // multi plural test. Usefull, if the target language has other plural forming rules. printf(i18nP("You have won one point!\n", "You have won %d points!\n", n), n); // reference to english html help printf(i18n("\nHelp: %s/index.html\n"), helpdir); printf(i18n("Test chapter: %s/test_chapter.html\n"), helpdir); } |
doc/Makefile.am |
SUBDIRS = @AMDEP_TRUE@@am__include@ @am__quote@generated_files.mk@am__quote@ pictures = apicture.png source_tarball_files = $(PACKAGE).xsl $(PACKAGE).xml test_chapter.xml htmlhelpdir = $(helpdir) htmlhelp_created_files = $(PACKAGE).hhc $(PACKAGE).hhk $(PACKAGE).hhp $(TESTPROJ_DOCFILES) htmlhelp_DATA = $(pictures) $(TESTPROJ_DOCFILES) EXTRA_DIST = $(source_tarball_files) $(pictures) generated_files.mk $(htmlhelp_created_files) DISTCLEANFILES = Makefile check_can_build_documentation: @if test x$(can_build_documentation) != "xyes" ; then echo "Missing libxslt." \ "Rerun configure and check for 'checking whether documentation can be changed and compiled... yes'!" ; \ exit 1 ; fi |
doc/Makefile.am |
... generated_files_include: @echo -n "TESTPROJ_DOCFILES = "> $(srcdir)/generated_files.mk2 @find . -maxdepth 1 -type f -name "*.html" | sort | $(AWK) '{printf(" \\\n\t%s", $$0)}' \ >> $(srcdir)/generated_files.mk2 @if diff $(srcdir)/generated_files.mk $(srcdir)/generated_files.mk2 >/dev/null 2>&1 ; then \ echo "generated_files.mk is unchanged" ; \ rm -f $(srcdir)/generated_files.mk2 ; \ else \ mv $(srcdir)/generated_files.mk2 $(srcdir)/generated_files.mk ; \ fi all: $(htmlhelp_created_files) force-update-doc: doc-clean $(htmlhelp_created_files) $(htmlhelp_created_files): $(source_tarball_files) @ $(MAKE) check_can_build_documentation $(MAKE) doc-clean $(xsltproc) $(srcdir)/$(PACKAGE).xsl $(srcdir)/$(PACKAGE).xml @echo "creating generated_files.mk" $(MAKE) generated_files_include maintainer-clean: doc-clean maintainer-clean-recursive doc-clean: -rm -f *.hhp -rm -f *.html -rm -f *.hhk -rm -f *.hhc .PHONY: check_can_build_documentation generated_files_include force-update-doc doc-clean |
doc/testproj.xsl |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="docbook/htmlhelp/htmlhelp.xsl"/> <xsl:param name="htmlhelp.use.hhk" select="1"/> <xsl:param name="htmlhelp.button.next" select="1"/> <xsl:param name="htmlhelp.button.previous" select="1"/> <xsl:param name="htmlhelp.button.back" select="1"/> <xsl:param name="htmlhelp.button.forward" select="1"/> <xsl:param name="htmlhelp.hhc.show.root" select="0"/> <xsl:param name="htmlhelp.show.favorites" select="1"/> <xsl:param name="htmlhelp.show.advanced.search" select="1"/> <xsl:param name="htmlhelp.show.menu" select="1"/> <xsl:param name="htmlhelp.hhp" select="'testproj.hhp'"/> <xsl:param name="htmlhelp.hhc" select="'testproj.hhc'"/> <xsl:param name="htmlhelp.hhk" select="'testproj.hhk'"/> <xsl:param name="htmlhelp.chm" select="'testproj.chm'"/> <xsl:param name="use.id.as.filename" select="1"/> </xsl:stylesheet> |
ln -s /usr/local/share/xsl/docbook/ doc/docbook |
createFromCvs.freebsd |
... ln -s /usr/local/share/gettext/gettext.h src ln -s /usr/local/share/xsl/docbook/ doc/docbook |
createFromCvs.gentoo |
... ln -s /usr/share/gettext/gettext.h src ln -s /usr/share/sgml/docbook/xsl-stylesheets-1.68.1 doc/docbook |
doc/testproj.xml |
<?xml version="1.0"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ <!ENTITY test_chapter SYSTEM "test_chapter.xml"> <!ENTITY directions_right "right"> <!ENTITY results_right "right "> ]> <book lang="en"> <bookinfo> <legalnotice> <para> Legal notice ... </para> </legalnotice> <author> <firstname>J.T.</firstname> <surname>Kirk</surname> </author> <copyright> <year>2005</year> <year>2006</year> <holder>J.T. Kirk</holder> </copyright> </bookinfo> <title>testproj</title> <preface id="overview"><title>Preface to testproj</title> <para> <indexterm><primary>testproj</primary></indexterm> <indexterm><primary>Preface</primary></indexterm> This is the preface. It contains of a paragrapgh, a list and a link. This paragraph contains useless words only. Its mere purpose is to have some text in order to see the paragraphs end.</para> <para> A small list: <variablelist><itemizedlist> <listitem>list item 1</listitem> <listitem>list item 2</listitem> </itemizedlist></variablelist> </para> <para> Demonstration of amigous translations: <informaltable> <tgroup cols='2'> <tbody> <row> <entry>Possible directions</entry> <entry>Possible results</entry> </row> <row> <entry>&directions_right;</entry> <entry>&results_right;</entry> </row> <row> <entry>left</entry> <entry>wrong</entry> </row> </tbody> </tgroup> </informaltable> </para> <para> Link: <link linkend="test_chapter"> Jump to test chapter. </link> </para> </preface> &test_chapter; </book> |
doc/test_chapter.xml |
<chapter id="test_chapter"><title>Test Chapter</title> <para><indexterm><primary>Test chapter</primary></indexterm> This is the first and only chapter. It contains a note, a picture and a table. </para> <para> This paragraph contains a picture <mediaobject><imageobject><imagedata fileref="apicture.png" format="png"/> </imageobject></mediaobject> <emphasis>within</emphasis> the paragraph, which is surrounded by the text. <note>This is a small note</note> </para> <para> Finally a table with some xml tags: <informaltable> <tgroup cols='2'> <tbody> <row> <entry>xml tag</entry> <entry>result</entry> </row> <row> <entry><para>command</para></entry> <entry><para><command>command</command> </para></entry> </row> <row> <entry><para>replaceable</para></entry> <entry><para><replaceable>replaceable</replaceable> </para></entry> </row> <row> <entry><para>prompt</para></entry> <entry><para><prompt>prompt</prompt></para></entry> </row> </tbody> </tgroup> </informaltable> </para> </chapter> |
# gmake cd . && aclocal19 -I m4 cd . && automake19 --gnu cd . && autoconf259 /bin/sh ./config.status --recheck running /bin/sh ./configure --no-create --no-recursion ... checking for xsltproc... /usr/local/bin/xsltproc checking for doc/docbook/htmlhelp/htmlhelp.xsl... yes checking whether documentation can be changed and compiled... yes ... gmake[3]: Entering directory `/usr/home/he/develop/testproj/src' if g++ -DLOCALEDIR=\"/usr/local/share/locale\" -DHELPDIR=\"/usr/local/share/doc/testproj\" -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.cpp; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi ... Making all in doc gmake[2]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Nothing to be done for `all-am'. gmake[3]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake doc-clean gmake[3]: Entering directory `/usr/home/he/develop/testproj/doc' rm -f *.hhp rm -f *.html rm -f *.hhk rm -f *.hhc gmake[3]: Leaving directory `/usr/home/he/develop/testproj/doc' /usr/local/bin/xsltproc testproj.xsl testproj.xml Writing overview.html for preface(overview) Writing test_chapter.html for chapter(test_chapter) Writing index.html for book Writing testproj.hhp Writing testproj.hhc Writing testproj.hhk creating generated_files.mk gmake generated_files_include gmake[3]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[2]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[2]: Entering directory `/usr/home/he/develop/testproj' gmake[2]: Leaving directory `/usr/home/he/develop/testproj' gmake[1]: Leaving directory `/usr/home/he/develop/testproj' |
# cat doc/generated_files.mk TESTPROJ_DOCFILES = \ ./index.html \ ./overview.html \ ./test_chapter.html |
po/de.po |
... #: src/main.cpp:34 #, c-format msgid "" "\n" "Help: %s/index.html\n" msgstr "" "\n" "Hilfe: %s/index.html\n" #: src/main.cpp:35 #, c-format msgid "Test chapter: %s/test_chapter.html\n" msgstr "Test Kapitel: %s/test_chapter.html\n" ... |
# gmake update-gmo ... # gmake install ... Making install in doc gmake[1]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[2]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Nothing to be done for `install-exec-am'. test -z "/usr/local/share/doc/testproj" || /usr/local/bin/bash ../mkinstalldirs "/usr/local/share/doc/testproj" mkdir /usr/local/share/doc/testproj /usr/bin/install -c -m 644 'apicture.png' '/usr/local/share/doc/testproj/apicture.png' /usr/bin/install -c -m 644 './index.html' '/usr/local/share/doc/testproj/index.html' /usr/bin/install -c -m 644 './overview.html' '/usr/local/share/doc/testproj/overview.html' /usr/bin/install -c -m 644 './test_chapter.html' '/usr/local/share/doc/testproj/test_chapter.html' gmake[3]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[2]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[1]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[1]: Entering directory `/usr/home/he/develop/testproj' gmake[2]: Entering directory `/usr/home/he/develop/testproj' gmake[2]: Nothing to be done for `install-exec-am'. gmake[2]: Nothing to be done for `install-data-am'. gmake[2]: Leaving directory `/usr/home/he/develop/testproj' gmake[1]: Leaving directory `/usr/home/he/develop/testproj' |
# testproj Hello world! Press a key Possible directions: right, left Possible results: right, wrong Enter a number: 3 You have won 3 points! Help: /usr/local/share/doc/testproj/index.html Test chapter: /usr/local/share/doc/testproj/test_chapter.html |
# gmake uninstall ... Making uninstall in doc gmake[1]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[2]: Entering directory `/usr/home/he/develop/testproj/doc' rm -f '/usr/local/share/doc/testproj/apicture.png' rm -f '/usr/local/share/doc/testproj/index.html' rm -f '/usr/local/share/doc/testproj/overview.html' rm -f '/usr/local/share/doc/testproj/test_chapter.html' gmake[2]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[1]: Leaving directory `/usr/home/he/develop/testproj/doc' gmake[1]: Entering directory `/usr/home/he/develop/testproj' gmake[1]: Nothing to be done for `uninstall-am'. gmake[1]: Leaving directory `/usr/home/he/develop/testproj' # ./configure --help ... Optional Packages: ... --with-helpdir=dir Installation directory of the html help [${datadir}/doc/testproj] Some influential environment variables: ... # ./configure --with-helpdir=/usr/local/share/doc/a_test ... # gmake clean ... # gmake ... gmake[3]: Entering directory `/usr/home/he/develop/testproj/src' if g++ -DLOCALEDIR=\"/usr/local/share/locale\" -DHELPDIR=\"/usr/local/share/doc/a_test\" -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.cpp; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi ... # gmake install ... gmake[3]: Entering directory `/usr/home/he/develop/testproj/doc' gmake[3]: Nothing to be done for `install-exec-am'. test -z "/usr/local/share/doc/a_test" || /usr/local/bin/bash ../mkinstalldirs "/usr/local/share/doc/a_test" mkdir /usr/local/share/doc/a_test /usr/bin/install -c -m 644 'apicture.png' '/usr/local/share/doc/a_test/apicture.png' /usr/bin/install -c -m 644 './index.html' '/usr/local/share/doc/a_test/index.html' /usr/bin/install -c -m 644 './overview.html' '/usr/local/share/doc/a_test/overview.html' /usr/bin/install -c -m 644 './test_chapter.html' '/usr/local/share/doc/a_test/test_chapter.html' ... # testproj ... Help: /usr/local/share/doc/a_test/index.html Test chapter: /usr/local/share/doc/a_test/test_chapter.html |
# gmake uninstall clean ... # ./configure ... |
Prev | Home | Next |
Documentation Overview | Internationalization of the Documentation |