/usr/bin/po2debconf is in po-debconf 1.0.20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | #! /bin/sh
# po2debconf - merge translations into Debconf templates file
# Copyright (C) 2002-2005 Denis Barbier <barbier@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# This script is part of po-debconf
: ${PODEBCONF_LIB=/usr/share/intltool-debian}
: ${PODEBCONF_ENCODINGS=/usr/share/po-debconf/encodings}
# Prevent automatic conversion to UTF-8 by Perl
unset LANGUAGE LANG LC_ALL LC_CTYPE
# Default values
dftencoding=utf8
dftformat=2
help=
quiet=--quiet
origfile=
podir=
outfile=
encoding=$dftencoding
format=$dftformat
for option
do
if [ -n "$prev" ]; then
eval "$prev=\$option"
prev=
shift
continue
fi
optarg=`expr "x$option" : 'x[^=]*=\(.*\)'`
case $option in
-h | --h | --help )
help=1
shift ;;
-v | --v | --verbose )
quiet=
shift ;;
-o | --o | --output )
prev=outfile
shift ;;
-o=* | --o=* | --output=* )
outfile=$optarg
shift ;;
--podir )
prev=podir
shift ;;
--podir=* )
podir=$optarg
shift ;;
-e | --e | --encoding )
prev=encoding
shift ;;
--e=* | --encoding=* )
encoding=$optarg
shift ;;
-E | --E | --alt-encoding )
encoding=popular
shift ;;
-u | --u | --utf8 )
# Obsolete
encoding=utf8
shift ;;
-n | --n | --no-utf8 )
# Obsoleted
encoding=po
shift ;;
-O | --O | --old-format )
# Obsolete, use po/output file instead
format=1
shift ;;
-* ) echo "$0: unknown option: $option ...exiting" 1>&2
exit 1
;;
* ) break ;;
esac
done
origfile=$1
fail=0
[ -n "$origfile" ] || fail=1
if [ "x$help" = x1 ] || [ "x$fail" = x1 ]; then
cat <<EOT 1>&2
Usage: po2debconf [options] master
Options:
-h, --help display this help message
-v, --verbose enable verbose mode
-o, --output=FILE specify output file (Default: stdout)
-e, --encoding=STRING convert encoding, STRING is chosen between
po: no conversion
utf8: convert to UTF-8
popular: change encoding according to file map found
in PODEBCONF_ENCODINGS environment variable
(Default, map is $PODEBCONF_ENCODINGS)
traditional: obsolete, replaced by popular
--podir=DIR specify PO output directory
(Default: <master directory>/po)
EOT
exit $fail
fi
[ -f "$origfile" ] || {
echo "ERROR: File $origfile does not exist ...exiting" 1>&2
exit 1
}
utf8=
case $encoding in
po | PO )
encoding=po ;;
pop* | POP* )
encoding=popular ;;
trad* | TRAD* )
encoding=popular ;;
utf8 | utf-8 | UTF8 | UTF-8 )
encoding=utf8 ;;
* ) echo "ERROR: Wrong --encoding argument, must be po, popular or utf8 ...exiting" 1>&2
exit 1 ;;
esac
[ -n "$podir" ] || podir=`dirname $origfile`/po
[ -d "$podir" ] || {
echo "ERROR: Directory $podir does not exist ...exiting" 1>&2
exit 1
}
# Override values when $podir/output file is found
if [ -f "$podir/output" ]; then
outputformat=`sed -e 1q "$podir/output" | awk '{printf "%s", $1}'`
[ -n "$outputformat" ] && format=$outputformat
outputencoding=`sed -e 1q "$podir/output" | awk '{printf "%s", $2}'`
[ -n "$outputencoding" ] && encoding=$outputencoding
fi
# Test validity of $encoding and $format values
case $encoding in
po | popular | utf8 )
# Do nothing
: ;;
* )
# Invalid value, set default encoding
echo "Warning:Invalid encoding: $encoding, set to '$dftencoding'" 1>&2
encoding=$dftencoding ;;
esac
case $format in
1 | 2 )
# Do nothing
:
;;
* )
# Invalid value, set default encoding
echo "Warning:Invalid format: $format, set to '$dftformat'" 1>&2
format=$dftformat
;;
esac
[ "$encoding" = popular ] || format=2
[ "$encoding" = utf8 ] && utf8="-u"
outdir=
fake=
is_tmp=
tmpfile=
cleanup()
{
rc=$?
[ -n "$outdir" ] && [ -d "$outdir" ] && {
rm -f "$outdir"/*.po
rmdir "$outdir"
}
[ -n "$fake" ] && [ -L "$podir/$fake.po" ] && rm -f "$podir/$fake.po"
[ -n "$is_tmp" ] && [ -f "$outfile" ] && rm -f "$outfile"
[ -n "$tmpfile" ] && [ -f "$tmpfile" ] && rm -f "$tmpfile"
exit $rc
}
trap 'cleanup' HUP INT QUIT BUS PIPE TERM
if [ "$encoding" = popular ]; then
[ -f "$PODEBCONF_ENCODINGS" ] || {
echo "ERROR: File $PODEBCONF_ENCODINGS does not exist ...exiting" 1>&2
exit 1
}
outdir=`mktemp -t -d po2debconf.XXXXXXXXXX` || {
echo "ERROR: Unable to create temporary directory ...exiting" 1>&2
exit 1
}
tmpfile=`mktemp -t po2debconf.XXXXXXXXXX` || {
echo "ERROR: Unable to create temporary file ...exiting" 1>&2
exit 1
}
for f in $podir/*.po
do
[ -f "$f" ] || continue
l=`echo $f | sed -e 's/.*\///' -e 's/\.po$//'`
encto=`grep "^$l[ ]" "$PODEBCONF_ENCODINGS" | sed -e "s/^$l[ ][ ]*//" -e 1q`
if [ -n "$encto" ]; then
[ -n "$quiet" ] || echo "Converting $f to $encto..." 1>&2
if msgconv -t "$encto" "$f" -o "$tmpfile" 2>/dev/null; then
mv "$tmpfile" "$outdir/$l.po"
else
echo "Warning: msgconv failed when converting file $f to $encto ... file skipped" >&2
fi
else
echo "Warning: Unknown default encoding for $l, get it from $f" 1>&2
cat "$f" > "$outdir/$l.po"
fi
done
podir=$outdir
rm -f "$tmpfile"
fi
if [ "x$outfile" = 'x-' ] || [ -z "$outfile" ]; then
outfile=`mktemp -t po2debconf.XXXXXXXXXX` || {
echo "ERROR: Unable to create temporary file ...exiting" 1>&2
exit 1
}
is_tmp=1
fi
# Helps no.po -> nb.po transition
if [ -r "$podir/no.po" ]; then
if [ -r "$podir/nb.po" ]; then
echo "Warning: Both no.po and nb.po files exist, please consider removing no.po" 1>&2
else
echo "Warning: no.po is obsolete and should be renamed into nb.po" 1>&2
fi
elif [ -r "$podir/nb.po" ]; then
# nb.po was found, copy it to no.po to provide both -nb and -no
# localized fields and thus ease no -> nb transition for Norwegian
# speaking people.
fake=no
ln -s nb.po "$podir/no.po"
fi
$PODEBCONF_LIB/intltool-merge $quiet --rfc822deb-style $utf8 $podir $origfile $outfile 1>&2 || exit 1
if [ $format -le 1 ]; then
tmpfile=`mktemp -t po2debconf.XXXXXXXXXX` || {
echo "ERROR: Unable to create temporary file ...exiting" 1>&2
exit 1
}
sed -e 's/^\([^ :]*\)\.[^ :]*:/\1:/' $outfile > $tmpfile && mv -f $tmpfile $outfile
fi
tmpfile=`mktemp -t po2debconf.XXXXXXXXXX` || {
echo "ERROR: Unable to create temporary file ...exiting" 1>&2
exit 1
}
sed -e 's/^DefaultChoice/Default/' $outfile > $tmpfile && mv -f $tmpfile $outfile
[ -n "$is_tmp" ] && cat "$outfile"
# Set $? to 0
:
cleanup
|