Different Utilities for CMake Project Building/Documenting/etc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.9 KiB

  1. #!/bin/sh
  2. ##
  3. # settings
  4. ##
  5. PO_DIR_NAME=po
  6. EXE_PATH="`readlink -f $0`"
  7. PRJ_PATH="${EXE_PATH%/*/*/*}"
  8. ##
  9. # code
  10. ##
  11. cd $PRJ_PATH
  12. find */ -type f -regex '.*\.\(glade\|glade2\|ui\)$' -exec intltool-extract --type="gettext/glade" '{}' \; 2>/dev/null
  13. find */ -type f -name '*.gschema.xml' -exec intltool-extract --type="gettext/gsettings" '{}' \; 2>/dev/null
  14. C_FILELIST="`find */ -type f -regex '.*\.\(h\|hxx\|hpp\|c\|cxx\|cpp\|vala\)$' 2>/dev/null`"
  15. PROJECT_LOWERCASE_NAME=`grep '\<SET *(PROJECT_LOWERCASE_NAME\>' "$PRJ_PATH"/CMakeLists.txt | sed 's~.*"\(.*\)".*~\1~'`
  16. MAJOR=`grep '\<SET *(MAJOR\>' "$PRJ_PATH"/CMakeLists.txt | sed 's~.*\([0-9]\+\).*~\1~'`
  17. mkdir -p $PO_DIR_NAME
  18. xgettext --language=C --escape --package-name=$PROJECT_LOWERCASE_NAME --default-domain=$PROJECT_LOWERCASE_NAME --add-comments=/// \
  19. -k_ -kQ_ -kC_ -kN_ -kNC_ -kg_dgettext -kg_dcgettext \
  20. -kg_dngettext -kg_dpgettext -kg_dpgettext2 -kg_strip_context -F -n -o \
  21. $PRJ_PATH/$PO_DIR_NAME/$source.pot $C_FILELIST
  22. find ${PRJ_PATH} -type f -regex '.*\.\(glade\|glade2\|ui\)\.h$' -exec rm '{}' \; 2>/dev/null
  23. find ${PRJ_PATH} -type f -name '*.gschema.xml.h' -exec rm '{}' \; 2>/dev/null
  24. msgcat -o $PRJ_PATH/$PO_DIR_NAME/$PROJECT_LOWERCASE_NAME.pot --use-first $PRJ_PATH/$PO_DIR_NAME/$source.pot
  25. rm $PRJ_PATH/$PO_DIR_NAME/$source.pot
  26. [ 0 != $? ] && echo "xgettext failed ;-(" && exit 1
  27. [ ! -e $PRJ_PATH/$PO_DIR_NAME/$PROJECT_LOWERCASE_NAME.pot ] && echo "No strings found ;-(" && exit 1
  28. for d in $PRJ_PATH/$PO_DIR_NAME/*; do
  29. [ ! -d $d ] && continue
  30. if [ -e $d/$PROJECT_LOWERCASE_NAME.po ]; then
  31. echo "Merging '${d##*/}' locale" && msgmerge -F -U $d/$PROJECT_LOWERCASE_NAME.po $PRJ_PATH/$PO_DIR_NAME/$PROJECT_LOWERCASE_NAME.pot
  32. [ 0 != $? ] && echo "msgmerge failed ;(" && exit 1
  33. else
  34. echo "Creating '${d##*/}' locale" && msginit -l ${d##*/} -o $d/$PROJECT_LOWERCASE_NAME.po -i $PRJ_PATH/$PO_DIR_NAME/$PROJECT_LOWERCASE_NAME.pot
  35. [ 0 != $? ] && echo "msginit failed ;(" && exit 1
  36. fi
  37. done