summaryrefslogtreecommitdiff
path: root/CMake/Translations.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake/Translations.cmake')
-rw-r--r--CMake/Translations.cmake46
1 files changed, 44 insertions, 2 deletions
diff --git a/CMake/Translations.cmake b/CMake/Translations.cmake
index 1b9781d69..6a9862005 100644
--- a/CMake/Translations.cmake
+++ b/CMake/Translations.cmake
@@ -13,6 +13,13 @@ function(apt_add_translation_domain)
set(abs_scripts "")
set(targets ${NLS_TARGETS})
set(domain ${NLS_DOMAIN})
+ set(xgettext_params
+ --add-comments
+ --foreign
+ --package-name=${PROJECT_NAME}
+ --package-version=${PACKAGE_VERSION}
+ --msgid-bugs-address=${PACKAGE_MAIL}
+ )
foreach(source ${NLS_SCRIPTS})
string(SUBSTRING ${source} 0 1 init_char)
string(COMPARE EQUAL ${init_char} "/" is_absolute)
@@ -50,19 +57,21 @@ function(apt_add_translation_domain)
set(sh_pot ${PROJECT_BINARY_DIR}/${domain}.sh.pot)
# Create the template for this specific sub-domain
add_custom_command (OUTPUT ${sh_pot}
- COMMAND xgettext --add-comments --foreign -L Shell
+ COMMAND xgettext ${xgettext_params} -L Shell
-o ${sh_pot} ${scripts}
DEPENDS ${abs_scripts}
+ VERBATIM
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endif()
add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/${domain}.c.pot
- COMMAND xgettext --add-comments --foreign -k_ -kN_
+ COMMAND xgettext ${xgettext_params} -k_ -kN_
--keyword=P_:1,2
-o ${PROJECT_BINARY_DIR}/${domain}.c.pot ${files}
DEPENDS ${abs_files}
+ VERBATIM
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
@@ -100,3 +109,36 @@ function(apt_add_translation_domain)
add_custom_target(nls-${domain} ALL DEPENDS ${mofiles})
endfunction()
+
+# Usage: apt_add_update_po(output domain [domain ...])
+function(apt_add_update_po)
+ set(options)
+ set(oneValueArgs TEMPLATE)
+ set(multiValueArgs DOMAINS)
+ cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot)
+ foreach(domain ${NLS_DOMAINS})
+ list(APPEND potfiles ${PROJECT_BINARY_DIR}/${domain}.pot)
+ endforeach()
+
+ get_filename_component(master_name ${output} NAME_WE)
+ add_custom_target(nls-${master_name}
+ COMMAND msgcomm --sort-by-file --add-location=file
+ --more-than=0 --output=${output}
+ ${potfiles}
+ DEPENDS ${potfiles})
+
+ file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po")
+ if (NOT TARGET update-po)
+ add_custom_target(update-po)
+ endif()
+ foreach(translation ${translations})
+ get_filename_component(langcode ${translation} NAME_WE)
+ add_custom_target(update-po-${langcode}
+ COMMAND msgmerge -q --update --backup=none ${translation} ${output}
+ DEPENDS nls-${master_name}
+ )
+ add_dependencies(update-po update-po-${langcode})
+ endforeach()
+ add_dependencies(update-po nls-${master_name})
+endfunction()