mail[Wesnoth-commits] r34189 - in /trunk: cmake/update_pot_source_dependencies.cmake po/CMakeLists.txt


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on March 27, 2009 - 21:05:
Author: mordante
Date: Fri Mar 27 21:05:52 2009
New Revision: 34189

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34189&view=rev
Log:
Add new experimental version of the pot-update.

Added:
    trunk/cmake/update_pot_source_dependencies.cmake   (with props)
Modified:
    trunk/po/CMakeLists.txt

Added: trunk/cmake/update_pot_source_dependencies.cmake
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/cmake/update_pot_source_dependencies.cmake?rev=34189&view=auto
==============================================================================
--- trunk/cmake/update_pot_source_dependencies.cmake (added)
+++ trunk/cmake/update_pot_source_dependencies.cmake Fri Mar 27 21:05:52 2009
@@ -1,0 +1,77 @@
+# Update the source file dependencies of the pot file.
+#
+# This globs all files cpp in the src directory and looks for the text domain
+# definition in that file and outputs these dependencies in POTFILES.in.
+
+# Remove the old input file.
+# Dummy target with a non existing (and not created file) is always executed.
+add_custom_command(
+       OUTPUT ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in.dummy
+       # remove the old file.
+       COMMAND ${CMAKE_COMMAND} 
+                       -E remove 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+       COMMENT "pot-update [${DOMAIN}]: Removed existing POTFILES.in."
+)
+
+# Recreate the input file.
+if(DOMAIN STREQUAL ${DEFAULT_DOMAIN})
+
+       # For the default text domain.
+       add_custom_command(
+               OUTPUT ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+
+               # Create an empty new one, to be sure it will exist.
+               COMMAND ${CMAKE_COMMAND} 
+                               -E touch 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+
+               # Find all cpp files which are not in a .svn directory.
+               COMMAND find src  -name .svn -prune -o -name '*cpp' -print |
+                               sort |
+                               while read file\; do
+                                       # If the file doesn't contain a 
GETTEXT_DOMAIN
+                                       # definition it should be added to 
the default domain.
+                                       if ! grep \"^\#define  
*GETTEXT_DOMAIN\" 
+                                                       $$file &>/dev/null\; 
then 
+
+                                               echo $$file >> 
+                                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in \;
+                                       fi 
+                               done
+
+               DEPENDS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in.dummy
+               WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+               COMMENT 
+                       "pot-update [${DOMAIN}]: Created POTFILES.in for 
default domain."
+       )
+
+else(DOMAIN STREQUAL ${DEFAULT_DOMAIN})
+
+       # For the other text domains.
+       add_custom_command(
+               OUTPUT ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+
+               # Create an empty new one, to be sure it will exist.
+               COMMAND ${CMAKE_COMMAND} 
+                               -E touch 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+
+               # Find all cpp files which are not in a .svn directory.
+               COMMAND find src  -name .svn -prune -o -name '*cpp' -print |
+                               sort |
+                               while read file\; do 
+                                       # If the file contains a 
GETTEXT_DOMAIN definition for
+                                       # the current domain add it to the 
domain.
+                                       if grep \"^\#define  *GETTEXT_DOMAIN  
*\\\"${DOMAIN}\\\"\"
+                                                       $$file &>/dev/null\; 
then 
+
+                                               echo $$file >> 
+                                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in \;
+                                       fi 
+                               done
+
+               DEPENDS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in.dummy
+               WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+               COMMENT "pot-update [${DOMAIN}]: Created POTFILES.in."
+       )
+
+endif(DOMAIN STREQUAL ${DEFAULT_DOMAIN})
+

Propchange: trunk/cmake/update_pot_source_dependencies.cmake
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/po/CMakeLists.txt
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/po/CMakeLists.txt?rev=34189&r1=34188&r2=34189&view=diff
==============================================================================
--- trunk/po/CMakeLists.txt (original)
+++ trunk/po/CMakeLists.txt Fri Mar 27 21:05:52 2009
@@ -38,3 +38,270 @@
 foreach(DIR ${TRANSLATION_DIRS})
   add_subdirectory(${DIR})
 endforeach(DIR ${TRANSLATION_DIRS})
