summaryrefslogtreecommitdiffstats
path: root/convert-locale
blob: 39dc3a2576ae6a6709011a1d727521d05b72370a (plain)
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
#!/bin/bash

SOURCELOCALEDIR=/usr/share/locale
DESTLOCALEDIR=$DESTDIR/usr/share/locale
LIBLOCALEDIR=$DESTDIR/usr/lib/locale

SOURCELOCALE=de
DESTLOCALES=

while [ $# -gt 0 ] ; do
	case $1 in
	--source)
		shift
		SOURCELOCALE=$1
		shift
		;;
	*)
		DESTLOCALES="$DESTLOCALES $1"
		shift
		;;
	esac
done

if [ -z "$DESTLOCALES" ] ; then
	echo Usage: `basename $0` '[--source sourcelocale]' 'destlocale [...]'
fi

messagedir=$SOURCELOCALEDIR/$SOURCELOCALE/LC_MESSAGES

for DESTLOCALE in $DESTLOCALES ; do
	aliasfile=/usr/X11R6/lib/X11/locale/locale.alias
	alias=`basename $DESTLOCALE`

	echo Converting strings from $SOURCELOCALE using $alias.

	test  -d $LIBLOCALEDIR || mkdir -p $LIBLOCALEDIR
	test  -d $DESTLOCALEDIR/$alias/LC_MESSAGES || \
	mkdir -p $DESTLOCALEDIR/$alias/LC_MESSAGES

	test  -d $LIBLOCALEDIR/$alias/LC_MESSAGES || \
	ln -s /usr/lib/locale/en_US $LIBLOCALEDIR/$alias

	sources=`find $messagedir -type f -name "*.mo" | sort`

	for source in $sources ; do
		domain=`basename $source .mo`
		echo " $domain"
		target=$DESTLOCALEDIR/$alias/LC_MESSAGES/$domain.mo
		TMP1=`mktemp /tmp/convert${domain}XXXXXX`
		TMP2=`mktemp /tmp/convert${domain}XXXXXX`
		msgunfmt $source > $TMP1
		pomatic $TMP1 $DESTLOCALE > $TMP2
		msgfmt -o $target $TMP2
		rm $TMP1 $TMP2
	done
	echo

	if ! grep -q ^$alias: $aliasfile ; then
		echo $alias: en_US.ISO8859-1 >> $aliasfile
	fi
done