Index: share/mk/doc.commands.mk =================================================================== --- share/mk/doc.commands.mk +++ share/mk/doc.commands.mk @@ -70,8 +70,13 @@ HTML2TXT?= ${PREFIX}/bin/links HTML2TXTOPTS?= -dump ${HTML2TXTFLAGS} +ITSTOOL?= ${PREFIX}/bin/itstool + JING?= ${PREFIX}/bin/jing +MSGFMT?= ${PREFIX}/bin/msgfmt +MSGMERGE?= ${PREFIX}/bin/msgmerge + XMLLINT?= ${PREFIX}/bin/xmllint XSLTPROC?= ${PREFIX}/bin/xsltproc Index: share/mk/doc.docbook.mk =================================================================== --- share/mk/doc.docbook.mk +++ share/mk/doc.docbook.mk @@ -269,6 +269,37 @@ ${SED} 's|@@URL_RELPREFIX@@|http://www.FreeBSD.org|g' < ${.TARGET} > ${DOC}.parsed.print.xml ${SED} -i '' -e 's|@@URL_RELPREFIX@@|../../../..|g' ${.TARGET} +# translation ------------------------------------------------------- + +# path to the English version to be translated +ENGDOCDIR= ${PWD:S/${LANGCODE}/en_US.ISO8859-1/} +# detect the document type from the path, and make it singular for use in the DTD +# just removing the trailing "s" is less safe than distinct replacements +SRCDOCTYPE= ${PWD:H:T:S/articles/article/:S/books/book/} +# DTD for inclusion in translated documents +FREEBSDDTD= + +# create a po file for translations +po ${DOC}.po: ${XML_INCLUDES} + ${MAKE} -C ${ENGDOCDIR} ${DOC}.parsed.xml + ${ITSTOOL} -k -o ${DOC}.po.tmp ${ENGDOCDIR}/${DOC}.parsed.xml + ( if [ -f "${DOC}.po" ]; then \ + echo "${DOC}.po exists, merging" ; \ + ${MSGMERGE} -o ${DOC}.po.new ${DOC}.po ${DOC}.po.tmp ; \ + ${MV} ${DOC}.po.new ${DOC}.po ; \ + ${RM} ${DOC}.po.tmp ; \ + else \ + ${MV} ${DOC}.po.tmp ${DOC}.po ; \ + fi ) + +# create the translated ${DOC}.xml from the .po file. +tran: ${DOC}.po + # abort if there is an existing ${DOC}.xml? + ${MSGFMT} -o ${DOC}.mo ${DOC}.po + ${ITSTOOL} -l ${LANGCODE:S/_.*//} -k -m ${DOC}.mo -o ${DOC}.xml ${ENGDOCDIR}/${DOC}.parsed.xml + # put the FreeBSD DTD back in after line 1 + ${SED} -i'' -e "1a \\${.newline}${FREEBSDDTD}${.newline}" ${DOC}.xml + # XHTML ------------------------------------------------------------- index.html: ${DOC}.parsed.xml ${LOCAL_IMAGES_LIB} ${LOCAL_IMAGES_PNG} \