+
+
+
+
+############ Settings. ###########
+
+# Available languages.
+set(LANGUAGES
+       af
+       ar
+       bg
+       ca
+       ca_ES@valencia
+       cs
+       da
+       de
+       el
+       en_GB
+       es
+       eo
+       et
+       eu
+       fi
+       fr
+       fur_IT
+       gl
+       he
+       hr
+       hu
+       id
+       is
+       it
+       ja
+       ko
+       la
+       lt
+       lv
+       mk
+       mr
+       nl
+       nb_NO
+       pl
+       pt
+       pt_BR
+       racv
+       ro
+       ru
+       sk
+       sl
+       sr
+       sr@latin
+       sv
+       tl
+       tr
+       zh_CN
+       zh_TW
+)
+
+# The normal domains use cpp and cfg files.
+set(NORMAL_DOMAINS
+    wesnoth
+    wesnoth-anl
+    wesnoth-aoi
+    wesnoth-did
+    wesnoth-editor
+    wesnoth-ei
+    wesnoth-httt
+    wesnoth-l
+    wesnoth-lib
+    wesnoth-low
+    wesnoth-multiplayer
+    wesnoth-nr
+    wesnoth-sof
+    wesnoth-sotbe
+    wesnoth-tb
+    wesnoth-test
+    wesnoth-thot
+    wesnoth-trow
+    wesnoth-tsg
+    wesnoth-tutorial
+    wesnoth-units
+    wesnoth-utbs
+)
+
+# All available domains.
+set(DOMAINS
+       ${NORMAL_DOMAINS}
+       wesnoth-manpages
+       wesnoth-manual
+)
+
+# If a source file has not GETTEXT_DOMAIN it belongs to this domain.
+set(DEFAULT_DOMAIN wesnoth)
+
+############ Validation. ###########
+
+find_program(GETTEXT_MSGINIT_EXECUTABLE msginit)
+if(NOT GETTEXT_MSGINIT_EXECUTABLE)
+      message(FATAL_ERROR "msginit not found")
+endif(NOT GETTEXT_MSGINIT_EXECUTABLE)
+
+find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
+if(NOT GETTEXT_XGETTEXT_EXECUTABLE )
+      message(FATAL_ERROR "xgettext not found")
+endif(NOT GETTEXT_XGETTEXT_EXECUTABLE )
+
+find_program(GETTEXT_MSGCAT_EXECUTABLE msgcat)
+if(NOT GETTEXT_MSGCAT_EXECUTABLE )
+      message(FATAL_ERROR "msgcat not found")
+endif(NOT GETTEXT_MSGCAT_EXECUTABLE )
+
+set(WMLXGETTEXT ${PROJECT_SOURCE_DIR}/utils/wmlxgettext)
+
+############ pot update. ###########
+
+if(ENABLE_POT_UPDATE_TARGET)
+
+       foreach(DOMAIN ${NORMAL_DOMAINS})
+
+               # Update the source file dependencies.
+               include(update_pot_source_dependencies)
+
+               # Generate pot file for c++ data.
+               add_custom_command(
+                       # misses bug address
+                       OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                       # create the pot file make sure we always get output.
+                       COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
+                               --force-po
+                               --add-comments=TRANSLATORS 
+                               
--files-from=${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in 
+                               --copyright-holder=\"Wesnoth development 
team\" 
+                               --from-code=UTF-8
+                               --sort-by-file
+                               --keyword=_
+                               --keyword=N_
+                               --keyword=sgettext
+                               --keyword=vgettext
+                               --keyword=_n:1,2
+                               --keyword=sngettext:1,2
+                               --keyword=vngettext:1,2
+                               
--output=${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                       # replace the chartype
+                       COMMAND sed -i 
+                               s/charset=CHARSET/charset=UTF-8/ 
+                               
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                       # Remove some header info - Need to test whether 
needed.
+#                      COMMAND sed -i
+#                              -f po/remove-potcdate.sed 
+#                              
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                       DEPENDS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/POTFILES.in
+                       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+                       COMMENT "pot-update [${DOMAIN}]: Generated source pot 
file."
+               )
+
+               # Generate pot file for wml data.
+#              if(EXISTS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/FINDCFG)
+                       add_custom_command(
+                               OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+
+                               COMMAND ${WMLXGETTEXT} 
+                                       --directory=${PROJECT_SOURCE_DIR} 
+                                       --domain=${DOMAIN} 
+                                       `cd ${PROJECT_SOURCE_DIR} && 
+                                               sh 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/FINDCFG`
+                                               > 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+                               DEPENDS 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/FINDCFG
+                               WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+                               COMMENT "pot-update [${DOMAIN}]: Generated 
wml pot file."
+                       )
+#              else(EXISTS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/FINDCFG)
+#                      add_custom_command(
+#                              OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+#
+#                              COMMAND touch 
+#                                              
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+#                              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+#                              COMMENT "pot-update [${DOMAIN}]: Generated 
dummy wml pot file."
+#                      )
+#              endif(EXISTS ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/FINDCFG)
+
+               # Merge both pot files
+               add_custom_command(
+                       # The old function checked for differences in the 
time in the header see
+                       # what we need to do with it.
+                       OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.pot
+
+                       COMMAND ${GETTEXT_MSGCAT_EXECUTABLE} 
+                               --sort-by-file 
+                                        
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                                        
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+                               --output  
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.pot
+
+                       COMMAND ${CMAKE_COMMAND} -E remove 
+                                        
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                                        
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+
+                       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+                       DEPENDS 
+                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.cpp.pot
+                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.wml.pot
+                       COMMENT "pot-update [${DOMAIN}]: Generated pot file."
+               )
+
+               # Update / generate the po files for all languages
+               foreach(LANG ${LANGUAGES})
+
+                       ### Generate new po file.
+
+                       # For some reason CMake is rather happy to delete the 
po file in
+                       # some cases. Too avoid that problem only generate 
the init rule
+                       # if the po file doesn't exist. The case where a po 
file used to
+                       # exist and no longer exists should never occur
+
+                       if(NOT EXISTS 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LANG}.po)
+                               add_custom_command(
+                                       OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LANG}.po
+                                       COMMAND ${GETTEXT_MSGINIT_EXECUTABLE}
+                                                       --no-translator 
+                                                       --input=${DOMAIN}.pot 
+                                                       
--output-file=${LANG}.po
+                                                       --locale=${LANG}
+                                       WORKING_DIRECTORY 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}
+                                       DEPENDS
+                                               
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.pot
+                                       COMMENT 
+                                               "pot-update 
[${DOMAIN}-${LANG}]: Initialized po file."
+                               )
+                       endif(NOT EXISTS 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LANG}.po)
+
+                       ### Update existing po file.
+                       add_custom_command(
+                               # The pot-update depends on a dummy file 
which we promise to
+                               # make. We don't make this dummy file but the 
pot-update
+                               # still works.
+                               OUTPUT 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LANG}.po.dummy
+                               COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} 
+                                               --backup=none
+                                               -U ${LANG}.po 
+                                               ${DOMAIN}.pot
+                               DEPENDS
+                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.pot 
+                                       
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LANG}.po
+                               WORKING_DIRECTORY 
${PROJECT_SOURCE_DIR}/po/${DOMAIN}
+                               COMMENT "pot-update [${DOMAIN}-${LANG}]: 
Updated po file."
+                       )
+
+                       SET(pot-update-SRC ${pot-update-SRC} 
${DOMAIN}/${LANG}.po.dummy)
+
+               endforeach(LANG ${LANGUAGES})
+
+               # Add to target list
+               SET(pot-update-SRC 
+                       ${pot-update-SRC} 
+                       ${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${DOMAIN}.pot # 
should depend on languages
+               )
+
+       endforeach(DOMAIN ${NORMAL_DOMAINS})
+
+       # The target to call
+       add_custom_target(pot-update2
+               COMMENT "pot-update: Done."
+               DEPENDS ${pot-update-SRC}
+       )
+
+endif(ENABLE_POT_UPDATE_TARGET)
+




Related Messages


Powered by MHonArc, Updated Fri Mar 27 22:40:43 2009