1#!/usr/local/bin/bash 2# 3# Copyright 2005 Zuza Software Foundation 4# 5# This file is part of The Translate Toolkit. 6# 7# The Translate Toolkit is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# translate is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this program; if not, see <http://www.gnu.org/licenses/>. 19 20 21# popuretext - extracts all the source text from a directory of PO or POT files, removes 22# po headers and optionally the accelerator keys. 23 24if [ $# -lt 2 ]; then 25 echo "Usage: popuretext ( -P pot-dir | po-dir ) file.txt [accelerator]" 26 exit 1 27fi 28 29do_pot=0 30if [ "$1" == "-P" ]; then 31 do_pot=1 32 shift 33 potdir=$1 34else 35 podir=$1 36fi 37textfile=$2 38accelerator=$3 39 40 41if [ $do_pot -eq 1 ]; then 42 tempdir=`mktemp -d -t /tmp tmp.XXXXXXXXXX` 43 for pot in `cd $potdir; find . -name "*.pot"` 44 do 45 mkdir -p $tempdir/$(dirname $pot) 46 msgen --no-wrap $potdir/$pot -o $tempdir/$(dirname $pot)/$(basename $pot .pot).po 47 done 48 podir=$tempdir 49fi 50 51cat /dev/null > $textfile 52 53for po in `find $podir -name "*.po"` 54do 55 msgexec -i $po sed "s/$/\\n/g" | 56 sed "/^_:/d" | 57 sed "/^$/d" | 58 if [ "$accelerator" != "" ]; then 59 sed "s/$accelerator//g" 60 else 61 cat 62 fi | 63 sed "/^\(Project-Id-Version:\|Report-Msgid-Bugs-To:\|POT-Creation-Date:\|PO-Revision-Date:\|Last-Translator:\|Language-Team:\|MIME-Version:\|Content-Type:\|Content-Transfer-Encoding:\|Plural-Forms:\|X-Generator:\|X-Accelerator-Marker:\)/d" >> $textfile 64done 65 66rm -rf $tempdir 67