#################################################
#
#  (C) 2019 Slávek Banko
#  slavek.banko (AT) axis.cz
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 2.8 )


##### include our cmake modules #################

set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEL10n )


##### set directory for POT files ###############

set( POT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../tde-i18n/template/messages/tdevelop" )


##### create translation templates ##############

tde_l10n_create_template(
    CATALOG "tdevelop"
    EXCLUDES
        "^kdevdesigner/src/"
        "^parts/tipofday/"
)

tde_l10n_auto_add_subdirectories()

file(
    GLOB_RECURSE _desktops
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*.desktop
)
list( SORT _desktops )

file(
    GLOB_RECURSE _protocols
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*.protocol
)
list( SORT _protocols )

file(
    GLOB_RECURSE _directories
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*.directory
)
list( SORT _directories )

file(
    GLOB_RECURSE _plugins
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*.plugin
)
list( SORT _plugins )

file(
    GLOB_RECURSE _profiles
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*profile.config
)
list( SORT _profiles )

file(
    GLOB_RECURSE _template_names
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/*.kdevtemplate
)
unset( _templates )
foreach( _template_name IN LISTS _template_names )
    string( REGEX REPLACE "\\.kdevtemplate$" "" _template_base ${_template_name} )
    if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_template_base}" AND
        NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_template_base}" )
        list( APPEND _templates "${_template_base}" )
    endif()
    list( APPEND _templates "${_template_name}" )
endforeach()
list( SORT _templates )

file(
    GLOB_RECURSE _wizards
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/parts/appwizard/imports/*
)
foreach( _wizard_name IN LISTS _wizards )
    if( _wizard_name MATCHES "/(CMakeLists\\.txt|CMakeL10n\\.txt|Makefile\\.am)$" OR
        _wizard_name MATCHES "\\.[kt]develop" OR
        _wizard_name MATCHES "\\.tde_l10n$" OR
        _wizard_name MATCHES "/\\." )
        list( REMOVE_ITEM _wizards ${_wizard_name} )
    endif()
endforeach()
list( SORT _wizards )

tde_l10n_create_template(
    CATALOG "desktop_files/tdevelop-desktops/"
    SOURCES_DESKTOP
        ${_desktops}
        ${_protocols}
        ${_directories}
        ${_plugins}
        ${_profiles}
        ${_templates}
        ${_wizards}
    KEYWORDS
        Category
    DESTINATION "${CMAKE_SOURCE_DIR}/translations"
)

tde_l10n_create_template(
    CATALOG "desktop_files/tdevelop-eventsrc/"
    SOURCES *eventsrc
    DESTINATION "${CMAKE_SOURCE_DIR}/translations"
)
