Refactor qtutils.
[kaya.git] / translations / CMakeLists.txt
blobf24d12b49222e2ac5a1bd312aafe071a90c5e0cd
1 FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
2  
3 IF(NOT GETTEXT_MSGFMT_EXECUTABLE)
4         MESSAGE(
5 "------
6                  NOTE: msgfmt not found. Translations will *not* be installed
7 ------")
8 ELSE(NOT GETTEXT_MSGFMT_EXECUTABLE)
9  
10         SET(catalogname kaya)
12         ADD_CUSTOM_TARGET(translations ALL)
14         FILE(GLOB PO_FILES *.po)
16         FOREACH(_poFile ${PO_FILES})
17                 GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME)
18                 STRING(REGEX REPLACE "^${catalogname}_?" "" _langCode ${_poFileName} )
19                 STRING(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} )
21                 IF( _langCode )
22                         GET_FILENAME_COMPONENT(_lang ${_poFile} NAME_WE)
23                         SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
25                         ADD_CUSTOM_COMMAND(TARGET translations
26                                 COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_poFile}
27                                 DEPENDS ${_poFile})
28                         INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_langCode}/LC_MESSAGES/ RENAME ${catalogname}.mo)
29                 ENDIF( _langCode )
31         ENDFOREACH(_poFile ${PO_FILES})
33 ENDIF(NOT GETTEXT_MSGFMT_EXECUTABLE)