2017-10-12 16:13:48 +02:00
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
# This include file <doc.translate.mk> handles building and installing of
|
|
|
|
# DocBook documentation translations in the FreeBSD Documentation Project.
|
|
|
|
#
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Document-specific variables
|
|
|
|
# [...]
|
|
|
|
#
|
|
|
|
|
|
|
|
# translation -------------------------------------------------------
|
|
|
|
|
|
|
|
# Master English document
|
|
|
|
MASTERDOC_EN?= ${MASTERDOC:S/${LANGCODE}/en_US.ISO8859-1/}
|
|
|
|
TRAN_DIR?= ${MASTERDOC:H}
|
|
|
|
EN_DIR?= ${TRAN_DIR:S/${LANGCODE}/en_US.ISO8859-1/}
|
|
|
|
PO_LANG?= ${LANGCODE:C/\..*$//}
|
|
|
|
PO_CHARSET?= ${LANGCODE:tl:C/^.*\.//:S/^iso/iso-/:S/utf-8/UTF-8/}
|
|
|
|
CLEANFILES+= ${DOC}.translate.xml ${PO_LANG}.mo
|
|
|
|
|
|
|
|
PO_CATALOG_FILES= file://${EN_DIR}/catalog-cwd.xml \
|
|
|
|
file://${EN_DIR:H:H}/share/xml/catalog.xml \
|
|
|
|
file://${DOC_PREFIX}/share/xml/catalog.xml \
|
|
|
|
file://${LOCALBASE}/share/xml/catalog
|
|
|
|
.if defined(EXTRA_CATALOGS)
|
|
|
|
PO_CATALOG_FILES+= ${EXTRA_CATALOGS}
|
|
|
|
.endif
|
|
|
|
PO_XMLLINT= env XML_CATALOG_FILES="${PO_CATALOG_FILES}" ${PREFIX}/bin/xmllint
|
|
|
|
|
|
|
|
# fix settings in PO file
|
|
|
|
IDSTR1= $$Free
|
|
|
|
IDSTR2= BSD$$
|
|
|
|
POSET_CMD= ${SED} -i '' -e '1s,^,\#${IDSTR1}${IDSTR2}\${.newline},' \
|
|
|
|
-e 's,^\(\"Language-Team:.*\\n\"\),\1\${.newline}\"Language: ${PO_LANG}\\n\",' \
|
|
|
|
-e 's,^\"Content-Type: text/plain; charset=.*\\n,\"Content-Type: text/plain; charset=${PO_CHARSET}\\n,'
|
|
|
|
|
|
|
|
.if ${.TARGETS:Mpo} || ${.TARGETS:Mtran} || ${.TARGETS:M${DOC}.translate.xml}
|
|
|
|
|
|
|
|
MASTER_SRCS!= ${MAKE} -C ${EN_DIR} -V SRCS
|
|
|
|
|
|
|
|
${DOC}.translate.xml:
|
2017-10-12 16:38:11 +02:00
|
|
|
.if ${TRAN_DIR} == ${EN_DIR}
|
2018-02-02 17:55:24 +01:00
|
|
|
@${ECHO} "Please build PO file only in a non-English directory, ignored"
|
2017-10-12 16:38:11 +02:00
|
|
|
.else
|
2017-10-12 16:13:48 +02:00
|
|
|
# some SRCS files might need to be generated, make sure they exist
|
2018-02-02 17:55:24 +01:00
|
|
|
@${MAKE} -C ${EN_DIR} ${MASTER_SRCS} > /dev/null
|
2017-10-12 16:13:48 +02:00
|
|
|
# normalize the English original into a single file
|
2018-02-02 17:55:24 +01:00
|
|
|
@${PO_XMLLINT} --nonet --noent --valid --xinclude ${MASTERDOC_EN} > ${.TARGET}.tmp
|
2017-10-12 16:13:48 +02:00
|
|
|
# remove redundant namespace attributes
|
2018-02-02 17:55:24 +01:00
|
|
|
@${PO_XMLLINT} --nsclean ${.TARGET}.tmp > ${.TARGET}
|
|
|
|
@${RM} ${.TARGET}.tmp
|
|
|
|
@${MAKE} -C ${EN_DIR} clean > /dev/null
|
2017-10-12 16:38:11 +02:00
|
|
|
.endif
|
2017-10-12 16:13:48 +02:00
|
|
|
|
2017-10-12 16:38:11 +02:00
|
|
|
.if ${TRAN_DIR} == ${EN_DIR}
|
|
|
|
po:
|
|
|
|
.else
|
2017-10-12 16:13:48 +02:00
|
|
|
po: ${PO_LANG}.po
|
2017-10-12 16:38:11 +02:00
|
|
|
.endif
|
|
|
|
|
2017-10-12 16:13:48 +02:00
|
|
|
.PHONY: po
|
2017-10-12 16:38:11 +02:00
|
|
|
|
2017-10-12 16:13:48 +02:00
|
|
|
${PO_LANG}.po: ${DOC}.translate.xml
|
2018-02-02 17:55:24 +01:00
|
|
|
@${ITSTOOL} -o ${PO_LANG}.po.tmp ${DOC}.translate.xml
|
2017-10-12 16:57:29 +02:00
|
|
|
.if exists(${PO_LANG}.po)
|
2017-10-12 17:20:47 +02:00
|
|
|
@${ECHO} "${PO_LANG}.po exists, merging"
|
2018-02-02 17:55:24 +01:00
|
|
|
@${MSGMERGE} -o ${PO_LANG}.po.new ${PO_LANG}.po ${PO_LANG}.po.tmp
|
|
|
|
@${MSGATTRIB} --no-obsolete -o ${PO_LANG}.po.new ${PO_LANG}.po
|
|
|
|
@${MV} ${PO_LANG}.po.new ${PO_LANG}.po
|
|
|
|
@${RM} ${PO_LANG}.po.tmp
|
2017-10-12 16:57:29 +02:00
|
|
|
.else
|
2017-10-12 17:39:02 +02:00
|
|
|
@${ECHO} "${PO_LANG}.po created, please check and correct the settings in the header"
|
2018-02-02 17:55:24 +01:00
|
|
|
@${MV} ${PO_LANG}.po.tmp ${PO_LANG}.po
|
|
|
|
@${POSET_CMD} ${.TARGET}
|
2017-10-12 16:57:29 +02:00
|
|
|
.endif
|
2017-10-12 16:13:48 +02:00
|
|
|
|
|
|
|
${PO_LANG}.mo: ${PO_LANG}.po
|
2018-02-02 17:55:24 +01:00
|
|
|
@${MSGFMT} -o ${.TARGET} ${.ALLSRC}
|
2017-10-12 16:13:48 +02:00
|
|
|
|
|
|
|
tran ${DOC}.xml: ${DOC}.translate.xml ${PO_LANG}.mo
|
2017-10-12 16:57:50 +02:00
|
|
|
.if ${TRAN_DIR} == ${EN_DIR}
|
2018-02-02 17:55:24 +01:00
|
|
|
@${ECHO} "Please build translation only in a non-English directory, ignored"
|
2017-10-12 16:57:50 +02:00
|
|
|
.else
|
2018-02-02 17:55:24 +01:00
|
|
|
@${ITSTOOL} -l ${PO_LANG} -m ${PO_LANG}.mo -o ${DOC}.xml ${DOC}.translate.xml
|
2017-10-12 16:13:48 +02:00
|
|
|
.endif
|
2017-10-12 16:57:50 +02:00
|
|
|
.endif
|
2017-10-12 16:13:48 +02:00
|
|
|
|