2017-02-01 21:48:46 -06:00
|
|
|
ADD_SUBDIRECTORY(glossary)
|
2015-12-07 11:17:08 -06:00
|
|
|
|
|
|
|
# Set of available languages.
|
2016-01-20 10:46:01 -06:00
|
|
|
SET (TP_LINGUAS az ca cs da eu fa ja nl rw sk sr sv tr uk zh_CN)
|
2015-12-07 11:17:08 -06:00
|
|
|
# already marked as external at TP:
|
2016-01-20 10:46:01 -06:00
|
|
|
SET (GC_LINGUAS ar bg de el en_GB es fi fr gu he hi hu it kn ko lt lv mr nb ne pl pt pt_BR ro ru ta te ur vi zh_TW)
|
2015-12-07 11:17:08 -06:00
|
|
|
# not marked or no TP team:
|
|
|
|
SET (NEW_LINGUAS as brx doi es_NI kok kok@latin ks mai mni mni@bengali)
|
|
|
|
|
|
|
|
SET (ALL_LINGUAS ${TP_LINGUAS} ${GC_LINGUAS} ${NEW_LINGUAS})
|
|
|
|
|
|
|
|
SET (CATALOGS "")
|
|
|
|
SET (BUILD_CATALOGS "")
|
2016-01-13 10:45:29 -06:00
|
|
|
|
|
|
|
SET(CMAKE_COMMAND_TMP "")
|
|
|
|
IF (${CMAKE_VERSION} VERSION_GREATER 3.1)
|
|
|
|
SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
|
|
|
|
ENDIF()
|
|
|
|
|
2017-02-01 21:48:46 -06:00
|
|
|
SET(po_SOURCES "")
|
|
|
|
FOREACH(lingua ${ALL_LINGUAS})
|
|
|
|
LIST(APPEND po_SOURCES ${lingua}.po)
|
|
|
|
ENDFOREACH()
|
|
|
|
|
2017-07-04 20:36:35 -05:00
|
|
|
SET_LOCAL_DIST(po_DIST_local ${po_SOURCES} CMakeLists.txt ChangeLog Makevars
|
|
|
|
POTFILES.ignore POTFILES.in POTFILES.skip README check-po.cmake)
|
2017-02-01 21:48:46 -06:00
|
|
|
SET(po_DIST ${po_DIST_local} ${po_glossary_DIST} PARENT_SCOPE)
|
|
|
|
|
2015-12-07 11:17:08 -06:00
|
|
|
FOREACH(lingua ${ALL_LINGUAS})
|
|
|
|
SET(_OUTPUT_FILE ${lingua}.gmo)
|
|
|
|
LIST(APPEND CATALOGS ${_OUTPUT_FILE})
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${_OUTPUT_FILE}
|
2016-01-13 10:45:29 -06:00
|
|
|
COMMAND ${CMAKE_COMMAND_TMP} ${MSGFMT} -o ${_OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${lingua}.po
|
2015-12-07 11:17:08 -06:00
|
|
|
)
|
2017-07-04 20:36:35 -05:00
|
|
|
SET(_BUILD_FILE_DIR ${DATADIR_BUILD}/locale/${lingua}/LC_MESSAGES)
|
2017-02-01 21:48:46 -06:00
|
|
|
MAKE_DIRECTORY(${_BUILD_FILE_DIR})
|
|
|
|
SET(_BUILD_FILE ${_BUILD_FILE_DIR}/gnucash.gmo)
|
|
|
|
LIST(APPEND BUILD_CATALOGS ${_BUILD_FILE})
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${_BUILD_FILE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${lingua}.gmo ${_BUILD_FILE}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_OUTPUT_FILE}
|
|
|
|
#APPEND
|
2015-12-07 11:17:08 -06:00
|
|
|
)
|
|
|
|
ENDFOREACH(lingua)
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(po-gmo ALL DEPENDS ${CATALOGS})
|
2017-02-01 21:48:46 -06:00
|
|
|
ADD_CUSTOM_TARGET(po-gmo-build ALL DEPENDS ${BUILD_CATALOGS})
|
2015-12-07 11:17:08 -06:00
|
|
|
|
|
|
|
|
|
|
|
FOREACH(lingua ${ALL_LINGUAS})
|
|
|
|
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lingua}.gmo RENAME gnucash.mo DESTINATION share/locale/${lingua}/LC_MESSAGES)
|
2016-01-20 10:46:01 -06:00
|
|
|
ENDFOREACH(lingua)
|
2017-02-01 21:48:46 -06:00
|
|
|
|
|
|
|
FUNCTION(READ_FILE_REMOVING_COMMENTS OUTPUT PATH)
|
|
|
|
SET(RESULT "")
|
|
|
|
FILE(STRINGS "${PATH}" LINES_IN)
|
|
|
|
FOREACH(line ${LINES_IN})
|
|
|
|
STRING(REGEX REPLACE "#.*" "" line2 ${line})
|
|
|
|
LIST(APPEND RESULT ${line2})
|
|
|
|
ENDFOREACH()
|
|
|
|
SET(${OUTPUT} ${RESULT} PARENT_SCOPE)
|
|
|
|
ENDFUNCTION()
|
|
|
|
|
|
|
|
|
|
|
|
FUNCTION(MAKE_GNUCASH_POTFILES)
|
|
|
|
|
|
|
|
SET(IGNORE_PATTERNS "gw-" "test" "experimental" "python-bindings" "swig-.*\\.c")
|
2017-07-04 20:36:35 -05:00
|
|
|
|
2017-02-01 21:48:46 -06:00
|
|
|
# Create a list of candidate translation files
|
|
|
|
FILE(GLOB_RECURSE FILES_IN RELATIVE ${CMAKE_SOURCE_DIR}
|
2017-07-04 20:36:35 -05:00
|
|
|
${CMAKE_SOURCE_DIR}/*.c ${CMAKE_SOURCE_DIR}/*.cpp ${CMAKE_SOURCE_DIR}/*.glade ${CMAKE_SOURCE_DIR}/*.desktop.in
|
2017-02-01 21:48:46 -06:00
|
|
|
${CMAKE_SOURCE_DIR}/*.keys.in ${CMAKE_SOURCE_DIR}/*.gschema.xml.in.in ${CMAKE_SOURCE_DIR}/*.scm)
|
|
|
|
|
|
|
|
# Only consider files in the src/ directory. Also check against list of ignore patterns
|
|
|
|
SET(FILES "")
|
|
|
|
FOREACH(path ${FILES_IN})
|
|
|
|
STRING(REGEX MATCH "^src" IS_SRC ${path})
|
|
|
|
IF (IS_SRC)
|
|
|
|
SET(IS_IGNORED FALSE)
|
|
|
|
FOREACH(pattern ${IGNORE_PATTERNS})
|
|
|
|
STRING(REGEX MATCH ${pattern} YES_IGNORE ${path})
|
|
|
|
IF (YES_IGNORE)
|
|
|
|
SET(IS_IGNORED TRUE)
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH(pattern)
|
|
|
|
IF (NOT IS_IGNORED)
|
|
|
|
LIST(APPEND FILES ${path})
|
|
|
|
ENDIF(NOT IS_IGNORED)
|
2017-07-04 20:36:35 -05:00
|
|
|
ENDIF(IS_SRC)
|
2017-02-01 21:48:46 -06:00
|
|
|
ENDFOREACH(path)
|
|
|
|
|
|
|
|
# Read in list of paths to skip from POTFILES.{skip,ignore}
|
|
|
|
READ_FILE_REMOVING_COMMENTS(SKIP_LINES POTFILES.skip)
|
|
|
|
READ_FILE_REMOVING_COMMENTS(IGNORE_LINES POTFILES.ignore)
|
|
|
|
|
|
|
|
# Remove the paths that are skipped or ignored
|
|
|
|
FOREACH(path ${SKIP_LINES} ${IGNORE_LINES})
|
|
|
|
list(REMOVE_ITEM FILES ${path})
|
|
|
|
ENDFOREACH()
|
|
|
|
|
2017-07-04 20:36:35 -05:00
|
|
|
|
2017-02-01 21:48:46 -06:00
|
|
|
# CMake sorting different from UNIX sorting. Sort the files
|
|
|
|
# here so it is easier for me to compare to the autotools
|
|
|
|
# generated POTFILES.in
|
|
|
|
STRING(REPLACE ";" "\n" SORT_IN "${FILES}")
|
|
|
|
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in.in "${SORT_IN}")
|
|
|
|
|
|
|
|
EXECUTE_PROCESS(COMMAND "sort"
|
|
|
|
INPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in.in
|
|
|
|
OUTPUT_VARIABLE POTFILES_IN
|
|
|
|
)
|
|
|
|
STRING(REPLACE "\n" ";" POTFILES "${POTFILES_IN}")
|
|
|
|
|
|
|
|
# Write out the final list.
|
|
|
|
# intltool-update insists that this file be in the source directory. :-(
|
|
|
|
SET(POTFILES_IN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in)
|
2017-07-04 20:36:35 -05:00
|
|
|
FILE(WRITE ${POTFILES_IN_PATH} "# This is a list of files which contain tranlatable strings.
|
2017-02-01 21:48:46 -06:00
|
|
|
# This file was generated by ../make-gnucash-potfiles.
|
|
|
|
")
|
|
|
|
|
|
|
|
FOREACH(path ${POTFILES})
|
|
|
|
STRING(REGEX MATCH gschema.xml.in.in IS_GSCHEMA ${path})
|
|
|
|
IF(IS_GSCHEMA AND NOT WIN32)
|
|
|
|
# Force parse type for gsettings files
|
|
|
|
SET(path "[type: gettext/gsettings]${path}")
|
|
|
|
ENDIF()
|
|
|
|
FILE(APPEND ${POTFILES_IN_PATH} "${path}\n")
|
|
|
|
ENDFOREACH()
|
|
|
|
|
|
|
|
# These are also added, even though they are outside of src/
|
|
|
|
FILE(APPEND ${POTFILES_IN_PATH} "src/gnome/gnucash.appdata.xml.in
|
|
|
|
src/gnome/gnucash.desktop.in.in
|
|
|
|
src/libqof/qof/qofbookslots.h
|
|
|
|
doc/tip_of_the_day.list.in
|
2017-07-04 20:36:35 -05:00
|
|
|
lib/goffice/go-charmap-sel.c
|
|
|
|
lib/goffice/go-optionmenu.c
|
2017-02-01 21:48:46 -06:00
|
|
|
")
|
|
|
|
|
|
|
|
ENDFUNCTION()
|
|
|
|
|
|
|
|
find_program(INTLTOOL_UPDATE NAMES intltool-update)
|
|
|
|
IF (${INTLTOOL_UPDATE} STREQUAL "INTLTOOL_UPDATE-NOTFOUND")
|
|
|
|
MESSAGE(FATAL_ERROR "Can't find the 'intltool-update' program.")
|
|
|
|
ENDIF ()
|
|
|
|
|
|
|
|
IF(BUILDING_FROM_VCS)
|
|
|
|
|
|
|
|
MAKE_GNUCASH_POTFILES()
|
|
|
|
|
|
|
|
find_program(INTLTOOL_EXTRACT NAMES intltool-extract)
|
|
|
|
find_program(XGETTEXT xgettext)
|
|
|
|
|
|
|
|
IF (${INTLTOOL_EXTRACT} STREQUAL "INTLTOOL_EXTRACT-NOTFOUND")
|
|
|
|
MESSAGE(FATAL_ERROR "Can't find the 'intltool-extract' program.")
|
|
|
|
ENDIF ()
|
|
|
|
|
|
|
|
IF (${XGETTEXT} STREQUAL "XGETTEXT-NOTFOUND")
|
|
|
|
MESSAGE(FATAL_ERROR "Can't find the 'xgettext' program.")
|
|
|
|
ENDIF ()
|
|
|
|
|
|
|
|
IF (${CMAKE_VERSION} VERSION_GREATER 3.1 AND NOT WIN32)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${CMAKE_COMMAND_TMP} INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT} XGETTEXT=${XGETTEXT} ${INTLTOOL_UPDATE} --gettext-package ${PACKAGE} --pot
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
RESULT_VARIABLE GNUCASH_POT_RESULT
|
|
|
|
)
|
|
|
|
IF(NOT ${GNUCASH_POT_RESULT} STREQUAL "0")
|
|
|
|
MESSAGE(FATAL_ERROR "Error when creating gnucash.pot: ${GNUCASH_POT_RESULT}")
|
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
|
|
|
CONFIGURE_FILE(make-gnucash-pot.sh.in make-gnucash-pot.sh)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${SHELL} ${CMAKE_CURRENT_BINARY_DIR}/make-gnucash-pot.sh
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
RESULT_VARIABLE GNUCASH_POT_RESULT_SHELL
|
|
|
|
)
|
|
|
|
IF(NOT ${GNUCASH_POT_RESULT_SHELL} STREQUAL "0")
|
|
|
|
MESSAGE(FATAL_ERROR "Error when creating gnucash.pot from shell script: ${GNUCASH_POT_RESULT_SHELL}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2017-07-04 20:36:35 -05:00
|
|
|
IF (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot)
|
2017-02-01 21:48:46 -06:00
|
|
|
MESSAGE(FATAL_ERROR "POT file '${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot' was not successfully created.")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy gnucash.pot ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
EXECUTE_PROCESS(
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove gnucash.pot
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(check-po
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D INTLTOOL_UPDATE=${INTLTOOL_UPDATE}
|
|
|
|
-D PO_DIR=${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
-P check-po.cmake
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2017-07-04 20:36:35 -05:00
|
|
|
)
|