Warning, /multimedia/kwave/cmake/KwaveL10N.cmake is written in an unsupported language. File is not indexed.

0001 #############################################################################
0002 ##    Kwave                - cmake/KwaveL10N.cmake l10n support
0003 ##                           -------------------
0004 ##    begin                : Sat Sep 13 2008
0005 ##    copyright            : (C) 2008 by Thomas Eschenbacher
0006 ##    email                : Thomas.Eschenbacher@gmx.de
0007 #############################################################################
0008 #
0009 #############################################################################
0010 #                                                                           #
0011 # Redistribution and use in source and binary forms, with or without        #
0012 # modification, are permitted provided that the following conditions        #
0013 # are met:                                                                  #
0014 #                                                                           #
0015 # 1. Redistributions of source code must retain the above copyright         #
0016 #    notice, this list of conditions and the following disclaimer.          #
0017 # 2. Redistributions in binary form must reproduce the above copyright      #
0018 #    notice, this list of conditions and the following disclaimer in the    #
0019 #    documentation and/or other materials provided with the distribution.   #
0020 #                                                                           #
0021 # For details see the accompanying cmake/COPYING-CMAKE-SCRIPTS file.        #
0022 #                                                                           #
0023 #############################################################################
0024 
0025 FIND_REQUIRED_PROGRAM(FIND_EXECUTABLE find)
0026 FIND_REQUIRED_PROGRAM(MSGCAT_EXECUTABLE msgcat)
0027 FIND_REQUIRED_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
0028 FIND_REQUIRED_PROGRAM(MSGMERGE_EXECUTABLE msgmerge)
0029 FIND_REQUIRED_PROGRAM(MSGFMT_EXECUTABLE msgfmt)
0030 
0031 SET(PO_SRC_DIR "${CMAKE_SOURCE_DIR}/po")
0032 SET(PO_BIN_DIR "${CMAKE_BINARY_DIR}/po")
0033 
0034 #############################################################################
0035 ### get environment variable LINGUAS, default to all languages            ###
0036 
0037 SET(LINGUAS "$ENV{LINGUAS}")
0038 STRING(REGEX REPLACE "[ \t]+" \; OUTPUT "${LINGUAS}")
0039 SEPARATE_ARGUMENTS(LINGUAS)
0040 IF ("${LINGUAS}" STREQUAL "")
0041     SET(LINGUAS "*")
0042 ENDIF ("${LINGUAS}" STREQUAL "")
0043 
0044 #############################################################################
0045 ### checks whether a language has been requested per configuration       ###
0046 
0047 MACRO(CHECK_LANG _lang _result)
0048     # take only languages that have been requested
0049     SET(${_result} TRUE)
0050     IF (NOT "${LINGUAS}" STREQUAL "*")
0051         LIST(FIND LINGUAS "${${_lang}}" _found)
0052         IF (_found LESS 0)
0053             SET(${_result} FALSE)
0054         ENDIF (_found LESS 0)
0055     ENDIF (NOT "${LINGUAS}" STREQUAL "*")
0056 ENDMACRO(CHECK_LANG _lang _result)
0057 
0058 #############################################################################
0059 ### find out which po files exist                                        ###
0060 
0061 FILE(GLOB _existing_po_files "${PO_SRC_DIR}/*.po")
0062 FOREACH(_po_file ${_existing_po_files})
0063     GET_FILENAME_COMPONENT(_lang "${_po_file}" NAME_WE)
0064 
0065     CHECK_LANG(_lang _take_it)
0066     IF (_take_it)
0067         LIST(APPEND KWAVE_BUILD_LINGUAS "${_lang}")
0068         LIST(APPEND _po_files "${_po_file}")
0069         MESSAGE(STATUS "Enabled GUI translation for ${_lang}")
0070 
0071         # handle generation and installation of the message catalog (gmo)
0072         SET(_gmo_file ${PO_BIN_DIR}/${_lang}.gmo)
0073 
0074         ADD_CUSTOM_COMMAND(
0075             OUTPUT ${_gmo_file}
0076             COMMAND ${CMAKE_COMMAND} -E make_directory ${PO_BIN_DIR}
0077             COMMAND ${MSGFMT_EXECUTABLE} -o ${_gmo_file} ${_po_file}
0078             DEPENDS ${_po_file}
0079         )
0080 
0081         INSTALL(
0082             FILES ${_gmo_file}
0083             DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES
0084             RENAME kwave.mo
0085         )
0086         SET(_gmo_files ${_gmo_files} ${_gmo_file})
0087 
0088     ENDIF (_take_it)
0089 ENDFOREACH(_po_file ${_existing_po_files})
0090 
0091 #############################################################################
0092 ### update the local copy of the translations with files from kde svn     ###
0093 
0094 ADD_CUSTOM_TARGET(update-translations
0095     COMMAND ${CMAKE_SOURCE_DIR}/bin/svn-update-l10n.sh "${CMAKE_SOURCE_DIR}"
0096 )
0097 
0098 #############################################################################
0099 ### processing of GUI translations if found                               ###
0100 
0101 IF (NOT "${KWAVE_BUILD_LINGUAS}" STREQUAL "")
0102 
0103     IF ("${LINGUAS}" STREQUAL "*")
0104         MESSAGE(STATUS "LINGUAS not set, building for all supported languages")
0105     ENDIF ("${LINGUAS}" STREQUAL "*")
0106 
0107     IF (_existing_po_files)
0108 
0109         # build target "package-messages"
0110         ADD_CUSTOM_TARGET(package-messages ALL DEPENDS ${_gmo_files} )
0111 
0112         SET_DIRECTORY_PROPERTIES(PROPERTIES
0113             ADDITIONAL_MAKE_CLEAN_FILES
0114             "${CMAKE_BINARY_DIR}/po"
0115         )
0116     ENDIF (_existing_po_files)
0117 
0118 ELSE (NOT "${KWAVE_BUILD_LINGUAS}" STREQUAL "")
0119 
0120     MESSAGE(STATUS "Found no suitable language to build for")
0121 
0122 ENDIF (NOT "${KWAVE_BUILD_LINGUAS}" STREQUAL "")
0123 
0124 #############################################################################
0125 ### show the progress of translations                                     ###
0126 
0127 ADD_CUSTOM_TARGET(msgstats
0128     COMMAND ${CMAKE_SOURCE_DIR}/bin/msgstats.pl ${CMAKE_SOURCE_DIR}
0129 )
0130 
0131 #############################################################################
0132 #############################################################################