/[web]/www/trunk/langs/report.php
ViewVC logotype

Contents of /www/trunk/langs/report.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3038 - (show annotations) (download)
Sat Feb 1 21:31:11 2014 UTC (10 years, 2 months ago) by filip
File size: 14736 byte(s)
report updated for mga4
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="robots" content="noindex,nofollow,nosnippet">
6 <title>www.mageia.org translation report</title>
7 <style>
8 html, body { margin: 0; padding: 0; font-family: Verdana, "Trebuchet MS", "Lucida Grande", "Lucida Sans", Verdana, Tahoma, Arial, sans-serif; }
9 #page { padding: 1em; position: absolute; top: 128px; }
10 th { text-align: left; }
11 .ok a {
12 text-decoration: none;
13 color: inherit;
14 }
15 .ok { color: darkgreen; background: lightgreen; }
16 .ok, .strings, .missing { text-align: center; }
17 .number { text-align: right; }
18 .strings { background: orange; }
19 .strings, .missing, .small { font-size: 80%; }
20 td, th { vertical-align: top; font-family: Arial; font-size: 80%; padding: 0.3em; }
21 td { vertical-align: middle; }
22 .action { font-size: smaller; display: block; text-align: center;
23 text-decoration: none; padding: 0.3em 0.5em; border-radius: 3px;
24 background: rgba(0, 0, 0, 0.1); margin: 0.5em 0; }
25 .partial { display: inline; margin-left: 0.3em; margin-top: 0.3em; }
26 .addlang { color: #333; }
27 </style>
28 </head>
29 <body class="contribute">
30 <header id="mgnavt">
31 <h1><a href="//www.mageia.org/">www.mageia.org</a> translation report</h1>
32 <ul>
33 <li>Please check <a href="https://wiki.mageia.org/en/Internationalisation_Team_(i18n)#Website_translation">localization Wiki page</a> for special cases for navigation and some web pages like <a href="https://wiki.mageia.org/en/Internationalisation_Team_%28i18n%29#Special_cases_of_web_pages">downloads/get, constitution, license...</a></li>
34 </ul>
35 </header>
36 <div id="page">
37 <?php
38 /**
39 */
40 include 'lib.php';
41 $one_language = isset($_GET['l']) ? strip_tags(trim($_GET['l'])) : null;
42 $one_resource = isset($_GET['r']) ? strip_tags(trim($_GET['r'])) : null;
43 define('APP_ROOT', realpath(__DIR__ . '/..'));
44
45 $restore_languages = FALSE;
46 $restore_resources = FALSE;
47
48 if (isset($one_resource) && $one_resource != 'all') {
49 $enFiles = array($one_resource);
50 $restore_resources = TRUE;
51 } else {
52 $enFiles = get_lang_references();
53 array_unshift($enFiles, '../_nav/langs/en.lang'); // added navigation file
54 }
55
56 if (isset($one_language) && $one_language != 'all') {
57 $otherLangs = array('en', $one_language);
58 $restore_languages = TRUE;
59 } else {
60 $otherLangs = get_other_langs();
61 }
62
63 $enStringsCount = array();
64 $report = array();
65 $stats = array();
66 $stats['en']['files'] = 0;
67 $num_of_col = 0;
68
69 $diff_link = '<a href="diff.php?s=%s&amp;l=%s" title="see detailed diff">';
70
71 $languages = array();
72 $unique_lines_in_eng_constitution = array();
73 $number_of_unique_lines_in_eng_constitution = 0;
74
75 foreach ($otherLangs as $l) {
76
77 $stats['en']['files'] += 1;
78 $stats[$l]['files'] = 0;
79 $stats[$l]['strings'] = 0;
80 if ($l == 'en' || $restore_languages) {
81 $link_one_language = '%s';
82 } else {
83 $link_one_language = '<a href="?l=' . $l . '" title="see this language only">%s</a>';
84 }
85
86 $s = sprintf('<tr><th>' . $link_one_language . '<br><span style="font-weight: normal; font-size: smaller;">%s</span></th>',
87 $langs[$l], $l);
88
89 $cols = '';
90 $lang_coloumn = '';
91
92 foreach ($enFiles as $f) {
93
94 $enStringsCount[$f] = 0;
95 if ($f == '../_nav/langs/en.lang') {
96 $nav = true;
97 } else {
98 $nav = false;
99 }
100
101 $langF = str_replace('.en.lang', '.' . $l . '.lang', $f);
102 if ($nav) {
103 $langF = '../_nav/langs/' . $l . '.lang';
104 } else {
105 $langF = $l . substr($langF, 2);
106 }
107 $link = str_replace(array('en/', '.en.lang', 'index'), '', $f);
108 if ($nav) {
109 $dest_en = sprintf('%s/%s/%s', APP_ROOT, '_nav/langs', 'en.lang');
110 $dest_l = sprintf('%s/%s/%s', APP_ROOT, '_nav/langs', $l . '.lang');
111 } else {
112 $dest_en = sprintf('%s/%s/%s/%s', APP_ROOT, 'en', $link, 'index.php');
113 $dest_l = sprintf('%s/%s/%s/%s', APP_ROOT, $l, $link, 'index.php');
114 }
115
116 // if symlink e.g. does directly translated page exist?
117 if ((realpath($dest_l) == realpath($dest_en)) || $nav) {
118 $page_not_linked = '';
119 $old_page = '';
120 } else {
121 $page_not_linked = sprintf('<a href="/%s/%s">old page</a> still exists!', $l, $link);
122 $old_page = sprintf('by recycling <a href="/%s/%s">old page</a>', $l, $link);
123 }
124
125 if (file_exists($langF)) {
126
127 $stats[$l]['files'] += 1;
128
129 $test = _lang_diff($f, $langF);
130 $num_of_untranslated_strings = count($test['notrans']);
131 $num_of_duplicated_strings = count($test['dup_str']);
132
133 if ($link == 'about/constitution') {
134 $constitution_results = aproximate_number_of_untranslated_constitution_lines(APP_ROOT, $l, $unique_lines_in_eng_constitution);
135 if ($l == 'en') {
136 $unique_lines_in_eng_constitution = $constitution_results['unique_lines_in_constitution'];
137 $number_of_unique_lines_in_eng_constitution = count($unique_lines_in_eng_constitution);
138 }
139 $test['a'] += $number_of_unique_lines_in_eng_constitution; // add aproximate number of lines from constitution to translate
140 $num_of_untranslated_strings += $constitution_results['aproximate_number_of_untranslated_lines'];
141 }
142 if ($link == 'about/license') {
143 require_once('../en/about/license/license.php');
144 $license_array = read_license_from_vcs($l);
145 $license_numbers = array_pop($license_array);
146 $test['a'] += $license_numbers["all"]; // add aproximate number of untranslated sentences from license
147 $num_of_untranslated_strings += $license_numbers["untran"]; // add number of all license sentences
148 }
149
150 if ($nav) {
151 $mga = array();
152 $local_f = @file_get_contents('../_nav/langs/' . $l . '.lang');
153 $mognas_f = @file_get_contents('http://nav.mageia.org/langs/' . $l . '.lang');
154 if ($local_f != $mognas_f) {
155 $page_not_linked = 'difference in svn <a class="action partial" href="//svnweb.mageia.org/web/www/trunk/_nav/langs/">1</a> &amp; <a class="action partial" href="//svnweb.mageia.org/web/nav/langs/">2</a>';
156 }
157 } else if ($link == 'downloads/get') {
158 $mga = array(
159 'view download OK page' => 'downloads/get/index.php?q=Mageia-2-dual-CD.iso&amp;d=1" style="display: block;',
160 'and non existing file too' => 'downloads/get/index.php?q=Non_existing_file&amp;d=1" style="display: block;',
161 );
162 } else if ($link == '2') {
163 $mga = array(
164 'A' => '2/index.php',
165 'B' => '2/download_index.php',
166 'C' => '2/for-pc/index.php',
167 'D' => '2/for-server/index.php',
168 );
169 } else if ($link == '3') {
170 $mga = array(
171 'A' => '3/index.php',
172 'B' => '3/download_index.php',
173 'C' => '3/for-pc/index.php',
174 'D' => '3/for-server/index.php',
175 );
176 } else if ($link == '4') {
177 $mga = array(
178 'A' => '4/index.php',
179 'B' => '4/download_index.php',
180 );
181 } else if ($link == 'documentation') {
182 $mga = array(
183 'doc' => 'doc/index.php',
184 'archive' => 'doc/archive.php',
185 );
186 } else {
187 $mga = array(
188 'view page' => $link,
189 );
190 }
191 $link = '<div>';
192 foreach ($mga as $k => $v) {
193 $link .= sprintf('<a href="/%s/%s" class="action partial">%s</a>', $l, $v, $k);
194 }
195 $link .= $page_not_linked . '</div>';
196
197 if (count($test['missing']) === 0
198 && $num_of_untranslated_strings === 0) {
199
200 $extra = null;
201 if (count($test['extra']) > 0) {
202 $extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '+' . count($test['extra']) . '</a></span>';
203 }
204 if ($num_of_duplicated_strings > 0) {
205 $extra .= ' <span class="small">' . sprintf($diff_link, $f, $l) . 'dup: ' . $num_of_duplicated_strings . '</a></span>';
206 }
207
208 $cols .= sprintf('<td class="ok"><a href="%s" title="get a copy of the file">OK</a>%s%s</td>',
209 $langF, $extra, $link);
210
211 $done = $test['a'];
212 } else {
213 // special case, en
214 if ($l == 'en') {
215 $cols .= '<td class="number">' . $num_of_untranslated_strings . ' strings</td>';
216 $enStringsCount[$f] += $test['a'];
217 $done = $test['a'];
218
219 // regular case
220 } else {
221
222 $cols .= sprintf('<td class="strings">' . $diff_link,
223 $f, $l);
224
225 if (count($test['missing']) > 0) {
226 $cols .= count($test['missing']) . '&nbsp;missing<br>';
227 }
228 if ($num_of_untranslated_strings > 0) {
229 $cols .= $num_of_untranslated_strings . '&nbsp;untranslated<br>';
230 }
231 if (count($test['extra']) > 0) {
232 $cols .= count($test['extra']) . '&nbsp;extra<br>';
233 }
234 if ($num_of_duplicated_strings > 0) {
235 $cols .= $num_of_duplicated_strings . '&nbsp;duplicate';
236 $cols .= ($num_of_duplicated_strings > 1 ? 's' : '');
237 }
238 $cols .= '</a>';
239 $cols .= $link . '</td>';
240 $done = $test['a'] - $num_of_untranslated_strings - count($test['missing']);
241 }
242 }
243 $stats[$l]['strings'] += $done;
244
245 } else {
246 $cols .= sprintf('<td class="missing"><a href="missing.php?s=%s&amp;l=%s" class="action addlang">add translation</a>%s</td>',
247 $f, $l, $old_page
248 );
249 }
250 $num_clmns_to_repeat = 9;
251 $num_of_col++;
252 if ($num_of_col % $num_clmns_to_repeat == 0 && $num_of_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) {
253 if ($l == 'en') {
254 $cols .= $lang_coloumn = '<td style="font-weight: bold;">Language</td>';
255 } else {
256 $cols .= $lang_coloumn = sprintf('<td style="font-weight: bold; vertical-align: top;">' . $link_one_language . '<br><span style="font-weight: normal; font-size: smaller;">%s</span></td>', $langs[$l], $l);
257 }
258 }
259 }
260 $cols .= $lang_coloumn; // last coloumn
261 $num_of_col = 0; // reset counter of coloumns
262
263 $progress = floor($stats[$l]['strings'] / $stats['en']['strings'] * 100);
264 // special case, en
265 if ($l == 'en') {
266 $s .= sprintf('<td class="number">%d strings</td>', $stats[$l]['strings']);
267 // regular case
268 } else {
269 $s .= sprintf(
270 '<td class="number">%d%%<br><span style="font-size: smaller;">%d / %d</span></td>',
271 $progress,
272 $stats[$l]['strings'],
273 $stats['en']['strings']
274 );
275 }
276 $s .= $cols;
277 $s .= '</tr>' . PHP_EOL;
278 $languages[$stats[$l]['strings'] . '-' . $l] = $s;
279 }
280 $en_language = array_shift($languages); // shift English for proper sorting
281 krsort($languages, SORT_NUMERIC);
282
283 // add language coloumn repeating
284 $lang_line = array();
285 $num_of_h_col = 0;
286 $add_last_coloumn = FALSE;
287 $resources = ($restore_resources ? '&nbsp;' : count($enFiles) . ' resources');
288 foreach ($enFiles as $lang_chunk) {
289 $num_of_h_col++;
290 if ($restore_resources) {
291 $lang_line[] = str_replace('en/', '', $lang_chunk);
292 } else {
293 $lang_line[] = '<a href="?r=' . $lang_chunk . '" title="see only this resource">' . str_replace('en/', '', $lang_chunk) . '</a>';
294 }
295 if ($num_of_h_col % $num_clmns_to_repeat == 0 && $num_of_h_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) {
296 $lang_line[] = $resources;
297 $add_last_coloumn = TRUE;
298 }
299 }
300 if ($add_last_coloumn) {
301 $lang_line[] = $resources;// last h coloumn
302 }
303
304 $thfiles = '<th>' . implode('</th><th>', $lang_line) . '</th>' . PHP_EOL;
305 if ($restore_languages) {
306 echo '<p>Restore <a href="?l=all" title="see all languages">all languages</a>.</p>';
307 $count = '&nbsp;';
308 } else {
309 $count = count($otherLangs) . ' languages';
310 }
311 if ($restore_resources) {
312 echo '<p>Restore <a href="?r=all" title="see all resources">all resources</a>.</p>';
313 }
314 $chunks = array_chunk($languages, $num_lines_to_repeat = 8); // add header repeating
315 $table_body = array();
316 foreach ($chunks as $chunk) {
317 $table_body = array_merge($table_body, $chunk, array(count($chunk) > ($num_lines_to_repeat / 2) ? '<tr><th>' . $count . '</th><th>' . $resources . '</th>' . $thfiles : ''));
318 }
319 array_unshift($table_body, $en_language); // unshift English back
320 $s = implode($table_body);
321
322
323 echo <<<S
324 <table border="1">
325 <thead><tr>
326 <th>{$count}</th>
327 <th>Progress</th>
328 {$thfiles}
329 </tr></thead>
330 <tbody>
331 {$s}
332 </tbody>
333 </table>
334
335 <hr>
336 S;
337 ?>
338 </div>
339 <script src="//nav.mageia.org/js/"></script>
340 </body>
341 </html>

  ViewVC Help
Powered by ViewVC 1.1.30