#!/bin/bash # This is a word count utility for gettext po files. # Copyright (C) 2002 Szabolcs Ban # Copyright (C) 2003 Andras Timar # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA declare -i stotal=0; declare -i sfuzzy=0; declare -i strans=0; declare -i suntrans=0; echo -e "\n\nPO file word count report\n\n\n

PO file word count report

\n" echo -e "\n" for i in $* do # removing all deprecated (#~) and location (#:) lines # removing all empty lines # and comments # replacing \n with ß # replacing escaped quotes with ¤ # replacing quotes with § # joining multiple line msg*s # changing back ß to \n # removing lines begining with # # removing lines containing empty string or marked as fuzzy # changing back escaped quotes cat $i | grep -v "^#[~:]" | grep -v "^$" | \ grep -v "# " | tr "\n" "ß" | \ sed "s/\\\\\"/¤/g" | \ tr "\\\"" "§" | \ sed "s/§\s*ß§//g" | \ sed "s/ßmsgstr §//g" | \ sed "s/ß#, fuzzy[^ß]*ßmsgid §/ßmsgidð§§ §/g" | \ tr "ß" "\n" | \ grep -v "^#" | \ grep -v "msgid §§" | \ sed "s/¤/\\\\\"/g" | \ sed "s/§§/ß/g" > /tmp/count.db #count total total=`cat /tmp/count.db | cut -f 2 -d "§" | \ sed "s/[ßð]//g" | wc -w` stotal=$stotal+$total # count untranslated untrans=`cat /tmp/count.db | grep ß | grep -v ð | cut -f 2 -d "§" | \ sed "s/[ßð]//g" | wc -w` suntrans=$suntrans+$untrans # count fuzzy fuzzy=`cat /tmp/count.db | grep ð | cut -f 2 -d "§" | \ sed "s/[ßð]//g" | wc -w` sfuzzy=$sfuzzy+$fuzzy #count translated trans=`cat /tmp/count.db | grep -v ß | cut -f 2 -d "§" | \ sed "s/[ßð]//g" | wc -w` strans=$strans+$trans echo -e "" done echo -e "" echo -e "
FilenameTotalTransFuzzyUntrans
" $i "" $total "" $trans "" $fuzzy "" $untrans "
Total " $stotal "" $strans "" $sfuzzy "" $suntrans "
\n\n" # removing the count.db file # rm /tmp/count.db