po_report.pl 6.16 KB
Newer Older
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
#!/usr/bin/perl
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4  -*-

#
#  The translation status from .po files
#
#  Copyright (C) 2005 Free Software Foundation.
#
#  Intltool is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License 
#  version 2 published by the Free Software Foundation.
#
#  Intltool 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#  As a special exception to the GNU General Public License, if you
#  distribute this file as part of a program that contains a
#  configuration script generated by Autoconf, you may include it under
#  the same distribution terms that you use for the rest of that program.
#
#  Authors: Bruno Coudoin <bruno.coudoin@free.fr>
#

use strict;

my %table_supported;		# Supported languages (more than 80% strings translated).
my %table_unsupported;		# Partially supported languages (between 50% and 80%).
my %table_partially;		# Unsupported languages (less than 50%).

# Update as needed
my %COUNTRY = (
38 39 40
	       'af' => 'Afrikaans',
	       'am' => 'Amharic',
	       'ang' => 'Old English',
41
	       'ar' => 'Arabic',
42
	       'as' => 'Assamese',
43
	       'az' => 'Azerbaijani',
44 45
	       'az_IR' => 'Iranian Azerbaijani',
	       'be' => 'Belarusian',
46 47
	       'bg' => 'Bulgarian',
	       'bn' => 'Bengali',
48
	       'br' => 'Breton',
49
	       'bs' => 'Bosnian',
50 51
	       'ca' => 'Catalan',
	       'cs' => 'Czech',
52
	       'cy' => 'Welsh',
53 54 55 56 57 58 59 60
	       'da' => 'Danish',
	       'de' => 'German',
	       'el' => 'Greek',
	       'en_AU' => 'Australian English',
	       'en_CA' => 'Canadian English',
	       'en_GB' => 'British English',
	       'eo' => 'Esperanto',
	       'es' => 'Spanish',
61
	       'et' => 'Estonian',
62
	       'eu' => 'Basque',
63
	       'fa' => 'Persian',
64 65
	       'fi' => 'Finnish',
	       'fr' => 'French',
66
	       'ga' => 'Irish Gaelic',
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
	       'gl' => 'Galician',
	       'gu' => 'Gujarati',
	       'he' => 'Hebrew',
	       'hi' => 'Hindi',
	       'hr' => 'Croatian',
	       'hu' => 'Hungarian',
	       'ia' => 'Interlingua',
	       'id' => 'Indonesian',
	       'is' => 'Icelandic',
	       'it' => 'Italian',
	       'ja' => 'Japanese',
	       'ka' => 'Georgian',
	       'kn' => 'Kannada',
	       'ko' => 'Korean',
	       'li' => 'Limburgish',
	       'lt' => 'Lithuanian',
	       'lv' => 'Latvian',
	       'mi' => 'Maori',
	       'mk' => 'Macedonian',
86
	       'ml' => 'Malayalam',
87 88 89 90 91 92 93
	       'mn' => 'Mongolian',
	       'mr' => 'Marathi',
	       'ms' => 'Malay',
	       'nb' => 'Norwegian Bookmal',
	       'ne' => 'Nepali',
	       'nl' => 'Dutch',
	       'nn' => 'Norwegian Nynorsk',
94 95
	       'nso' => 'Northern Sotho',
	       'or' => 'Oriya',
96 97 98 99 100 101
	       'pa' => 'Punjabi',
	       'pl' => 'Polish',
	       'pt' => 'Portuguese',
	       'pt_BR' => 'Brazilian Portuguese',
	       'ro' => 'Romanian',
	       'ru' => 'Russian',
102
	       'rw' => 'Kinyarwanda',
103 104 105 106 107 108 109 110
	       'sk' => 'Slovak',
	       'sl' => 'Slovenian',
	       'sq' => 'Albanian',
	       'sr' => 'Serbian',
	       'sr@Latn' => 'Serbian',
	       'sr@ije' => 'Serbian Jekavian',
	       'sv' => 'Swedish',
	       'ta' => 'Tamil',
111
	       'tg' => 'Tajik',
112 113 114 115
	       'th' => 'Thai',
	       'tk' => 'Turkmen',
	       'tr' => 'Turkish',
	       'uk' => 'Ukrainian',
116 117
	       'uz' => 'Uzbek',
	       'uz@Latn' => 'Uzbek Latin',
118 119 120 121 122 123 124 125
	       'vi' => 'Vietnamese',
	       'wa' => 'Wallon',
	       'xh' => 'Xhosa',
	       'yi' => 'Yiddish',
	       'yo' => 'Yoruba',
	       'zh_CN' => 'Chinese Simplified',
	       'zh_TW' => 'Chinese Traditional',
	       'zu' => 'Zulu',
126 127 128 129 130
	      );



print STDERR "Please WAIT, running 'cd po && ../intltool-update --report'\n";
131
my $report = `export LC_ALL=C && cd po && ../intltool-update --report 2>&1`;
132 133 134

#For test to speed up create a fixed report file with the previous command output
#my $report = `export LC_ALL=C && cd po && cat report`;
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

my @report_list = split("\n", $report);

foreach my $line (@report_list) {
  my ($locale) = $line =~ /(^[\w_\@]+):.*/;
  if ($locale) {
    my ($translated)    = $line =~ /.*: (\d+) translated messages.*/;
    my ($fuzzy)         = $line =~ /.*:.* (\d+) fuzzy translations.*/;
    my ($untranslated)  = $line =~ /.*:.* (\d+) untranslated messages.*/;
    if ($translated) {
      my $percent = int((100-($untranslated+$fuzzy)/($translated+$untranslated+$fuzzy)*100));
      $table_supported{$locale} = $percent if $percent >= 80;
      $table_partially{$locale} = $percent if $percent >= 50 and $percent < 80;
      $table_unsupported{$locale} = $percent if $percent < 50;
    }
  }
}

# Global counter for display_report
my $counter = 1;


sub display_report($$) {
  my $title = shift;
  my $table = shift;

  my $previous_value = -1;

  print "\n\n$title\n\n";

  foreach my $key (sort { $table->{$b} <=> $table->{$a} } keys %{$table}) {
    if ($previous_value != $table->{$key}) {
      printf("%6s. %-40s %10s%\n", $counter, "$COUNTRY{$key} ($key)", $table->{$key});
    } else {
      printf("%6s. %-40s %10s%\n", "", "$COUNTRY{$key} ($key)", $table->{$key});
    }
    $counter++;
    $previous_value = $table->{$key};
  }
}


# Statistics
# ----------

printf("Translated in %d languages\n\n",
       (scalar keys %table_supported) +
       (scalar keys %table_partially) +
       (scalar keys %table_unsupported));

printf("%60s %d\n", "Supported languages (more than 80% strings translated):",  (scalar keys %table_supported));
printf("%60s %d\n", "Partially supported languages (between 50% and 80%):",  (scalar keys %table_partially));
printf("%60s %d\n", "Unsupported languages (less than 50%):",  (scalar keys %table_unsupported));

# Detailled report
# ----------------
display_report("Supported languages (more than 80% strings translated).", \%table_supported);
display_report("Partially supported languages (between 50% and 80%).", \%table_partially);
display_report("Unsupported languages (less than 50%).", \%table_unsupported);