Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/po_report.pl
blob: 99f5e7ee721c4a1c1bb7325fbc8ce5ab12dc25c2 (plain)
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
# -*- 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 = (
	       'af' => 'Afrikaans',
	       'am' => 'Amharic',
	       'ang' => 'Old English',
	       'ar' => 'Arabic',
	       'as' => 'Assamese',
	       'az' => 'Azerbaijani',
	       'az_IR' => 'Iranian Azerbaijani',
	       'be' => 'Belarusian',
	       'bg' => 'Bulgarian',
	       'bn' => 'Bengali',
	       'br' => 'Breton',
	       'bs' => 'Bosnian',
	       'ca' => 'Catalan',
	       'cs' => 'Czech',
	       'cy' => 'Welsh',
	       'da' => 'Danish',
	       'de' => 'German',
	       'el' => 'Greek',
	       'en_AU' => 'Australian English',
	       'en_CA' => 'Canadian English',
	       'en_GB' => 'British English',
	       'eo' => 'Esperanto',
	       'es' => 'Spanish',
	       'et' => 'Estonian',
	       'eu' => 'Basque',
	       'fa' => 'Persian',
	       'fi' => 'Finnish',
	       'fr' => 'French',
	       'ga' => 'Irish Gaelic',
	       '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',
	       'ml' => 'Malayalam',
	       'mn' => 'Mongolian',
	       'mr' => 'Marathi',
	       'ms' => 'Malay',
	       'nb' => 'Norwegian Bookmal',
	       'ne' => 'Nepali',
	       'nl' => 'Dutch',
	       'nn' => 'Norwegian Nynorsk',
	       'nso' => 'Northern Sotho',
	       'or' => 'Oriya',
	       'pa' => 'Punjabi',
	       'pl' => 'Polish',
	       'pt' => 'Portuguese',
	       'pt_BR' => 'Brazilian Portuguese',
	       'ro' => 'Romanian',
	       'ru' => 'Russian',
	       'rw' => 'Kinyarwanda',
	       'sk' => 'Slovak',
	       'sl' => 'Slovenian',
	       'sq' => 'Albanian',
	       'sr' => 'Serbian',
	       'sr@Latn' => 'Serbian',
	       'sr@ije' => 'Serbian Jekavian',
	       'sv' => 'Swedish',
	       'ta' => 'Tamil',
	       'tg' => 'Tajik',
	       'th' => 'Thai',
	       'tk' => 'Turkmen',
	       'tr' => 'Turkish',
	       'uk' => 'Ukrainian',
	       'uz' => 'Uzbek',
	       'uz@Latn' => 'Uzbek Latin',
	       'vi' => 'Vietnamese',
	       'wa' => 'Wallon',
	       'xh' => 'Xhosa',
	       'yi' => 'Yiddish',
	       'yo' => 'Yoruba',
	       'zh_CN' => 'Chinese Simplified',
	       'zh_TW' => 'Chinese Traditional',
	       'zu' => 'Zulu',
	      );



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

#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`;

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);