xgettext.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. #
  3. # xgettext.sh
  4. #
  5. # extracts strings from various sources
  6. # into one pot file
  7. #
  8. # @author Christopher Han <xiphux@gmail.com>
  9. # @copyright Copyright (c) 2010 Christopher Han
  10. # @package GitPHP
  11. # @package util
  12. #
  13. VER="`cat include/version.php | grep '^\$gitphp_version = ' | cut -d '\"' -f 2`"
  14. DIR="locale"
  15. COPYRIGHT="Christopher Han"
  16. EMAIL="xiphux@gmail.com"
  17. PKGNAME="GitPHP"
  18. BUNDLE="gitphp"
  19. FILE="gitphp.pot"
  20. # Extract from templates
  21. lib/smarty-gettext/tsmarty2c.php templates > smarty.c
  22. xgettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" --add-comments --no-location --from-code=utf-8 smarty.c
  23. rm smarty.c
  24. # Extract from include directory
  25. find include -iname '*.php' -type f | xgettext -k__ -k__n -ktranslate -kngettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -L PHP -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" --from-code=utf-8 -f -
  26. # Extract from index
  27. xgettext -k__ -k__n -ktranslate -kngettext -d ${BUNDLE} -o "${FILE}" -p ${DIR} -L PHP -j --package-name="${PKGNAME}" --package-version="${VER}" --msgid-bugs-address="${EMAIL}" --copyright-holder="${COPYRIGHT}" --from-code=utf-8 index.php
  28. # File references from smarty-gettext show up as code comments,
  29. # convert them back to file references
  30. sed -e 's/^#\./#:/' -i "${DIR}/${FILE}"