diff options
author | Nalin Dahyabhai <nalin@dahyabhai.net> | 2010-02-02 12:13:23 -0500 |
---|---|---|
committer | Nalin Dahyabhai <nalin@dahyabhai.net> | 2010-02-02 12:13:23 -0500 |
commit | 8d36f0832d166f0eb4944515e21770eebec11012 (patch) | |
tree | 4c3dfea41fe1ca4aa646b577f7680eb300226b83 /scripts | |
parent | 827ee5c7c38d07d6543e5776050e1c1f06b3e90b (diff) | |
download | pomatic-8d36f0832d166f0eb4944515e21770eebec11012.tar.gz pomatic-8d36f0832d166f0eb4944515e21770eebec11012.tar.xz pomatic-8d36f0832d166f0eb4944515e21770eebec11012.zip |
- finish the autotooling
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/collect-potfiles | 54 | ||||
-rwxr-xr-x | scripts/convert-locale | 48 | ||||
-rwxr-xr-x | scripts/create-locales | 46 | ||||
-rwxr-xr-x | scripts/inject-talkfilter-locales | 50 | ||||
-rw-r--r-- | scripts/talkfilters-i18n.spec.redhat | 27 |
5 files changed, 225 insertions, 0 deletions
diff --git a/scripts/collect-potfiles b/scripts/collect-potfiles new file mode 100755 index 0000000..e72786f --- /dev/null +++ b/scripts/collect-potfiles @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Collect .pot files from a set of source packages and place them in +# a specified output directory. +# + +outdir=$1 +shift + +if [ -z "$outdir" ] ; then + echo usage: `basename $0` output_directory sourcerpm '[...]' + exit 1 +fi + +tmpdir=`mktemp -d ${TMPDIR:-/tmp}/collect-potfilesXXXXXX` +if [ -z "$tmpdir" ] ; then + echo error creating tmpdir + exit 1 +fi + +exec < /dev/null + +cleanup() +{ + rm -fr $tmpdir +} +trap cleanup PIPE INT KILL TERM + +for sourcepackage in $@ ; do + rpm \ + --define "_topdir $tmpdir" \ + --define "_sourcedir $tmpdir" \ + --define "_specdir $tmpdir" \ + --define "_builddir $tmpdir" \ + --define "_srpmdir $tmpdir" \ + --define "_rpmdir $tmpdir" \ + -U $sourcepackage > /dev/null 2> /dev/null && + rpmbuild \ + --define "_topdir $tmpdir" \ + --define "_sourcedir $tmpdir" \ + --define "_specdir $tmpdir" \ + --define "_builddir $tmpdir" \ + --define "_srpmdir $tmpdir" \ + --define "_rpmdir $tmpdir" \ + -bp $tmpdir/*.spec > /dev/null 2> /dev/null + for potfile in `find $tmpdir -name "*.pot"`; do + basename $potfile + cp -f $potfile $outdir/ + done + chmod -R u+rw $tmpdir/* + rm -fr $tmpdir/* +done + +cleanup 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 diff --git a/scripts/create-locales b/scripts/create-locales new file mode 100755 index 0000000..a1cddc9 --- /dev/null +++ b/scripts/create-locales @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Generate new .mo files for each of the packages in a given directory. +# +if [ $# -lt 1 ] ; then + echo usage: `basename $0` source_rpm_directory + exit 1 +fi +localedir=${DESTDIR:-}/usr/share/locale +filters="biffster chef drawl jive krad kraut l33t redneck valspeak" + +tmpdir=`mktemp -d ${TMPDIR:-/tmp}/create-localesXXXXXX` +if [ -z "$tmpdir" ] ; then + echo error creating tmpdir + exit 1 +fi + +exec < /dev/null + +cleanup() +{ + rm -fr $tmpdir +} +trap cleanup PIPE INT KILL TERM + +echo '>>>> Collecting potfiles. <<<<' +collect-potfiles $tmpdir `find $@ -name "*.src.rpm" | sort` + +echo '>>>> Generating translations. <<<<' +for filter in $filters ; do + locale=en_US@$filter + test -d $localedir/$locale/LC_MESSAGES || \ + mkdir -p $localedir/$locale/LC_MESSAGES +done +for potfile in $tmpdir/*.pot ; do + potfilename=`basename $potfile` + package=`basename $potfilename .pot` + echo -n "$package " + for filter in $filters ; do + locale=en_US@$filter + pomatic $potfile $filter | msgfmt -o $localedir/$locale/LC_MESSAGES/$package.mo - && echo -n " $filter" + done + echo "" +done + +cleanup diff --git a/scripts/inject-talkfilter-locales b/scripts/inject-talkfilter-locales new file mode 100755 index 0000000..fe76f6c --- /dev/null +++ b/scripts/inject-talkfilter-locales @@ -0,0 +1,50 @@ +#!/bin/sh +# +# Add translations for $po_filters for every .pot file in this tree, and if +# we find what looks like autoconf scripts setting ALL_LINGUAS, add the +# new translations to the list of languages. +# +po_filters="biffster chef drawl jive krad kraut l33t redneck valspeak" +quiet=false + +exec < /dev/null + +for arg in $@ ; do + case "$arg" in + --quiet) quiet=true ;; + *) po_filters="$po_filters $arg" ;; + esac +done + +for filter in $po_filters ; do + fakelang="en_US@$filter" + + found=false + for potfile in `find . -name "*.pot"` ; do + if test -r "$potfile" ; then + subdir=`dirname $potfile` + if ! $quiet ; then + echo "Generating $fakelang translation." + fi + pomatic $potfile $filter > $subdir/$fakelang.po + found=true + fi + done + + if ! $found ; then + continue + fi + + for script in `find . -name configure.in -o -name configure.ac -o -name configure` ; do + if test -r $script ; then + sed -e 's,^ALL_LINGUAS="\(.*\)",ALL_LINGUAS="\1 '"$fakelang"'",g' $script > $script.___spec_prep_post && \ + chmod --reference $script $script.___spec_prep_post && \ + touch -r $script $script.___spec_prep_post && \ + mv -f $script.___spec_prep_post $script && \ + $quiet || echo "Added $fakelang to ALL_LINGUAS in $script." + if test -r $script.__spec_prep_post ; then + rm -f $script.___spec_prep_post + fi + fi + done +done diff --git a/scripts/talkfilters-i18n.spec.redhat b/scripts/talkfilters-i18n.spec.redhat new file mode 100644 index 0000000..4e2f31c --- /dev/null +++ b/scripts/talkfilters-i18n.spec.redhat @@ -0,0 +1,27 @@ +Name: talkfilters-i18n +Version: 1.0 +Release: 1 +Summary: talkfilters translations +Group: Applications/Text +License: GPL +BuildRoot: %{_tmppath}/%{name}-root +BuildPrereq: talkfilters, pomatic >= 1.0.2 +BuildArch: noarch + +%description +The talkfilters-i18n package contains translations for applications. + +%install +rm -fr $RPM_BUILD_ROOT +env DESTDIR=$RPM_BUILD_ROOT create-locales /mnt/redhat/test/latest-i386/SRPMS/ + +%clean +rm -fr $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%{_datadir}/locale/*/LC_MESSAGES/* + +%changelog +* Fri Jul 11 2003 Nalin Dahyabhai <nalin@redhat.com> +- initial package |