include(FindGettext)
if (GETTEXT_FOUND)
    set(GETTEXT_PACKAGE tint2conf)
    file(GLOB POTFILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.po")
    string(REPLACE ".po" " " LANGUAGES ${POTFILES})
    message(STATUS "gettext found languages: ${LANGUAGES}")
    string(REPLACE " " ";" LANGUAGES ${LANGUAGES})
    if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.8")
        GETTEXT_CREATE_TRANSLATIONS("${CMAKE_CURRENT_SOURCE_DIR}/tint2conf.pot" ALL ${POTFILES})
    else()
        foreach(LANG ${LANGUAGES})
            GETTEXT_PROCESS_PO_FILES(${LANG} ALL PO_FILES ${LANG}.po)
            install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo"
                    DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES"
                    RENAME "${GETTEXT_PACKAGE}.mo")
            endforeach ()
    endif()
else ()
    message(STATUS "gettext not found")
endif ()
