+ add_custom_target(nls-${domain} ALL DEPENDS ${mofiles} nls-${domain}-template)
+endfunction()
+
+# Usage: apt_add_update_po(output domain [domain ...])
+function(apt_add_update_po)
+ set(options)
+ set(oneValueArgs TEMPLATE)
+ set(multiValueArgs DOMAINS EXCLUDE_LANGUAGES)
+ cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot)
+ foreach(domain ${NLS_DOMAINS})
+ list(APPEND potfiles ${CMAKE_CURRENT_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)
+ if ("${langcode}" IN_LIST NLS_EXCLUDE_LANGUAGES)
+ continue()
+ endif()
+ add_custom_target(update-po-${langcode}
+ COMMAND msgmerge -q --previous --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()
+
+function(apt_add_po_statistics excluded)
+ add_custom_target(statistics)
+ file(GLOB translations "${PROJECT_SOURCE_DIR}/po/*.po")
+ foreach(translation ${translations})
+ get_filename_component(langcode ${translation} NAME_WE)
+ if ("${langcode}" IN_LIST excluded)
+ add_custom_command(
+ TARGET statistics PRE_BUILD
+ COMMAND printf "%-6s " "${langcode}:"
+ COMMAND echo "ignored"
+ VERBATIM
+ )
+ continue()
+ endif()
+ add_custom_command(
+ TARGET statistics PRE_BUILD
+ COMMAND printf "%-6s " "${langcode}:"
+ COMMAND msgfmt --statistics -o /dev/null ${translation}
+ VERBATIM
+ )
+ endforeach()