[rkward-cvs] SF.net SVN: rkward:[4062] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Thu Dec 1 19:03:16 UTC 2011
Revision: 4062
http://rkward.svn.sourceforge.net/rkward/?rev=4062&view=rev
Author: tfry
Date: 2011-12-01 19:03:15 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
Do not install extremely incomplete translations
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/po/CMakeLists.txt
Added Paths:
-----------
trunk/rkward/po/compile_po.cmake
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2011-11-30 08:46:16 UTC (rev 4061)
+++ trunk/rkward/ChangeLog 2011-12-01 19:03:15 UTC (rev 4062)
@@ -1,3 +1,4 @@
+- Only install translations which are at least 80% complete (not counting strings in plugins, which are not yet translatable)
- When asking for workspace file to open, use appropriate file filter
- When configured to ask for workspace to open on startup, don't prompt to save, first
- Fixed: potential crash when clicking "Select all updates" in the package installation dialog
Modified: trunk/rkward/po/CMakeLists.txt
===================================================================
--- trunk/rkward/po/CMakeLists.txt 2011-11-30 08:46:16 UTC (rev 4061)
+++ trunk/rkward/po/CMakeLists.txt 2011-12-01 19:03:15 UTC (rev 4062)
@@ -7,17 +7,25 @@
------")
ELSE(NOT GETTEXT_MSGFMT_EXECUTABLE)
- ADD_CUSTOM_TARGET(translations ALL)
-
FILE(GLOB PO_FILES *.po)
-
+
FOREACH(_poFile ${PO_FILES})
GET_FILENAME_COMPONENT(_lang ${_poFile} NAME_WE)
SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
- ADD_CUSTOM_COMMAND(TARGET translations
- COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_poFile}
+
+ # making the gmo be re-built, when the po changes, but not every time is surprsingly difficult
+ # (since the gmo file is only built for translations which are complete enough)
+ SET(_stampFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.stamp)
+ ADD_CUSTOM_COMMAND(OUTPUT ${_stampFile}
+ COMMAND ${CMAKE_COMMAND} "-D_poFile=${_poFile}" "-D_gmoFile=${_gmoFile}" "-DGETTEXT_MSGFMT_EXECUTABLE=${GETTEXT_MSGFMT_EXECUTABLE}" -P ${CMAKE_CURRENT_SOURCE_DIR}/compile_po.cmake
+ COMMAND ${CMAKE_COMMAND} -E touch ${_stampFile}
+ COMMENT "Generating translation for language '${_lang}'"
DEPENDS ${_poFile})
- INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES/ RENAME rkward.mo)
+ LIST(APPEND active_translations ${_stampFile})
+
+ INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES/ RENAME rkward.mo OPTIONAL)
ENDFOREACH(_poFile ${PO_FILES})
+ ADD_CUSTOM_TARGET(translations ALL DEPENDS ${active_translations})
+
ENDIF(NOT GETTEXT_MSGFMT_EXECUTABLE)
Added: trunk/rkward/po/compile_po.cmake
===================================================================
--- trunk/rkward/po/compile_po.cmake (rev 0)
+++ trunk/rkward/po/compile_po.cmake 2011-12-01 19:03:15 UTC (rev 4062)
@@ -0,0 +1,25 @@
+# helper script, which will compile a po into a gmo, if, and only if it is at least 80% translated.
+# this is basically, because ADD_CUSTOM_COMMAND won't capture stdout, and EXECUTE_PROCESS
+# can't be made to re-run when the po-file changes.
+EXECUTE_PROCESS(COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --statistics -o ${_gmoFile} ${_poFile}
+ ERROR_VARIABLE MSGFMT_STATS ERROR_STRIP_TRAILING_WHITESPACE)
+
+# Try to extract statistics information on translated vs. untranslated strings
+STRING(REGEX MATCHALL "[0-9]+"
+ MSGFMT_COUNTS
+ ${MSGFMT_STATS})
+LIST(LENGTH MSGFMT_COUNTS MSGFMT_COUNTS_COUNT)
+IF(MSGFMT_COUNTS_COUNT LESS 2)
+ LIST(APPEND MSGFMT_COUNTS 0) # This means X translated, and no untranslated strings
+ENDIF(MSGFMT_COUNTS_COUNT LESS 2)
+LIST(GET MSGFMT_COUNTS 0 TRANSLATED_COUNT)
+LIST(GET MSGFMT_COUNTS 1 UNTRANSLATED_COUNT)
+MATH(EXPR TRANSLATION_RATIO "${TRANSLATED_COUNT}*100/(${TRANSLATED_COUNT}+${UNTRANSLATED_COUNT})")
+
+# Purge hopelessly incomplete translations
+IF(TRANSLATION_RATIO LESS 80)
+ MESSAGE (STATUS "${_poFile} is only ${TRANSLATION_RATIO}% translated. Will not be installed.")
+ FILE(REMOVE ${_gmoFile})
+ELSE(TRANSLATION_RATIO LESS 80)
+ MESSAGE (STATUS "${_poFile} is ${TRANSLATION_RATIO}% translated.")
+ENDIF(TRANSLATION_RATIO LESS 80)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list