summaryrefslogtreecommitdiffstats
path: root/tdescreensaver/kxsconfig/CMakeL10n.txt
blob: b7099c1bc800fe423388769931088a955a39000d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
##### verify required programs ##################

if( NOT DEFINED INTLTOOL_EXTRACT_EXECUTABLE )
  find_program( INTLTOOL_EXTRACT_EXECUTABLE
    NAMES intltool-extract
    HINTS "${TDE_PREFIX}/bin"
  )
  if( NOT INTLTOOL_EXTRACT_EXECUTABLE )
    tde_message_fatal( "intltool-extract is required but not found" )
  endif( )
endif( )


##### prepare xscreensavers data files ##########

message( STATUS "Prepare to extract strings from xscreensaver data files..." )

include( ${CMAKE_SOURCE_DIR}/FindXscreensaver.cmake )
string( REPLACE ":" ";" SEARCH_XSCREENSAVER_CONFIG_DIRS "${XSCREENSAVER_CONFIG_DIRS}" )

unset( _xsavers_l10n )
foreach( XSCREENSAVER_CONFIG_DIR IN LISTS SEARCH_XSCREENSAVER_CONFIG_DIRS )
  file( GLOB _xsaver_files
        RELATIVE "${XSCREENSAVER_CONFIG_DIR}"
        ${XSCREENSAVER_CONFIG_DIR}*.xml )
  list( SORT _xsaver_files )
  foreach( _xsaver_file ${_xsaver_files} )
    string( REGEX REPLACE "\\.xml\$" "" _xsaver_name "${_xsaver_file}" )
    if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_name}.desktop" )
        file( READ "${XSCREENSAVER_CONFIG_DIR}${_xsaver_file}" _xsaver_xml )
        string( REGEX REPLACE
            ".*<screensaver[^>]*_label=\"([^\"]*)\".*" "\\1"
            _xsaver_label "${_xsaver_xml}" )
        message( STATUS "Create desktop file for ${_xsaver_label} (${_xsaver_name})" )
        execute_process(
            COMMAND ldd "${XSCREENSAVER_DIR}/${_xsaver_name}"
            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
            OUTPUT_VARIABLE _xsaver_libs
        )
        set( NAME "${_xsaver_name}" )
        set( LABEL "${_xsaver_label}" )
        if( "${_xsaver_libs}" MATCHES "libGL" )
          set( GL1 "X-TDE-Category=OpenGL Screen Savers" )
          set( GL2 "X-TDE-Type=OpenGL" )
        else( )
          set( GL1 "" )
          set( GL2 "" )
        endif( )
        configure_file(
            ${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/xscreensaver.template
            ${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_name}.desktop
            @ONLY )
    endif( )

    execute_process(
        COMMAND ${INTLTOOL_EXTRACT_EXECUTABLE}
          --type=gettext/xml --srcdir ${XSCREENSAVER_CONFIG_DIR} ${_xsaver_file}
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers
        OUTPUT_VARIABLE _xsaver_output
    )
    file( RENAME
        "${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h"
        "${CMAKE_CURRENT_SOURCE_DIR}/ScreenSavers/${_xsaver_file}.h.tde_l10n" )
    list( APPEND _xsavers_l10n "ScreenSavers/${_xsaver_file}.h.tde_l10n" )
  endforeach( )
endforeach( )


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

tde_l10n_create_template(
    CATALOG "kxsconfig"
    SOURCES
        "."
        ${_xsavers_l10n}
    KEYWORDS
        N_
)