summaryrefslogtreecommitdiffstats
path: root/modules/TDEL10n.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'modules/TDEL10n.cmake')
-rw-r--r--modules/TDEL10n.cmake78
1 files changed, 30 insertions, 48 deletions
diff --git a/modules/TDEL10n.cmake b/modules/TDEL10n.cmake
index 5c0db26..2faa466 100644
--- a/modules/TDEL10n.cmake
+++ b/modules/TDEL10n.cmake
@@ -54,16 +54,6 @@ if( NOT DEFINED MSGUNIQ_EXECUTABLE )
endif( )
endif( )
-if( NOT DEFINED MSGCAT_EXECUTABLE )
- find_program( MSGCAT_EXECUTABLE
- NAMES msgcat
- HINTS "${TDE_PREFIX}/bin"
- )
- if( "${MSGCAT_EXECUTABLE}" STREQUAL "MSGCAT_EXECUTABLE-NOTFOUND" )
- tde_message_fatal( "msgcat is required but not found" )
- endif( )
-endif( )
-
if( NOT DEFINED PO4A_GETTEXTIZE_EXECUTABLE )
find_program( PO4A_GETTEXTIZE_EXECUTABLE
NAMES po4a-gettextize
@@ -305,7 +295,7 @@ macro( tde_l10n_create_template )
if( ${_dest} MATCHES "[^/]$" )
set( _dest "${_dest}/" )
endif( )
- if( ${_dest} MATCHES "^[^/]" )
+ if( NOT IS_ABSOLUTE ${_dest} )
set( _dest "${CMAKE_CURRENT_SOURCE_DIR}/${_dest}" )
endif( )
@@ -555,12 +545,6 @@ macro( tde_l10n_create_template )
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _pot
)
-
- # set charset and encoding headers
- if( _pot )
- string( REPLACE "Content-Type: text/plain; charset=CHARSET" "Content-Type: text/plain; charset=UTF-8" _pot "${_pot}" )
- string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _pot "${_pot}" )
- endif( )
endif( )
# process desktop files
@@ -573,13 +557,8 @@ macro( tde_l10n_create_template )
endforeach( )
# create translation template for desktop files
- if( _pot )
- set( _withPotHeader "--omit-header" )
- else( )
- set( _withPotHeader "--foreign-user" )
- endif( )
execute_process(
- COMMAND ${XGETTEXT_EXECUTABLE} ${_withPotHeader}
+ COMMAND ${XGETTEXT_EXECUTABLE} --foreign-user
--from-code=UTF-8 -C -c -ki18n -o - ${_desktops}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _potDesktop
@@ -588,43 +567,34 @@ macro( tde_l10n_create_template )
# merge translation templates
if( _potDesktop )
if( _pot )
- file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp "${_pot}" )
- file( APPEND ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp "${_potDesktop}" )
- execute_process(
- COMMAND ${MSGUNIQ_EXECUTABLE} --use-first
- INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE _pot
- )
- file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp )
+ set( _pot "${_pot}\n${_potDesktop}" )
else( )
set( _pot "${_potDesktop}" )
-
- # set charset and encoding headers
- string( REPLACE "Content-Type: text/plain; charset=CHARSET" "Content-Type: text/plain; charset=UTF-8" _pot "${_pot}" )
- string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _pot "${_pot}" )
endif( )
endif( )
endif( )
- # merge additional pot files
+ # join additional pot files
if( _pots )
- file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp "${_pot}" )
- execute_process(
- COMMAND ${MSGCAT_EXECUTABLE} --use-first extracted-pot.tmp ${_pots}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE _pot
- )
- file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp )
-
- # set charset and encoding headers
- string( REPLACE "Content-Type: text/plain; charset=CHARSET" "Content-Type: text/plain; charset=UTF-8" _pot "${_pot}" )
- string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _pot "${_pot}" )
+ foreach( _extra_pot IN LISTS _pots )
+ file( READ ${_extra_pot} _extra_pot )
+ if( _extra_pot )
+ if( _pot )
+ set( _pot "${_pot}\n${_extra_pot}" )
+ else( )
+ set( _pot "${_extra_pot}" )
+ endif( )
+ endif( )
+ endforeach( )
endif( )
# finalize translation template
if( _pot )
+ # set charset and encoding headers
+ string( REPLACE "Content-Type: text/plain; charset=CHARSET" "Content-Type: text/plain; charset=UTF-8" _pot "${_pot}" )
+ string( REPLACE "Content-Transfer-Encoding: ENCODING" "Content-Transfer-Encoding: 8bit" _pot "${_pot}" )
+
# update references for resources to original files and line numbers
list( FIND _files "extracted-rc.tde_l10n" _extractedRC_index )
if( "${_extractedRC_index}" GREATER -1
@@ -650,6 +620,18 @@ macro( tde_l10n_create_template )
# update references for modified source files (".tde_l10n" extension)
string( REGEX REPLACE "\\.tde_l10n[0-9]*(:[0-9]+)" "\\1" _pot "${_pot}" )
+ # merge unique strings
+ string( REGEX REPLACE "\n\n(#[^\n]*\n)*msgid \"\"\nmsgstr \"\"\n(\"[^\n]*\n)*\n" "\n\n" _pot "${_pot}" )
+ file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp "${_pot}" )
+ execute_process(
+ COMMAND ${MSGUNIQ_EXECUTABLE}
+ INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE _pot
+ )
+ file( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/extracted-pot.tmp )
+ string( REGEX REPLACE "(^|\n)#.? #-#-#-#-# [^\n]* #-#-#-#-#\n" "\\1" _pot "${_pot}" )
+
# replace the references for _translatorinfo with instructions in the comment
string( REGEX REPLACE
"(^|\n)(#:[^\n]*) _translatorinfo:1($|[^\n]*)"