1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#!/usr/bin/perl
############################################################################
# msgstats.pl - script to show the current progress of the translations
# -------------------
# begin : Tue Oct 27 2015
# copyright : (C) 2015 by Thomas Eschenbacher
# email : Thomas.Eschenbacher@gmx.de
############################################################################
#
############################################################################
# #
# 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. #
# #
############################################################################
#
# parameters:
# $1 = project root directory
#
use I18N::LangTags::List;
my $top_dir = $ARGV[0] . "/po";
my $app = "kwave";
sub check_po
{
local $name = shift;
local $lang = shift;
local $scope = shift;
local $file = shift;
local $translated = 0;
local $fuzzy = 0;
local $untranslated = 0;
if ( -e $file) {
local $state = `LC_ALL=C msgfmt --statistics $file 2>&1`;
if ($state =~ m/(\d+)\ translated/) {
$translated = $1;
}
if ($state =~ m/(\d+)\ fuzzy/) {
$fuzzy = $1;
}
if ($state =~ m/(\d+)\ untranslated/) {
$untranslated = $1;
}
}
if (($translated + $fuzzy + $untranslated) != 0) {
printf(
"| %-22s | %-11s | %s | %9s | %9s | %9s |",
$name, $lang, $scope, $translated, $fuzzy, $untranslated
);
print " <= " if (($fuzzy + $untranslated) == 0);
print "\n";
}
}
opendir(DIR, $top_dir) or die "opendir $top_dir: $!";
local @dirs = grep { !/(^\.{1,2}$)|(\.git)/ } readdir(DIR);
closedir(DIR);
local @catalogs;
foreach $entry (@dirs)
{
local $e = $top_dir . "/" . $entry;
if (-d $e)
{
my $catalog = $entry;
push(@catalogs, $catalog) if (not grep { /$catalog/ } @catalogs);
}
elsif ($entry =~ /(.*)\.po/)
{
my $catalog = $entry;
push(@catalogs, $catalog) if (not grep { /$catalog/ } @catalogs);
}
}
print "+------------------------+-------------+-------+--------------+--------------+--------------+\n";
print "| language name | lang | scope | translated | fuzzy | untranslated |\n";
print "+------------------------+-------------+-------+--------------+--------------+--------------+\n";
foreach $catalog (@catalogs)
{
if ($catalog =~ /(..)[\_\@]*/) {
local $lang=$1;
local $lang_name = I18N::LangTags::List::name($lang);
local $po_gui=$top_dir . "/" . $catalog . "/" . $app . ".po";
check_po($lang_name, $catalog, "GUI", $po_gui);
if ((-e $top_dir . "/" . $po_doc) || (-e $top_dir . "/" . $po_gui) || (-e $top_dir . "/" . $po_dsk)) {
print "+------------------------+-------------+-------+--------------+--------------+--------------+\n";
}
}
}
#
# end of file
#
|