summaryrefslogtreecommitdiffstats
path: root/scripts/convert-locale
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/convert-locale')
-rwxr-xr-xscripts/convert-locale48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/convert-locale b/scripts/convert-locale
new file mode 100755
index 0000000..f848263
--- /dev/null
+++ b/scripts/convert-locale
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Create translation catalogs on the system for all of the packages for which
+# we can find .mo files.
+#
+
+SOURCELOCALEDIRS="/usr/share/locale /usr/lib/locale"
+DESTLOCALEDIR=$DESTDIR/usr/share/locale
+
+DESTFILTERS=
+
+while [ $# -gt 0 ] ; do
+ DESTFILTERS="$DESTFILTERS $1"
+ shift
+done
+
+if [ -z "$DESTFILTERS" ] ; then
+ echo Usage: `basename $0` 'filter [...]'
+fi
+
+exec < /dev/null
+
+PACKAGES=`find $SOURCELOCALEDIRS -name "*.mo" -print0 | xargs -0 -n1 basename | sed 's,.mo$,,g' | sort -u`
+
+for filter in $DESTFILTERS ; do
+ destlocale=en_US@$filter
+ test -d $DESTLOCALEDIR/$destlocale/LC_MESSAGES || \
+ mkdir -p $DESTLOCALEDIR/$destlocale/LC_MESSAGES
+done
+for package in $PACKAGES ; do
+ sourcemo=`find $SOURCELOCALEDIRS -name $package.mo | head -n1`
+ if test -n "$sourcemo" ; then
+ echo -n $package
+ for filter in $DESTFILTERS ; do
+ destlocale=en_US@$filter
+ msgunfmt $sourcemo | \
+ pomatic /dev/stdin $filter | \
+ msgfmt -o $DESTLOCALEDIR/$destlocale/LC_MESSAGES/$package.mo - && \
+ echo -n " $destlocale"
+ done
+ echo ""
+ fi
+done
+for filter in $DESTFILTERS ; do
+ destlocale=en_US@$filter
+ test -d $DESTLOCALEDIR/$destlocale/LC_MESSAGES && \
+ rmdir $DESTLOCALEDIR/$destlocale/LC_MESSAGES 2> /dev/null
+done