Page MenuHomeFreeBSD

D2947.id6876.diff
No OneTemporary

D2947.id6876.diff

Index: share/mk/doc.commands.mk
===================================================================
--- share/mk/doc.commands.mk
+++ share/mk/doc.commands.mk
@@ -70,8 +70,16 @@
HTML2TXT?= ${PREFIX}/bin/links
HTML2TXTOPTS?= -dump ${HTML2TXTFLAGS}
+ITSTOOL?= ${PREFIX}/bin/itstool
+
JING?= ${PREFIX}/bin/jing
+MSGFMT?= ${PREFIX}/bin/msgfmt
+MSGMERGE?= ${PREFIX}/bin/msgmerge
+
+PO4AGETTEXTIZE?= ${PREFIX}/bin/po4a-gettextize
+PO4ATRANSLATE?= ${PREFIX}/bin/po4a-translate
+
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,76 @@
${SED} 's|@@URL_RELPREFIX@@|http://www.FreeBSD.org|g' < ${.TARGET} > ${DOC}.parsed.print.xml
${SED} -i '' -e 's|@@URL_RELPREFIX@@|../../../..|g' ${.TARGET}
+# translation -------------------------------------------------------
+
+# define KEEPENTS to preserve entities in PO file
+
+# choice of PO software, po4a or itstool
+POSOFT?= po4a
+ENGDIR?= ${MASTERDOC:H:S/${LANGCODE}/en_US.ISO8859-1/}
+ENGSRCS?= ${ENGDIR}/${SRCS:S/${LANGCODE}/en_US.ISO8859-1/}
+# target PO file
+POFILE?= ${LANGCODE:C/_.*$//}
+
+# keep entities as-is, or expand them to text
+.if defined(KEEPENTS)
+NORMALIZE_MSG= "preserving entities"
+NORMALIZE_CMD= ${XMLLINT} --nonet --valid --xinclude ${MASTERDOC:S/${LANGCODE}/en_US.ISO8859-1/}
+.else
+NORMALIZE_MSG= "expanding entities"
+NORMALIZE_CMD= ${XMLLINT} --nonet --noent --valid --xinclude ${MASTERDOC:S/${LANGCODE}/en_US.ISO8859-1/}
+.endif
+
+# document type, typically "article" or "book"
+DOCTYPE= ${MASTERDOC:H:H:T:S/articles/article/:S/books/book/}
+
+# filter redundant attributes from tags so translators do not have to deal with them
+FILTER_CMD= ${SED} -i '' -e 's, xmlns=\"http://docbook.org/ns/docbook\",,g' \
+ -e 's, xmlns:xlink=\"http://www.w3.org/1999/xlink\",,g' \
+ -e 's,^<${DOCTYPE}.*version=\"5.0\",<${DOCTYPE} xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\",'
+
+# fix settings in PO file
+POSET_CMD= ${SED} -i '' -e 's,^\"Language: \\n,\"Language: ${LANGCODE:C/_.*$//}\\n,' \
+ -e 's,^\"Content-Type: text/plain; charset=CHARSET\\n,\"Content-Type: text/plain; charset=UTF-8\\n,'
+
+# use textproc/po4a or textproc/itstool for PO generation
+. if ${POSOFT:Mpo4a}
+PO_CMD= ${PO4AGETTEXTIZE} -p ${POFILE}.po.tmp -m ${DOC}.translate.xml -f docbook -M UTF-8 -L UTF-8 --copyright-holder 'not set'
+TRAN_CMD= ${PO4ATRANSLATE} -p ${POFILE}.po -f docbook -m ${DOC}.translate.xml -M UTF-8 -L UTF-8 -l ${DOC}.xml -k 0
+. elif ${POSOFT:Mitstool}
+PO_CMD= ${ITSTOOL} -k -o ${POFILE}.po.tmp ${DOC}.translate.xml
+TRAN_CMD= ${MSGFMT} -o ${POFILE}.mo ${POFILE}.po ; ${ITSTOOL} -k -l ${LANGCODE:S/_.*//} -m ${POFILE}.mo -o ${DOC}.xml ${DOC}.translate.xml
+. endif
+
+# create a po file for translations
+po ${POFILE}.po: ${ENGSRCS}
+ # create the normalized translation file
+ @${ECHO} ${NORMALIZE_MSG}
+ @${NORMALIZE_CMD} > ${DOC}.translate.xml
+ # filter redundant attributes
+ @${FILTER_CMD} ${DOC}.translate.xml
+ # create the PO file
+ @${PO_CMD}
+ # fix settings in PO file
+ @${POSET_CMD} ${POFILE}.po.tmp
+ # if PO file already exists, merge new version with it
+ @( if [ -f "${POFILE}.po" ]; then \
+ echo "${POFILE}.po exists, merging" ; \
+ ${MSGMERGE} -o ${POFILE}.po.new ${POFILE}.po ${POFILE}.po.tmp ;\
+ ${MV} ${POFILE}.po.new ${POFILE}.po ; \
+ ${RM} ${POFILE}.po.tmp ; \
+ else \
+ ${ECHO} "New PO file created." ; \
+ ${ECHO} "Please check and correct the settings in the header of ${POFILE}.po." ; \
+ ${MV} ${POFILE}.po.tmp ${POFILE}.po ; \
+ fi )
+
+tran: ${POFILE}.po
+ # generate the translated document from the PO file and ${DOC}.translate.xml
+ # ${DOC}.translate.xml might require some post-processing first,
+ # like for @@URL_RELPREFIX@@ if entities have been expanded
+ @${TRAN_CMD}
+
# XHTML -------------------------------------------------------------
index.html: ${DOC}.parsed.xml ${LOCAL_IMAGES_LIB} ${LOCAL_IMAGES_PNG} \

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 17, 7:55 PM (7 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40964040
Default Alt Text
D2947.id6876.diff (4 KB)

Event Timeline