Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F172406216
D2947.id6794.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D2947.id6794.diff
View Options
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
@@ -131,7 +131,7 @@
LOCAL_CSS_SHEET= ${CSS_SHEET:T}
.endif
-CLEANFILES+= ${DOC}.parsed.xml ${DOC}.parsed.print.xml
+CLEANFILES+= ${DOC}.parsed.xml ${DOC}.parsed.print.xml ${DOC}.translate.xml
.if ${FORMATS:R:Mhtml-split} && ${FORMATS:R:Mhtml}
XSLTPROCOPTS+= --param docformatnav "'1'"
@@ -269,6 +269,52 @@
${SED} 's|@@URL_RELPREFIX@@|http://www.FreeBSD.org|g' < ${.TARGET} > ${DOC}.parsed.print.xml
${SED} -i '' -e 's|@@URL_RELPREFIX@@|../../../..|g' ${.TARGET}
+# translation -------------------------------------------------------
+
+# choice of PO software, po4a or itstool
+POSOFT?= po4a
+POFILE?= ${LANGCODE:C/_.*$//}
+
+# create a po file for translations
+po ${POFILE}.po: ${XML_INCLUDES:S/${LANGCODE}/en_US.ISO8859-1/}
+ # create the normalized translation file
+ @${XMLLINT} --nonet --valid --xinclude \
+ ${MASTERDOC:S/${LANGCODE}/en_US.ISO8859-1/} > ${DOC}.translate.tmp
+ # remove redundant xmlns:xlink attributes
+ # ** this needs to be fixed to work with --nonet **
+ @${XMLLINT} --nocatalogs --nsclean ${DOC}.translate.tmp > ${DOC}.translate.xml 2>/dev/null
+ @${RM} ${DOC}.translate.tmp
+ # generate the PO file from the normalized file
+.if ${POSOFT:Mpo4a}
+ @${PO4AGETTEXTIZE} -p ${POFILE}.po.tmp -m ${DOC}.translate.xml -f docbook \
+ -M UTF-8 -L UTF-8 --copyright-holder 'not set'
+.elif ${POSOFT:Mitstool}
+ @${ITSTOOL} -k -o ${POFILE}.po.tmp ${DOC}.translate.xml
+.else
+.error "\"${POSOFT}\" not recognized, set POSOFT to po4a or itstool"
+.endif
+ # if a PO file is already present, merge it
+ # this needs thought, need to delete old translations
+ # that are no longer needed by the English document
+ @( 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 \
+ ${MV} ${POFILE}.po.tmp ${POFILE}.po ; \
+ fi )
+
+tran: ${POFILE}.po
+.if ${POSOFT:Mpo4a}
+ @${PO4ATRANSLATE} -p ${POFILE}.po -f docbook -m ${DOC}.translate.xml \
+ -M UTF-8 -L UTF-8 -l ${DOC}.xml -k 0
+.elif ${POSOFT:Mitstool}
+ @${ITSTOOL} -k -l ${LANGCODE:S/_.*//} -m ${POFILE}.mo -o ${DOC}.xml ${DOC}.translate.xml
+.else
+.error "\"${POSOFT}\" not recognized, set POSOFT to po4a or itstool"
+.endif
+
# XHTML -------------------------------------------------------------
index.html: ${DOC}.parsed.xml ${LOCAL_IMAGES_LIB} ${LOCAL_IMAGES_PNG} \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 19, 6:27 AM (2 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39204426
Default Alt Text
D2947.id6794.diff (3 KB)
Attached To
Mode
D2947: Doc toolchain PO translation support
Attached
Detach File
Event Timeline
Log In to Comment