/usr/share/anjuta/tools/translation-status.pl is in anjuta-common 2:3.18.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | #!/usr/bin/perl
## status.pl
## Copyright (C) Naba Kumar <naba@gnome.org>
##
## 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 Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## modified 2001-11-05 Andy Piper <andy.piper@freeuk.com>
## - added further countries to the hash table
## - altered XML file output
## - corrected typos
=head Status.pl
Usage: status.pl
This script shows the status of each po file in the current dir.
The translation status is given as a percentage.
=cut
## Output xml file for translation status
my $translation_file = "translations.xml";
## Country code to country name hash map
## Some contry codes may need to be filled.
my $country_hr = {
"az" => "Azerbaijani",
"br" => "Breton",
"bg" => "Bulgarian",
"ca" => "Catalan",
"cs" => "Czech",
"da" => "Danish",
"de" => "German",
"el" => "Greek",
"en_GB" => "British English",
"en_US" => "American English",
"eo" => "Esperanto",
"es" => "Spanish",
"et" => "Estonian",
"eu" => "Basque",
"fi" => "Finnish",
"fr" => "French",
"he" => "Hebrew",
"hr" => "Croatian",
"hu" => "Hungarian",
"is" => "Icelandic",
"it" => "Italian",
"ja" => "Japanese",
"ko" => "Korean",
"lt" => "Lithuanian",
"ms" => "Malay",
"mk" => "Macedonian",
"nl" => "Dutch",
"nn" => "Norwegian Nynorsk",
"no" => "Norwegian",
"pl" => "Polish",
"pt" => "Portuguese",
"pt_BR" => "Brazilian Portuguese",
"ro" => "Romanian",
"ru" => "Russian",
"sk" => "Slovak",
"sl" => "Slovenian",
"sr" => "Serbian",
"sv" => "Swedish",
"ta" => "Tamil",
"tr" => "Turkish",
"uk" => "Ukrainian",
"vi" => "Vietnamese",
"wa" => "Walloon",
"zh_CN.GB2312" => "Simplified Chinese",
"zh_CN" => "Simplified Chinese",
"zh_TW" => "Traditional Chinese"
};
my ($project_root) = @ARGV;
if (!defined ($project_root) || $project_root eq "") {
print STDERR "Error: No project\n";
exit(1);
}
if ($project_root !~ /^\//) {
print STDERR "Error: Project root is not absolute path\n";
exit(1);
}
unless (-d "$project_root/po") {
print STDERR "Error: Project does not have translations\n";
exit(1);
}
chdir("$project_root/po");
## Generate/update .pot file
system("intltool-update -p");
## Determine missing files.
system("intltool-update --maintain");
## Just take the first pot file found as the reference.
my $pot_file = glob("*.pot");
if ($pot_file eq "") {
print "There is no reference pot file in this directory.\n";
print "Make sure you are running status.pl in a po directory.\n";
print "...... Aborting.\n";
exit (1);
}
## the appname will be the name of the pot file
$appname = $pot_file;
while ($strip ne ".") {
$strip = chop ($appname);
}
## Determine the total messages available in this pot file.
my $output = `msgfmt --statistics $pot_file 2>&1`;
my @strs = split (", ", $output);
my ($pot_fuzzy, $pot_translated, $pot_untranslated) = (0,0,0);
foreach my $term (@strs) {
if ($term =~ /translated/) {
($pot_translated) = split (" ", $term);
} elsif ($term =~ /fuzzy/) {
($pot_fuzzy) = split (" ", $term);
} elsif ($term =~ /untranslated/) {
($pot_untranslated) = split (" ", $term);
}
}
my $total_messages = $pot_translated + $pot_fuzzy + $pot_untranslated;
print "\n";
print "\t\tTRANSLATION STATISTICS\n";
print "\t\tTotal messages: $total_messages\n\n";
print "\tTranslation status given in percentage.\n";
print "+----------------------------------------------------------------------------+\n";
printf ("| Po file | Language | Translated | Fuzzy | Untranslated |\n");
print "+----------------------------------------------------------------------------+\n";
my @po_files = glob("*.po");
my $date_time = gmtime(time());
foreach my $po_file (@po_files) {
if (-f $po_file) {
my $output = `msgfmt --statistics $po_file 2>&1`;
## print $output, "\n";
my ($translated, $fuzzy, $untranslated) = (0,0,0);
my @strs = split (", ", $output);
foreach my $coin (@strs) {
if ($coin =~ /\btranslated\b/) {
($translated) = split (" ", $coin);
} elsif ($coin =~ /\bfuzzy\b/) {
($fuzzy) = split (" ", $coin);
} elsif ($coin =~ /\buntranslated\b/) {
($untranslated) = split (" ", $coin);
}
}
$untranslated = $total_messages - ($translated + $fuzzy);
$untranslated *= 100/$total_messages;
$untranslated = ($untranslated < 0)? 0:$untranslated;
$untranslated = ($untranslated > 100)? 100:$untranslated;
$translated *= 100/$total_messages;
$translated = ($translated < 0)? 0:$translated;
$translated = ($translated > 100)? 100:$translated;
$fuzzy *= 100/$total_messages;
$fuzzy = ($fuzzy < 0)? 0:$fuzzy;
$fuzzy = ($fuzzy > 100)? 100:$fuzzy;
my $country_code = $po_file;
$country_code =~ s/\.po$//;
my $country = $country_hr->{$country_code};
$country = ($country ne "")? $country:"-";
printf ("|%10s |%21s | %6.2f ", $po_file, $country, $translated);
printf ("| %6.2f | %6.2f |\n", $fuzzy, $untranslated);
}
}
print "+----------------------------------------------------------------------------+\n";
__END__
|