press-release Makefile,1.1,1.2 fdp-pr.xsl,1.2,1.3

Tommy Reynolds (jtr) fedora-docs-commits at redhat.com
Fri Feb 10 00:43:10 UTC 2006


Author: jtr

Update of /cvs/docs/press-release
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2775

Modified Files:
	Makefile fdp-pr.xsl 
Log Message:
Added support for multiple translations by properly creating .POT and
.PO files.  The XML files for additional translations are
automatically derived from the source-language XML file and the
appropriate .PO file.



Index: Makefile
===================================================================
RCS file: /cvs/docs/press-release/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile	7 Feb 2006 15:04:49 -0000	1.1
+++ Makefile	10 Feb 2006 00:43:01 -0000	1.2
@@ -1,36 +1,106 @@
-XMLFILES=fdp-pr-en.xml
-PDFFILES=${XMLFILES:.xml=.pdf}
-TXTFILES=${XMLFILES:.xml=.txt}
-POFILES=${XMLFILES:.xml=.po}
-
+########################################################################
+# The ${DOC_BASE} symbol provides the basic name for this document.
+DOC_BASE=fdp-pr
+########################################################################
+# The ${LANG} symbol gives the locale for the original language for 
+# the document.
+LANG=en
+########################################################################
+# The ${OTHERS} symbol is a list of additional locales into which the
+# document is to be translated.
+# OTHERS=de es it no
+########################################################################
+# WARNING!  Make no changes below this line or you will void the
+# warranty ;-)
+########################################################################
+# Provide some utility macros
 XMLTO	=xmlto
 XMLTOFLAGS=-m params.xsl
-DTD	=fdp-pr.dtd
 XSL	=fdp-pr.xsl
-
 SED    =/bin/sed
-
+XML2POT	=xml2pot
+XML2PO	=xml2po
+PO2XML	=po2xml
+MSGMERGE=msgmerge
+MSGMERGEFLAGS=
+########################################################################
+# Define our own set of suffixes to streamline the process
 .SUFFIXES:
-.SUFFIXES:	.txt	.pdf	.po	.xml	.xsl	.dtd	.in
-
-%.pdf:	%.xml
-	${XMLTO} -x ${XSL} ${XMLTOFLAGS} pdf $< 
-
-%.po:	%.xml
-	xml2po -o $@ $<
-
-%.txt:	%.xml
-	${XMLTO} -x ${XSL} ${XMLTOFLAGS} txt $< 
-
-all:	${PDFFILES} ${TXTFILES} ${POFILES}
-
-${PDFFILES} ${TXTFILES}: ${XMLFILES} params.xsl
-
+.SUFFIXES:	.txt	.pdf	.po	.pot	.xml	.xsl	.dtd	.in
+########################################################################
+# Mark the proper virtual targets so that a "make -t all" does not create
+# an empty file called "all".
+.PHONY:	all clean distclean clobber pot
+.PHONY: $(foreach LOCALE,${OTHERS},xml-${LOCALE})
+.PHONY: $(foreach LOCALE,${OTHERS},po-${LOCALE})
+########################################################################
+# The default target "all"
+all::	${DOC_BASE}.pot
+all::	$(foreach LOCALE,${LANG} ${OTHERS},${DOC_BASE}-${LOCALE}.xml)
+all::	$(foreach LOCALE,${LANG} ${OTHERS},${DOC_BASE}-${LOCALE}.pdf)
+all::	$(foreach LOCALE,${LANG} ${OTHERS},${DOC_BASE}-${LOCALE}.txt)
+########################################################################
+# Compute the rules to transform our XML documents into both PDF and TXT
+# forms
+define	OUTPUT_template
+${DOC_BASE}-$(1).pdf::	${DOC_BASE}-$(1).xml params.xsl.in
+	LC_ALL=${1}.UTF-8 ${SED} -e "s|DATE|$$(date +'%x %X')|" 	\
+	       params.xsl.in >params.xsl
+	LC_ALL=${1}.UTF-8 ${XMLTO} -x ${XSL} ${XMLTOFLAGS} pdf 		\
+	       ${DOC_BASE}-$(1).xml
+${DOC_BASE}-$(1).txt::	${DOC_BASE}-$(1).xml params.xsl.in
+	LC_ALL=${1}.UTF-8 ${SED} -e "s|DATE|$$(date +'%x %X')|" 	\
+	       params.xsl.in >params.xsl
+	LC_ALL=${1}.UTF-8 ${XMLTO} -x ${XSL} ${XMLTOFLAGS} txt 		\
+	       ${DOC_BASE}-$(1).xml
+endef
+
+$(foreach LOCALE,${LANG} ${OTHERS},$(eval $(call OUTPUT_template,${LOCALE})))
+########################################################################
+# Always generate the current date.
 params.xsl: params.xsl.in
 	${SED} -e "s|DATE|$$(date +'%x %X')|" $< >$@.tmp && move-if-change $@.tmp $@
