Basic support for manpages in multiple languages
The patch changes the path where the manual pages are compiled, resulting in a tree structure that follows the man-db convention: the man pages of each language are stored in a subdirectory of the main man path. For example, the input file "$AWESOME_SRC/manpages/awesome.1.fr.txt" would be compiled as "$BUILD_DIR/manpages/fr/man1/awesome.1". The installation step just copies the resulting directory (in the example, "$BUILD_DIR/manpages/") into the global man path of the system, excluding the temporary files. The input .txt files for the translations are not added directly to AWE_MAN_FILES: instead, the new variable AWE_MAN_LANGS stores the language names and their input file names are generated automatically. The main reason of this modification is that it was more convenient for my testing purposes: this behaviour can be changed back with minor modifications to the code. This patch is supposed to be a first draft, after all, and it is far from being perfect, but I hope it is of help. Signed-off-by: Diego Moreda <diego.plan9@gmail.com> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e6a1f8bac9
commit
a189abe92e
|
@ -88,6 +88,7 @@ set(AWE_MAN_SRCS
|
||||||
${SOURCE_DIR}/manpages/awsetbg.1.txt
|
${SOURCE_DIR}/manpages/awsetbg.1.txt
|
||||||
${SOURCE_DIR}/manpages/awesome-client.1.txt
|
${SOURCE_DIR}/manpages/awesome-client.1.txt
|
||||||
${SOURCE_DIR}/manpages/awesomerc.5.txt)
|
${SOURCE_DIR}/manpages/awesomerc.5.txt)
|
||||||
|
set(AWE_MAN_LANGS fr)
|
||||||
|
|
||||||
add_executable(${PROJECT_AWE_NAME}
|
add_executable(${PROJECT_AWE_NAME}
|
||||||
${AWE_SRCS}
|
${AWE_SRCS}
|
||||||
|
@ -171,30 +172,59 @@ if(GENERATE_MANPAGES)
|
||||||
if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
|
if(NOT BUILD_DIR STREQUAL SOURCE_DIR)
|
||||||
file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
|
file(MAKE_DIRECTORY ${BUILD_DIR}/manpages)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# add the default translation to the list of languages
|
||||||
|
set(AWE_MAN_LANGS default ${AWE_MAN_LANGS})
|
||||||
|
|
||||||
|
foreach(lang ${AWE_MAN_LANGS})
|
||||||
|
|
||||||
foreach(txtfile ${AWE_MAN_SRCS})
|
foreach(txtfile ${AWE_MAN_SRCS})
|
||||||
string(REGEX REPLACE ".txt\$" ".xml" xmlfile ${txtfile})
|
# figure the base name of the file (ie "awesome.1")
|
||||||
string(REPLACE ${SOURCE_DIR}
|
GET_FILENAME_COMPONENT(tmpname ${txtfile} NAME)
|
||||||
${BUILD_DIR} xmlfile ${xmlfile})
|
string(REGEX REPLACE ".txt\$" "" basename ${tmpname})
|
||||||
string(REGEX REPLACE ".xml\$" ".gz" gzfile ${xmlfile})
|
|
||||||
string(REGEX REPLACE ".gz\$" "" manfile ${gzfile})
|
# figure the relative path of the file
|
||||||
|
GET_FILENAME_COMPONENT(tmppath ${txtfile} PATH)
|
||||||
|
string(REPLACE ${SOURCE_DIR}/ "" relpath ${tmppath})
|
||||||
|
|
||||||
|
# figure the manpage section to install to from filename
|
||||||
|
string(REGEX REPLACE "^.*\\.([0-9])$" "\\1" section ${basename})
|
||||||
|
|
||||||
|
# construct the language specific versions of the basename and path
|
||||||
|
if (lang STREQUAL default)
|
||||||
|
set(basename2 ${basename})
|
||||||
|
set(relpath2 ${relpath}/man${section})
|
||||||
|
else()
|
||||||
|
set(basename2 ${basename}.${lang})
|
||||||
|
set(relpath2 ${relpath}/${lang}/man${section})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# create the build directory (if it does not exist)
|
||||||
|
file(MAKE_DIRECTORY ${BUILD_DIR}/${relpath2})
|
||||||
|
|
||||||
|
# set the final filenames
|
||||||
|
set(txtfile ${SOURCE_DIR}/${relpath}/${basename2}.txt)
|
||||||
|
set(xmlfile ${BUILD_DIR}/${relpath2}/${basename}.xml)
|
||||||
|
set(gzfile ${BUILD_DIR}/${relpath2}/${basename}.gz)
|
||||||
|
set(manfile ${BUILD_DIR}/${relpath2}/${basename})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
|
COMMAND ${ASCIIDOC_EXECUTABLE} -d manpage -b docbook -o ${xmlfile} - < ${txtfile}
|
||||||
WORKING_DIRECTORY ${BUILD_DIR}/manpages
|
WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
|
||||||
OUTPUT ${xmlfile}
|
OUTPUT ${xmlfile}
|
||||||
DEPENDS ${txtfile}
|
DEPENDS ${txtfile}
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
|
COMMAND ${XMLTO_EXECUTABLE} man ${xmlfile}
|
||||||
OUTPUT ${manfile}
|
OUTPUT ${manfile}
|
||||||
WORKING_DIRECTORY ${BUILD_DIR}/manpages
|
WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
|
||||||
DEPENDS ${xmlfile})
|
DEPENDS ${xmlfile})
|
||||||
|
|
||||||
if(COMPRESS_MANPAGES)
|
if(COMPRESS_MANPAGES)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
|
COMMAND ${GZIP_EXECUTABLE} < ${manfile} > ${gzfile}
|
||||||
OUTPUT ${gzfile}
|
OUTPUT ${gzfile}
|
||||||
WORKING_DIRECTORY ${BUILD_DIR}/manpages
|
WORKING_DIRECTORY ${BUILD_DIR}/${relpath2}
|
||||||
DEPENDS ${manfile}
|
DEPENDS ${manfile}
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
|
@ -202,14 +232,8 @@ if(GENERATE_MANPAGES)
|
||||||
else()
|
else()
|
||||||
set(MAN_FILES ${MAN_FILES} ${manfile})
|
set(MAN_FILES ${MAN_FILES} ${manfile})
|
||||||
endif()
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# figure out in what section to install to from filename
|
|
||||||
string(REGEX REPLACE "^.*\\.([0-9])\\.gz\$" "\\1" section ${gzfile})
|
|
||||||
if(COMPRESS_MANPAGES)
|
|
||||||
set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${gzfile})
|
|
||||||
else()
|
|
||||||
set(AWE_MAN${section}_FILES ${AWE_MAN${section}_FILES} ${manfile})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
add_custom_target(man ALL DEPENDS ${MAN_FILES})
|
add_custom_target(man ALL DEPENDS ${MAN_FILES})
|
||||||
|
@ -305,8 +329,14 @@ install(DIRECTORY ${BUILD_DIR}/lib DESTINATION ${AWESOME_DATA_PATH}
|
||||||
install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
|
install(FILES ${AWE_CONF_FILE_DEFAULT} DESTINATION ${AWESOME_SYSCONFDIR}
|
||||||
RENAME ${AWE_CONF_FILE})
|
RENAME ${AWE_CONF_FILE})
|
||||||
if(GENERATE_MANPAGES)
|
if(GENERATE_MANPAGES)
|
||||||
install(FILES ${AWE_MAN1_FILES} DESTINATION ${AWESOME_MAN_PATH}/man1)
|
if(COMPRESS_MANPAGES)
|
||||||
install(FILES ${AWE_MAN5_FILES} DESTINATION ${AWESOME_MAN_PATH}/man5)
|
set(regex "\\.(xml|[0-9])$")
|
||||||
|
else()
|
||||||
|
set(regex "\\.(xml|gz)$")
|
||||||
|
endif()
|
||||||
|
MESSAGE( ${relpath} )
|
||||||
|
install(DIRECTORY ${BUILD_DIR}/${relpath}/ DESTINATION ${AWESOME_MAN_PATH}
|
||||||
|
REGEX ${regex} EXCLUDE )
|
||||||
endif()
|
endif()
|
||||||
install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
|
install(DIRECTORY ${AWE_ICON_DIR} DESTINATION ${AWESOME_DATA_PATH})
|
||||||
install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
|
install(DIRECTORY ${BUILD_DIR}/themes DESTINATION ${AWESOME_DATA_PATH}
|
||||||
|
|
Loading…
Reference in New Issue