]> git.saurik.com Git - apt.git/commitdiff
CMake: Translations: Allow excluding languages from translation
authorJulian Andres Klode <jak@debian.org>
Tue, 9 Aug 2016 16:14:41 +0000 (18:14 +0200)
committerJulian Andres Klode <jak@debian.org>
Wed, 10 Aug 2016 14:11:21 +0000 (16:11 +0200)
This seems to be needed for the hebrew translations.

Gbp-Dch: ignore

CMake/Translations.cmake
po/CMakeLists.txt

index 584c5c5afe0831837c8ed6df6d833279d0cdd92b..9880e68c79d4a18e56eb9cfe420cc74ec430655a 100644 (file)
@@ -4,7 +4,7 @@
 function(apt_add_translation_domain)
     set(options)
     set(oneValueArgs DOMAIN)
 function(apt_add_translation_domain)
     set(options)
     set(oneValueArgs DOMAIN)
-    set(multiValueArgs TARGETS SCRIPTS)
+    set(multiValueArgs TARGETS SCRIPTS EXCLUDE_LANGUAGES)
     cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
     # Build the list of source files of the target
     set(files "")
     cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
     # Build the list of source files of the target
     set(files "")
@@ -106,6 +106,9 @@ function(apt_add_translation_domain)
     list(SORT translations)
     foreach(file ${translations})
         get_filename_component(langcode ${file} NAME_WE)
     list(SORT translations)
     foreach(file ${translations})
         get_filename_component(langcode ${file} NAME_WE)
+        if ("${langcode}" IN_LIST NLS_EXCLUDE_LANGUAGES)
+            continue()
+        endif()
         set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES)
         file(MAKE_DIRECTORY ${outdir})
         # Command to merge and compile the messages. As explained in the custom
         set(outdir ${PROJECT_BINARY_DIR}/locale/${langcode}/LC_MESSAGES)
         file(MAKE_DIRECTORY ${outdir})
         # Command to merge and compile the messages. As explained in the custom
@@ -131,7 +134,7 @@ endfunction()
 function(apt_add_update_po)
     set(options)
     set(oneValueArgs TEMPLATE)
 function(apt_add_update_po)
     set(options)
     set(oneValueArgs TEMPLATE)
-    set(multiValueArgs DOMAINS)
+    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})
     cmake_parse_arguments(NLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
     set(output ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_TEMPLATE}.pot)
     foreach(domain ${NLS_DOMAINS})
@@ -151,6 +154,9 @@ function(apt_add_update_po)
     endif()
     foreach(translation ${translations})
             get_filename_component(langcode ${translation} NAME_WE)
     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 --update --backup=none ${translation} ${output}
                 DEPENDS nls-${master_name}
             add_custom_target(update-po-${langcode}
                 COMMAND msgmerge -q --update --backup=none ${translation} ${output}
                 DEPENDS nls-${master_name}
@@ -160,14 +166,23 @@ function(apt_add_update_po)
     add_dependencies(update-po nls-${master_name})
 endfunction()
 
     add_dependencies(update-po nls-${master_name})
 endfunction()
 
-function(apt_add_po_statistics)
+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)
     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
             add_custom_command(
                 TARGET statistics PRE_BUILD
-                COMMAND printf "%-7s" "${langcode}:"
+                COMMAND printf "%-6s " "${langcode}:"
                 COMMAND msgfmt --statistics -o /dev/null ${translation}
                 VERBATIM
             )
                 COMMAND msgfmt --statistics -o /dev/null ${translation}
                 VERBATIM
             )
index 92ff39867ae0bb39c18717004fff1555501d18a1..174cc5d41f2eb181db59d63bdab2b65835fd4782 100644 (file)
@@ -1,6 +1,11 @@
+set(languages_excluded
+    he  ## disabled by translator request #313283
+)
+
 apt_add_translation_domain(
     DOMAIN libapt-pkg${APT_PKG_MAJOR}
     TARGETS apt-pkg
 apt_add_translation_domain(
     DOMAIN libapt-pkg${APT_PKG_MAJOR}
     TARGETS apt-pkg
+    EXCLUDE_LANGUAGES ${languages_excluded}
 )
 
 apt_add_translation_domain(
 )
 
 apt_add_translation_domain(
@@ -10,6 +15,7 @@ apt_add_translation_domain(
             # Methods
             file copy store gpgv cdrom http https ftp rred rsh mirror
     SCRIPTS ../dselect/install ../dselect/update
             # Methods
             file copy store gpgv cdrom http https ftp rred rsh mirror
     SCRIPTS ../dselect/install ../dselect/update
+    EXCLUDE_LANGUAGES ${languages_excluded}
 )
 
 apt_add_translation_domain(
 )
 
 apt_add_translation_domain(
@@ -20,11 +26,13 @@ apt_add_translation_domain(
             apt-dump-solver
             apt-internal-planner
             apt-ftparchive
             apt-dump-solver
             apt-internal-planner
             apt-ftparchive
+    EXCLUDE_LANGUAGES ${languages_excluded}
 )
 
 apt_add_translation_domain(
     DOMAIN libapt-inst${APT_INST_MAJOR}
     TARGETS apt-inst
 )
 
 apt_add_translation_domain(
     DOMAIN libapt-inst${APT_INST_MAJOR}
     TARGETS apt-inst
+    EXCLUDE_LANGUAGES ${languages_excluded}
 )
 
 apt_add_update_po(
 )
 
 apt_add_update_po(
@@ -35,6 +43,8 @@ apt_add_update_po(
         libapt-inst${APT_INST_MAJOR}
         apt
         apt-utils
         libapt-inst${APT_INST_MAJOR}
         apt
         apt-utils
+    EXCLUDE_LANGUAGES
+        ${languages_excluded}
 )
 
 )
 
-apt_add_po_statistics()
+apt_add_po_statistics("${languages_excluded}")