summaryrefslogtreecommitdiffstats
path: root/modules/TDEL10n.cmake
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2019-01-09 17:21:00 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-01-09 17:21:21 +0100
commit6246f2b46a28c97b6e1946aead7faa48fb7ef3fc (patch)
treef358874d210db6222bbd7bb090503b716131c0a1 /modules/TDEL10n.cmake
parent99d63e82125c04e5ef35b012d1a43f81951dfc64 (diff)
downloadtde-cmake-6246f2b46a28c97b6e1946aead7faa48fb7ef3fc.tar.gz
tde-cmake-6246f2b46a28c97b6e1946aead7faa48fb7ef3fc.zip
Update TDEL10n module
+ Add ability to specify a template with strings that should not be extracted. + Fixed detection of required programs. Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'modules/TDEL10n.cmake')
-rw-r--r--modules/TDEL10n.cmake55
1 files changed, 48 insertions, 7 deletions
diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake
index c266132..1038df4 100644
--- a/modules/TDEL10n.cmake
+++ b/modules/TDEL10n.cmake
@@ -1,6 +1,6 @@
#################################################
#
-# (C) 2018 Slávek Banko
+# (C) 2018-2019 Slávek Banko
# slavek (DOT) banko (AT) axis.cz
#
# Improvements and feedback are welcome
@@ -29,7 +29,7 @@ if( NOT DEFINED KDE_XGETTEXT_EXECUTABLE )
NAMES kde-xgettext
HINTS "${TDE_PREFIX}/bin"
)
- if( NOT KDE_XGETTEXT_EXECUTABLE )
+ if( "${KDE_XGETTEXT_EXECUTABLE}" STREQUAL "KDE_XGETTEXT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "kde-xgettext is required but not found" )
endif( )
endif( )
@@ -39,7 +39,7 @@ if( NOT DEFINED XGETTEXT_EXECUTABLE )
NAMES xgettext
HINTS "${TDE_PREFIX}/bin"
)
- if( NOT XGETTEXT_EXECUTABLE )
+ if( "${XGETTEXT_EXECUTABLE}" STREQUAL "XGETTEXT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "xgettext is required but not found" )
endif( )
execute_process(
@@ -58,7 +58,7 @@ if( NOT DEFINED MSGUNIQ_EXECUTABLE )
NAMES msguniq
HINTS "${TDE_PREFIX}/bin"
)
- if( NOT MSGUNIQ_EXECUTABLE )
+ if( "${MSGUNIQ_EXECUTABLE}" STREQUAL "MSGUNIQ_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "msguniq is required but not found" )
endif( )
endif( )
@@ -68,7 +68,7 @@ if( NOT DEFINED MSGCAT_EXECUTABLE )
NAMES msgcat
HINTS "${TDE_PREFIX}/bin"
)
- if( NOT MSGCAT_EXECUTABLE )
+ if( "${MSGCAT_EXECUTABLE}" STREQUAL "MSGCAT_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "msgcat is required but not found" )
endif( )
endif( )
@@ -78,7 +78,7 @@ if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
NAMES po4a-gettextize
HINTS "${TDE_PREFIX}/bin"
)
- if( NOT PO4A_GETTEXTIZE_EXECUTABLE )
+ if( "${PO4A_GETTEXTIZE_EXECUTABLE}" STREQUAL "PO4A_GETTEXTIZE_EXECUTABLE-NOTFOUND" )
tde_message_fatal( "po4a-gettextize is required but not found" )
endif( )
execute_process(
@@ -92,6 +92,22 @@ if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
endif( )
endif( )
+if( NOT DEFINED TDE_COMMON_TEXTS_POT )
+ get_filename_component( TDE_SOURCE_BASE "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE )
+ while( (NOT EXISTS "${TDE_SOURCE_BASE}/tdelibs"
+ OR NOT IS_DIRECTORY "${TDE_SOURCE_BASE}/tdelibs" )
+ AND NOT "${TDE_SOURCE_BASE}" STREQUAL "/" )
+ get_filename_component( TDE_SOURCE_BASE "${TDE_SOURCE_BASE}" PATH )
+ endwhile( )
+ find_file( TDE_COMMON_TEXTS_POT
+ NAMES tde.pot
+ HINTS "${TDE_SOURCE_BASE}/tdelibs" "${TDE_PREFIX}/include" "${TDE_PREFIX}/include/tde"
+ )
+ if( "${TDE_COMMON_TEXTS_POT}" STREQUAL "TDE_COMMON_TEXTS_POT-NOTFOUND" )
+ tde_message_fatal( "translation template with common texts not found" )
+ endif( )
+endif( )
+
#################################################
#####
@@ -142,6 +158,7 @@ endfunction( )
##### [EXCLUDES regex [regex]]
##### [KEYWORDS keyword [keyword]]
##### [ATTRIBUTES attrib_spec [attrib_spec]]
+##### [X-POT common_texts.pot]
##### [DESTINATION directory]
##### )
#####
@@ -163,6 +180,9 @@ endfunction( )
##### Use "-" if is needed to disable default keywords.
##### ATTRIBUTES determines files and specification for extractattr:
##### source_spec:element,attribute[,context][[:element,attribute[,context]]...]
+##### X-POT entries from common_texts.pot are not extracted
+##### By default, "tde.pot" is searched for and used.
+##### Use "-" to skip this.
##### DESTINATION determines directory to save translation template.
##### The destination directory is determined as follows:
##### a) Directory is specified as an argument.
@@ -189,6 +209,7 @@ macro( tde_l10n_create_template )
unset( _keywords_add )
unset( _comment )
unset( _attributes )
+ unset( _exclude_pot )
unset( _pot )
unset( _directive )
set( _var _catalog )
@@ -246,6 +267,13 @@ macro( tde_l10n_create_template )
set( _directive 1 )
endif( )
+ # found directive "X-POT"
+ if( "+${_arg}" STREQUAL "+X-POT" )
+ unset( _exclude_pot )
+ set( _var _exclude_pot )
+ set( _directive 1 )
+ endif( )
+
# collect data
if( _directive )
unset( _directive )
@@ -340,6 +368,19 @@ macro( tde_l10n_create_template )
tde_message_fatal( "no source files found" )
endif( )
+ # prepare x-pot
+ if( NOT _exclude_pot )
+ set( _exclude_pot "${TDE_COMMON_TEXTS_POT}" )
+ endif( )
+ if( "${_exclude_pot}" STREQUAL "-" )
+ unset( _exclude_pot )
+ else( )
+ if( ${_exclude_pot} MATCHES "^[^/]" )
+ set( _exclude_pot "${CMAKE_CURRENT_SOURCE_DIR}/${_exclude_pot}" )
+ endif( )
+ set( _exclude_pot "-x${_exclude_pot}" )
+ endif( )
+
# prepare comment
if( NOT "${_comment}" STREQUAL "" )
if( "${_comment}" STREQUAL "-" OR "${_comment}" STREQUAL "all" )
@@ -497,7 +538,7 @@ macro( tde_l10n_create_template )
if( _files )
execute_process(
COMMAND ${KDE_XGETTEXT_EXECUTABLE} --foreign-user -C
- ${_comment} ${_keywords_c} -o - ${_files}
+ ${_comment} ${_keywords_c} ${_exclude_pot} -o - ${_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _pot
)