#!/usr/bin/perl # Copyright 2003-2004 Nathan Walp # Adapted for Koha by Ambrose Li # # 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., 50 Temple Place, Suite 330, Boston, MA 02111-1307 USA # my $PACKAGE="koha"; use Locale::Language; $lang{en_AU} = "English (Australian)"; $lang{en_CA} = "English (Canadian)"; $lang{en_GB} = "English (British)"; $lang{es_AR} = "Spanish (Argentinian)"; $lang{fr_FR} = "French"; # FIXME: should be just "fr" $lang{it_IT} = "Italian"; # FIXME: should be just "it" $lang{my_MM} = "Burmese (Myanmar)"; $lang{pl_PL} = "Polish"; # FIXME: should be just "pl" $lang{pt_BR} = "Portuguese (Brazilian)"; $lang{'sr@Latn'} = "Serbian (Latin)"; $lang{zh_CN} = "Chinese (Simplified)"; $lang{zh_TW} = "Chinese (Traditional)"; $ENV{LANG} = $ENV{LC_ALL} = 'C'; opendir(DIR, ".") || die "can't open directory: $!"; @pos = grep { /\.po$/ && -f } readdir(DIR); foreach (@pos) { s/\.po$//; }; closedir DIR; @pos = sort @pos; $now = `date`; system("./update.pl --pot > /dev/null"); print "\n"; print "$PACKAGE i18n statistics\n"; print "\n"; opendir(DIR, ".") || die "can't open directory: $!"; @templates = grep { /\.pot$/ && -f } readdir(DIR); foreach (@templates) { s/\.pot$//; }; closedir DIR; for my $PACKAGE (sort { my($theme1, $module1) = ($1, $2) if $a =~ /^(.*)_([^_]+)$/; my($theme2, $module2) = ($1, $2) if $b =~ /^(.*)_([^_]+)$/; return $module1 cmp $module2 || $theme1 cmp $theme2 } @templates) { my @pos_orig = @pos; my @pos = grep { /^${PACKAGE}_/ } @pos_orig; my($theme, $module) = ($1, $2) if $PACKAGE =~ /^(.*)_([^_]+)$/; $_ = `msgfmt --statistics $PACKAGE.pot -o /dev/null 2>&1`; die "unable to get total: $!" unless (/(\d+) untranslated messages/); $total = $1; print "

Module $module, theme $theme

\n"; print "
\n"; print"\n"; foreach $index (0 .. $#pos) { $trans = $fuzz = $untrans = 0; $po = $pos[$index]; next if $po =~ /_en_EN/; # Koha-specific print STDERR "$po..." if($ARGV[0] eq '-v'); system("msgmerge $po.po $PACKAGE.pot -o $po.new 2>/dev/null"); $_ = `msgfmt --statistics $po.new -o /dev/null 2>&1`; chomp; if(/(\d+) translated message/) { $trans = $1; } if(/(\d+) fuzzy translation/) { $fuzz = $1; } if(/(\d+) untranslated message/) { $untrans = $1; } $transp = 100 * $trans / $total; $fuzzp = 100 * $fuzz / $total; $untransp = 100 * $untrans / $total; if($index % 2) { $color = " bgcolor='#e0e0e0'"; } else { $color = " bgcolor='#d0e0ff'"; } my $lang = $1 if $po =~ /^${PACKAGE}_(.*)$/; # Koha-specific $name = ""; $name = $lang{$lang}; # NOTE $name = code2language($lang) unless $name ne ""; # NOTE $name = "???" unless $name ne ""; printf "\n"; unlink("$po.new"); print STDERR "done ($untrans untranslated strings).\n" if($ARGV[0] eq '-v'); } print "
languagetrans%fuzzy%untrans% 
%s(%s.po)%d%0.2f%d%0.2f%d%0.2f", $name, $po, $trans, $transp, $fuzz, $fuzzp, $untrans, $untransp; printf "", $transp*2 unless $transp*2 < 0.5; printf "", $fuzzp*2 unless $fuzzp*2 < 0.5; printf "", $untransp*2 unless $untransp*2 < 0.5; print "
\n"; print "Latest $PACKAGE.pot generated $now: $PACKAGE.pot
\n"; } print "\n"; print "\n";