]> git.lyx.org Git - lyx.git/blob - po/postats.sh
e8edea19fe1c0a842479ad20725716ba85ae1b85
[lyx.git] / po / postats.sh
1 #! /bin/sh
2
3 # file postats.sh
4 #
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7 #
8 # author: Michael Schmitt, michael.schmitt@teststep.org
9 #
10 # This script extracts some information from the po file headers (last
11 # translator, revision date), generates the corresponding gmo files
12 # to retrieve the number of translated/fuzzy/untranslated messages,
13 # and generates a PHP web page.
14 #
15 # Invocation:
16 #    postats.sh po_files > "pathToWebPages"/i18n.php3
17
18
19 # *** The PHP header ***
20
21 cat <<EOF
22 <?
23         // What's the title of the page?
24         \$title = "LyX i18n";
25         // What's the short name of the page in the navigation bar?
26         \$item="i18n";
27         // Who is the author?
28         \$author="Michael Schmitt";
29         // Full name of the file (relative path from LyX home page -- i.e., it should
30         // be "foo.php3" or "bar/foo.php3")
31         \$file_full="i18n.php3";
32
33         include("start.php3");
34
35         error_reporting(E_ALL);
36 ?>
37 EOF
38
39 # *** The po file analysis ***
40
41 echo "<?"
42 echo "\$podata = array ( "
43 first=true
44 for x
45 do
46         if [ $first = true ] ; then
47                 first=false ;
48         else
49                 echo ", " ;
50         fi
51         y=`basename $x .po`
52         echo "array ( 'langcode' => '$y', "
53         touch $x
54         make 2>&1 $y.gmo | grep "^[1-9]" |
55                 sed -e 's/\([0-9]*\) translated m[a-z]*[.,]/"msg_tr" => \1,/' |
56                 sed -e 's/\([0-9]*\) fuzzy t[a-z]*[.,]/"msg_fu" => \1,/' |
57                 sed -e 's/\([0-9]*\) untranslated m[a-z]*./"msg_nt" => \1,/'
58         # Format: "Last-Translator: Michael Schmitt <Michael.Schmitt@teststep.org>\n"
59         grep "Last-Translator" $x |
60                 sed -e 's/"Last-Translator: \(.*\)\( *\)<\(.*\)>\\n"/"translator" => "\1", "email" => "\3", /'
61         # Format: "PO-Revision-Date: 2003-01-18 03:00+0100\n"
62         grep "PO-Revision-Date" $x |
63                 sed -e 's/"PO-Revision-Date: \(.*\) .*/"date" => "\1" )/'
64 done
65 echo ");"
66 echo "?>"
67
68 # *** The PHP core part ***
69
70 cat <<EOF
71         <?
72                 \$lang = array(
73                                 'bg' => 'Bulgarian',
74                                 'ca' => 'Catalan',
75                                 'cs' => 'Czech',
76                                 'da' => 'Danish',
77                                 'de' => 'German',
78                                 'es' => 'Spanish',
79                                 'eu' => 'Basque',
80                                 'fi' => 'Finnish',
81                                 'fr' => 'French',
82                                 'he' => 'Hebrew',
83                                 'hu' => 'Hungarian',
84                                 'it' => 'Italian',
85                                 'nl' => 'Dutch',
86                                 'no' => 'Norwegian',
87                                 'pl' => 'Polish',
88                                 'pt' => 'Portuguese',
89                                 'ro' => 'Romanian',
90                                 'ru' => 'Russian',
91                                 'sk' => 'Slovak',
92                                 'sl' => 'Slovenian',
93                                 'sv' => 'Swedish',
94                                 'tr' => 'Turkish',
95                                 'wa' => 'Wallon'
96                              );
97
98                 \$noOfMsg = \$podata[0]['msg_tr'] + \$podata[0]['msg_fu'] + \$podata[0]['msg_nt'];
99
100                 function cmp (\$a, \$b) {
101                         if (\$a['msg_tr'] == \$b['msg_tr']) {
102                                 return 0;
103                         }
104                         return (\$a['msg_tr'] > \$b['msg_tr']) ? -1 : 1;
105                 }
106
107                 usort (\$podata, "cmp");
108         ?>
109
110         <p>
111                 The following table lists all translations available with the number of messages
112                 given for the LyX main development branch (currently 1.3.0cvs).
113                 Unfortunately, only a few languages are well-supported.
114                 For every release, the LyX development team may decide to exclude some of the
115                 translations from the distribution in order not to confuse the user by a strongly
116                 mixed-language interface.
117         </p>
118         <p>
119                 Explanation:
120                 <ul>
121                 <li><i>Translated:</i> The number of translated messages</li>
122                 <li><i>Fuzzy:</i> The number of fuzzy messages; these are not considered
123                     for LyX output but solely serve as a hint for the translators</li>
124                 <li><i>Untranslated:</i> The number of untranslated messages; the
125                     default language (i.e., English) will be used in the LyX outputs</li>
126                 </ul>
127         </p>
128         <table class="center" frame="box" rules="all" border="2" cellpadding="5">
129                 <thead>
130                         <tr>
131                                 <td>Language</td>
132                                 <td>Translated</td>
133                                 <td>Fuzzy</td>
134                                 <td>Untranslated</td>
135                                 <td>Revision Date</td>
136                                 <td>Translator</td>
137                         </tr>
138                 </thead>
139                 <tbody>
140                         <?
141                                 while (list(\$foo,\$info) = each(\$podata)) {
142                                         print "<tr>";
143
144                                         if ( \$info['msg_tr'] > \$noOfMsg * 2 / 3 ) {
145                                                 \$style="style='background:#009900'";
146                                         } else if ( \$info['msg_tr'] > \$noOfMsg / 2 ) {
147                                                 \$style="style='background:#AAAA00'";
148                                         } else {
149                                                 \$style="style='background:#AA3333'";
150                                         }
151
152                                         print "<td \$style>" . \$lang[\$info['langcode']] . "</td>";
153
154                                         print "<td \$style align=\"right\">" . \$info['msg_tr'] . "</td>";
155
156                                         print "<td \$style align=\"right\">";
157                                         if (isset(\$info['msg_fu'])) {
158                                                 print \$info['msg_fu'];
159                                         } else {
160                                                 print "0";
161                                         }
162                                         print "</td>";
163
164                                         print "<td \$style align=\"right\">";
165                                         if (isset(\$info['msg_nt'])) {
166                                                 print \$info['msg_nt'];
167                                         } else {
168                                                 print "0";
169                                         }
170                                         print "</td>";
171
172                                         print "<td \$style align=\"center\">" . \$info['date'] . "</td>";
173
174                                         print "<td \$style>";
175                                         if (\$info['email'] == "") {
176                                                 print \$info['translator'];
177                                         } else {
178                                                 print "<a href=\"mailto:" . \$info['email'] . "\">" .
179                                                       \$info['translator'] . "</a>";
180                                         }
181                                         print "</td>";
182
183                                         print "</tr>\n";
184                                 }
185                         ?>
186                 </tbody>
187         </table>
188 EOF
189
190 cat <<EOF
191         <?
192                 include("end.php3");
193         ?>
194 EOF