Debian Codegraph @

debconf-updatepo

raw
1 #! /bin/sh
2
3 # debconf-updatepo - update PO files with Debconf templates files content
4 # Copyright (C) 2002-2005 Denis Barbier <[email protected]>
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 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 msgid_bugs_address=
40
41 for option
42 do
43 if [ -n "$prev" ]; then
44 eval "$prev=\$option"
45 prev=
46 shift
47 continue
48 fi
49 optarg=$(expr "x$option" : 'x[^=]*=\(.*\)')
50 case $option in
51 -h | --h | --help )
52 help=1 ;;
53 -v | --v | --verbose )
54 verbose=--verbose ;;
55 --podir )
56 prev=podir ;;
57 --podir=* )
58 podir=$optarg ;;
59 --skip-merge )
60 skip_merge=1 ;;
61 --skip-pot )
62 skip_pot=1 ;;
63 --msgid-bugs-address=* )
64 msgid_bugs_address=$optarg ;;
65 -* )
66 echo "$0: unknown option: $option ...exiting" 1>&2
67 exit 1 ;;
68 * ) break ;;
69 esac
70 shift
71 done
72
73 if [ -n "$help" ]; then
74 cat <<EOT 1>&2
75 Usage: debconf-updatepo [OPTIONS]
76 Options:
77 -h, --help display this help message
78 -v, --verbose enable verbose mode
79 --podir=DIR specify PO directory (searched by default in
80 debian/po, ./po and ../po)
81 --skip-pot do not generate a new templates.pot file
82 --skip-merge do not merge PO files with templates.pot
83 --msgid-bugs-address=EMAIL
84 specify an email address for POT's
85 Report-Msgid-Bugs-To field
86 EOT
87 exit 0
88 fi
89
90 [ -n "$podir" ] || {
91 for d in ../po po debian/po
92 do
93 [ -d $d ] && podir=$d
94 done
95 }
96 [ -n "$podir" ] || {
97 echo "No PO directory found, use the --podir flag to tell where it is... exiting" 1>&2
98 exit 1
99 }
100 [ -d "$podir" ] || {
101 echo "Directory $podir does not exist... exiting" 1>&2
102 exit 1
103 }
104 [ -f "$podir/POTFILES.in" ] || {
105 echo "File $podir/POTFILES.in does not exist... exiting" 1>&2
106 exit 1
107 }
108
109 [ -n "$verbose" ] && echo "PO directory is $podir" 1>&2
110
111 cd "$podir"
112 domain=templates
113 [ -f debian.pot ] && domain=debian
114
115 if [ -z "$skip_pot" ]; then
116 if [ -z "$msgid_bugs_address" ] && [ -r "../control" ]; then
117 source_package=$(LC_ALL=C grep "^Source:" ../control |
118 sed -e 's/.*:\s\+//' -e 1q)
119 if [ -n "$source_package" ]; then
120 msgid_bugs_address="[email protected]"
121 package_name="$source_package"
122 export XGETTEXT_ARGS
123 fi
124 fi
125 if [ -n "$msgid_bugs_address" ]; then
126 # intltool-update accepts XGETTEXT_ARGS since intltool-debian 0.34.1
127 XGETTEXT_ARGS="--msgid-bugs-address=\"$msgid_bugs_address\" --package-name=\"$source_package\""
128 export XGETTEXT_ARGS
129 fi
130 "$PODEBCONF_LIB/intltool-update" $verbose --gettext-package=$domain --pot || exit 1
131 fi
132
133 if [ -z "$skip_merge" ]; then
134 for lang in *.po
135 do
136 [ "x$lang" = "x*.po" ] && break
137 [ -n "$verbose" ] && printf "Merging $lang with $domain.pot... " 1>&2
138 msgmerge --backup=none --previous -q -U $lang $domain.pot
139 [ -n "$verbose" ] && msgfmt -v -o /dev/null $lang
140 done
141 fi
142
143 rm -f messages.mo 2>/dev/null
144
145 exit 0