home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / debconf-updatepo < prev    next >
Encoding:
Text File  |  2006-12-12  |  3.9 KB  |  134 lines

  1. #! /bin/sh
  2.  
  3. #  debconf-updatepo  - update PO files with Debconf templates files content
  4. #  Copyright (C) 2002-2005  Denis Barbier <barbier@debian.org>
  5. #
  6. #  This program is free software; you can redistribute it and/or modify
  7. #  it under the terms of the GNU General Public License as published by
  8. #  the Free Software Foundation; either version 2 of the License, or (at
  9. #  your option) any later version.
  10. #
  11. #  This program is distributed in the hope that it will be useful, but
  12. #  WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. #  General Public License for more details.
  15. #
  16. #  You should have received a copy of the GNU General Public License
  17. #  along with this program; if not, write to the
  18. #  Free Software Foundation, Inc.,
  19. #  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. #   This script is part of po-debconf
  22.  
  23. : ${PODEBCONF_LIB=/usr/share/intltool-debian}
  24. INTLTOOL_EXTRACT=${PODEBCONF_LIB}/intltool-extract
  25. export INTLTOOL_EXTRACT
  26.  
  27. #  See intltool-extract
  28. INTLTOOL_DEBIAN_TYPE=po-debconf
  29. export INTLTOOL_DEBIAN_TYPE
  30.  
  31. #   Prevent automatic conversion to UTF-8 by Perl
  32. unset LANGUAGE LANG LC_ALL LC_CTYPE
  33.  
  34. help=
  35. verbose=
  36. podir=
  37. skip_pot=
  38. skip_merge=
  39.  
  40. for option
  41. do
  42.         if [ -n "$prev" ]; then
  43.                 eval "$prev=\$option"
  44.                 prev=
  45.                 shift
  46.                 continue
  47.         fi
  48.         optarg=$(expr "x$option" : 'x[^=]*=\(.*\)')
  49.         case $option in
  50.             -h | --h | --help )
  51.                 help=1 ;;
  52.             -v | --v | --verbose )
  53.                 verbose=--verbose ;;
  54.             --podir )
  55.                 prev=podir ;;
  56.             --podir=* )
  57.                 podir=$optarg ;;
  58.             --skip-merge )
  59.                 skip_merge=1 ;;
  60.             --skip-pot )
  61.                 skip_pot=1 ;;
  62.             -* )
  63.                 echo "$0: unknown option: $option ...exiting" 1>&2
  64.                 exit 1 ;;
  65.             * ) break ;;
  66.         esac
  67.         shift
  68. done
  69.  
  70. if [ -n "$help" ]; then
  71.         cat <<EOT 1>&2
  72. Usage: debconf-updatepo [OPTIONS]
  73. Options:
  74.   -h,  --help          display this help message
  75.   -v,  --verbose       enable verbose mode
  76.        --podir=DIR     specify PO directory (searched by default in
  77.                        debian/po, ./po and ../po)
  78.        --skip-pot      do not generate a new templates.pot file
  79.        --skip-merge    do not merge PO files with templates.pot
  80. EOT
  81.         exit 0
  82. fi
  83.  
  84. [ -n "$podir" ] || {
  85.         for d in ../po po debian/po
  86.         do
  87.                 [ -d $d ] && podir=$d
  88.         done
  89. }
  90. [ -n "$podir" ] || {
  91.         echo "No PO directory found, use the --podir flag to tell where it is... exiting" 1>&2
  92.         exit 1
  93. }
  94. [ -d "$podir" ] || {
  95.         echo "Directory $podir does not exist... exiting" 1>&2
  96.         exit 1
  97. }
  98. [ -f "$podir/POTFILES.in" ] || {
  99.         echo "File $podir/POTFILES.in does not exist... exiting" 1>&2
  100.         exit 1
  101. }
  102.  
  103. [ -n "$verbose" ] && echo "PO directory is $podir" 1>&2
  104.  
  105. cd "$podir"
  106. domain=templates
  107. [ -f debian.pot ] && domain=debian
  108.  
  109. if [ -z "$skip_pot" ]; then
  110.         if [ -r "../control" ]; then
  111.                 maint=$(LC_ALL=C grep "^Maintainer:" ../control | sed -e 1q | sed -e 's/.*<//' -e 's/>.*//')
  112.                 #  intltool-update accepts XGETTEXT_ARGS since intltool-debian 0.34.1
  113.                 if [ -n "$maint" ]; then
  114.                         XGETTEXT_ARGS="--msgid-bugs-address=$maint"
  115.                         export XGETTEXT_ARGS
  116.                 fi
  117.         fi
  118.         "$PODEBCONF_LIB/intltool-update" $verbose --gettext-package=$domain --pot || exit 1
  119. fi
  120.  
  121. if [ -z "$skip_merge" ]; then
  122.         for lang in *.po
  123.         do
  124.                 [ "x$lang" = "x*.po" ] && break
  125.                 [ -n "$verbose" ] && printf "Merging $lang with $domain.pot... " 1>&2
  126.                 msgmerge -q -U $lang $domain.pot
  127.                 [ -n "$verbose" ] && msgfmt -v -o /dev/null $lang
  128.         done
  129. fi
  130.  
  131. rm -f messages.mo 2>/dev/null
  132.  
  133. exit 0
  134.