aboutsummaryrefslogtreecommitdiffstats
path: root/langs/report.php
blob: f0c7d13fcccb21260fc916d4826724b57a9517a3 (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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex,nofollow,nosnippet">
    <title>www.mageia.org translation report</title>
    <style>
    .ok a {
        text-decoration: none;
        color: inherit;
    }
    .ok { color: darkgreen; background: lightgreen; text-align: center; }
    .strings { background: orange; }
    .missing { background: darkorange; }
    .strings, .missing { font-size: 80%; }
    .number, .strings, .missing { text-align: right; }
    .small { font-size: 80%; }
    td, th { vertical-align: top; font-family: Arial; font-size: 80%; }
    .lv { display: inline-block; -webkit-transform: rotate(-40deg); }
    </style>
</head>
<body>
    <h1><a href="//www.mageia.org/">www.mageia.org</a> translation report</h1>
    <ul>
        <li>TODO article/link on the Wiki: How to translate this Web site?</li>
    </ul>
    <?php
    /**
    */
    include 'lib.php';

    $enFiles    = get_lang_references();
    $otherLangs = get_other_langs();
    
    echo '<p>', count($otherLangs), ' languages.</p>';
    
    $enStringsCount = array();
    $report         = array();
    $stats          = array();
    
    $diff_link      = '<a href="diff.php?s=%s&l=%s" title="see detailed diff">';

    foreach ($otherLangs as $l) {

        if (is_dir($f)) continue;

        $stats['en']['files'] += 1;

        $s .= sprintf('<tr><th>%s (%s)</th>',
            $langs[$l], $l);

        foreach ($enFiles as $f) {

            $langF = str_replace('.en.lang', '.' . $l . '.lang', $f);
            $langF = $l . substr($langF, 2);

            if (file_exists($langF)) {

                $stats[$l]['files'] += 1;

                $test = _lang_diff($f, $langF);

                if (count($test['missing']) === 0
                    && count($test['notrans']) === 0) {

                    $extra = null;
                    if (count($test['extra']) > 0) {
                        $extra = ' <span class="small">' . sprintf($diff_link, $f, $l) . '(+' . count($test['extra']) . ')</a></span>';
                    }

                    $s .= sprintf('<td class="ok"><a href="%s" title="get a copy of the file">OK</a>%s</td>',
                        $langF, $extra);
                }
                else {
                    // special case, en
                    if ($l == 'en') {
                        $s .= '<td class="number">' . count($test['notrans']) . ' strings</td>';
                        $enStringsCount[$f] += $test['a'];

                    // regular case
                    } else {

                        $s .= sprintf('<td class="strings">' . $diff_link,
                            $f, $l);

                        if (count($test['missing']) > 0) {
                            $s .= count($test['missing']) . '&nbsp;missing<br>';
                        }
                        if (count($test['notrans']) > 0) {
                            $s .= count($test['notrans']) . '&nbsp;untranslated';
                        }
                        $s .= '</a></td>';
                    }
                }
                $stats[$l]['strings'] += $test['b'];

            } else {
                $stats[$l]['files'] += 0;
                $stats[$l]['strings'] += 0;
                $s .= sprintf('<td class="missing"><a href="missing.php?s=%s&l=%s">add</a></td>',
                    $f, $l
                );
            }
        }
        
        $s .= sprintf(
            '<td class="number">%d / %d</td>
            <td class="number">%d%%</td>',
            $stats[$l]['strings'],
            $stats['en']['strings'],
            round($stats[$l]['strings'] / $stats['en']['strings'] * 100)
        );
        
        $s .= '</tr>';
    }

    $thfiles = '<th>' . implode('</th><th>', $enFiles) . '</th>';

    echo <<<S
<table border="1">
<thead><tr>
    <th>Language</th>
    {$thfiles}
    <th>Translated strings</th>
    <th>Completeness</th>
</tr></thead>
<tbody>
{$s}
</tbody>
</table>

<hr>
S;
?>
</body>
</html>