License
Annotate for file src/UseClQti18n.cmake
2009-04-14 tobias 1 # Copyright 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
14:29:22 ' 2 #
' 3 # Permission is hereby granted, free of charge, to any person
' 4 # obtaining a copy of this software and associated documentation
' 5 # files (the "Software"), to deal in the Software without
' 6 # restriction, including without limitation the rights to use,
' 7 # copy, modify, merge, publish, distribute, sublicense, and/or sell
' 8 # copies of the Software, and to permit persons to whom the
' 9 # Software is furnished to do so, subject to the following
' 10 # conditions:
' 11 #
' 12 # The above copyright notice and this permission notice shall be
' 13 # included in all copies or substantial portions of the Software.
' 14 #
' 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
' 16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
' 17 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
' 18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
' 19 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
' 20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
' 21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
' 22 # OTHER DEALINGS IN THE SOFTWARE.
' 23 #
2009-04-05 tobias 24 # - Extract qt:tr strings from lisp source files and generate the Qt message files.
15:36:46 ' 25 #
' 26 # macro CL_GENERATE_QT_CATALOG(CATALOG_NAME LISP_SOURCE_FILES)
' 27 # Generates ${CATALOG_NAME}.pot, updates the ${CATALOG_NAME}_LANGS.po files and
' 28 # makes the ${CATALOG_NAME}_LANGS.qm files when the global target is build.
' 29 #
' 30
' 31 find_package(Gettext)
' 32 find_program(XGETTEXT_EXECUTABLE xgettext)
' 33
' 34 macro(CL_GENERATE_QT_CATALOG CATALOG_NAME LISP_SOURCE_FILES)
' 35 ## Run xgettext
' 36 ##
' 37 ## TODO: set charset
' 38 if(XGETTEXT_EXECUTABLE)
' 39 add_custom_command(OUTPUT ${CATALOG_NAME}.pot
' 40 COMMAND ${XGETTEXT_EXECUTABLE} -L lisp
' 41 -kqt:tr:1,2c
' 42 -kqt:tr:1
' 43 ${LISP_SOURCE_FILES} -o ${CATALOG_NAME}.pot
' 44 DEPENDS ${LISP_SOURCE_FILES})
' 45 add_custom_target(messages ALL DEPENDS ${CATALOG_NAME}.pot)
' 46 endif(XGETTEXT_EXECUTABLE)
' 47
' 48 ## Generate Qt .qm files from the .po files.
' 49 ##
' 50 ## based on:
' 51 ## http://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems#Extracting_and_merging_messages
' 52 if(GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGMERGE_EXECUTABLE)
' 53 file(GLOB PO_FILES ${CATALOG_NAME}*.po)
' 54 message ("PO ${PO_FILES}")
' 55
' 56 set(QM_FILES "")
' 57
' 58 foreach(_poFile ${PO_FILES})
' 59 get_filename_component(_poFileName ${_poFile} NAME)
' 60 string(REGEX REPLACE "^${CATALOG_NAME}_?" "" _langCode ${_poFileName} )
' 61 string(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} )
' 62
' 63 if( _langCode )
' 64 get_filename_component(_lang ${_poFile} NAME_WE)
' 65 set(_qmFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.qm)
' 66 add_custom_command(OUTPUT ${_qmFile}
' 67 COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE}
' 68 --quiet --update --backup=none
' 69 ${_poFileName}
' 70 ${CATALOG_NAME}.pot
' 71
' 72 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
' 73 --check --use-fuzzy --qt -o ${_qmFile} ${_poFile}
' 74
' 75 DEPENDS ${_poFile} ${CATALOG_NAME}.pot)
' 76 list(APPEND QM_FILES ${_qmFile})
' 77 endif( _langCode )
' 78
' 79 endforeach(_poFile ${PO_FILES})
' 80
' 81 add_custom_target(translations ALL
' 82 DEPENDS ${QM_FILES})
' 83
' 84 endif(GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGMERGE_EXECUTABLE)
' 85
' 86 endmacro(CL_GENERATE_QT_CATALOG)
' 87
' 88
' 89