# Copyright 2009 Tobias Rautenkranz # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitation the rights to use, # copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following # conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # # - Extract qt:tr strings from lisp source files and generate the Qt message files. # # macro CL_GENERATE_QT_CATALOG(CATALOG_NAME LISP_SOURCE_FILES) # Generates ${CATALOG_NAME}.pot, updates the ${CATALOG_NAME}_LANGS.po files and # makes the ${CATALOG_NAME}_LANGS.qm files when the global target is build. # find_package(Gettext) find_program(XGETTEXT_EXECUTABLE xgettext) macro(CL_GENERATE_QT_CATALOG CATALOG_NAME LISP_SOURCE_FILES) ## Run xgettext ## ## TODO: set charset if(XGETTEXT_EXECUTABLE) add_custom_command(OUTPUT ${CATALOG_NAME}.pot COMMAND ${XGETTEXT_EXECUTABLE} -L lisp -kqt:tr:1,2c -kqt:tr:1 ${LISP_SOURCE_FILES} -o ${CATALOG_NAME}.pot DEPENDS ${LISP_SOURCE_FILES}) add_custom_target(messages ALL DEPENDS ${CATALOG_NAME}.pot) endif(XGETTEXT_EXECUTABLE) ## Generate Qt .qm files from the .po files. ## ## based on: ## http://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems#Extracting_and_merging_messages if(GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGMERGE_EXECUTABLE) file(GLOB PO_FILES ${CATALOG_NAME}*.po) message ("PO ${PO_FILES}") set(QM_FILES "") foreach(_poFile ${PO_FILES}) get_filename_component(_poFileName ${_poFile} NAME) string(REGEX REPLACE "^${CATALOG_NAME}_?" "" _langCode ${_poFileName} ) string(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} ) if( _langCode ) get_filename_component(_lang ${_poFile} NAME_WE) set(_qmFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.qm) add_custom_command(OUTPUT ${_qmFile} COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none ${_poFileName} ${CATALOG_NAME}.pot COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --use-fuzzy --qt -o ${_qmFile} ${_poFile} DEPENDS ${_poFile} ${CATALOG_NAME}.pot) list(APPEND QM_FILES ${_qmFile}) endif( _langCode ) endforeach(_poFile ${PO_FILES}) add_custom_target(translations ALL DEPENDS ${QM_FILES}) endif(GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGMERGE_EXECUTABLE) endmacro(CL_GENERATE_QT_CATALOG)