-
+########################################################################
+# The ${DOC_BASE}.pot target produces a new .POT file everytime the
+# original XML file is updated.
+${DOC_BASE}.pot: ${DOC_BASE}-${LANG}.xml
+	xml2pot $< >$@
+########################################################################
+# Compute the rules to create or update a language-specific .po file
+# any time the ${DOC_BASE}.pot file is updated.  We try to avoid losing
+# current .PO translations by calling msgmerge if a .po file already 
+# exists.
+define PO_template
+po-${1} ${1}.po:: ${DOC_BASE}.pot
+	@if [ ! -f ${1}.po ]; then					\
+		echo Creating pristine ${1}.po;				\
+		cp ${DOC_BASE}.pot ${1}.po;				\
+	else								\
+		echo Updating existing ${1}.po;				\
+		${MSGMERGE} ${MSGMERGEFLAGS} 				\
+			${1}.po $${DOC_BASE}.pot >${1}.po;		\
+	fi
+endef
+
+$(foreach LOCALE,${OTHERS},$(eval $(call PO_template,${LOCALE})))
+########################################################################
+# Compute the rules and targets to generate the translated XML files
+# given an updated .PO file and the source XML file.
+define NEWLANG_template
+xml-${1} ${DOC_BASE}-${1}.xml:: ${DOC_BASE}-${LANG}.xml ${1}.po
+	${PO2XML} ${DOC_BASE}-${LANG}.xml ${1}.po >${DOC_BASE}-${1}.xml
+endef
+
+$(foreach LOCALE,${OTHERS},$(eval $(call NEWLANG_template,${LOCALE})))
+########################################################################
+# Neatness counts
 clean:
+	${RM} $(foreach LOCALE,${OTHERS},${DOC_BASE}-${LOCALE}.xml)
 	${RM} params.xsl
 
 distclean clobber: clean
-	${RM} ${PDFFILES} ${TXTFILES} ${POFILES}
+	${RM} $(foreach LOCALE,${LANG} ${OTHERS},${DOC_BASE}-${LOCALE}.pdf)
+	${RM} $(foreach LOCALE,${LANG} ${OTHERS},${DOC_BASE}-${LOCALE}.txt)
+########################################################################
+# End of Makefile
+########################################################################


Index: fdp-pr.xsl
===================================================================
RCS file: /cvs/docs/press-release/fdp-pr.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fdp-pr.xsl	7 Feb 2006 17:30:59 -0000	1.2
+++ fdp-pr.xsl	10 Feb 2006 00:43:01 -0000	1.3
@@ -55,7 +55,9 @@
               <fo:table-row>
                 <fo:table-cell text-align="left">
                   <fo:block>
-                    <fo:page-number/>/<fo:page-number-citation ref-id="EOF"/>
+                    <fo:page-number/>
+                    <xsl:text>/</xsl:text>
+                    <fo:page-number-citation ref-id="EOF"/>
                   </fo:block>
                 </fo:table-cell>
                 <fo:table-cell text-align="right">




More information about the Fedora-docs-commits mailing list