aboutsummaryrefslogtreecommitdiffstats
path: root/langs/report.php
blob: 13de503a5a57273c3d1c37d1ea393274619e88f4 (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
<!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,
    .strings a,
    .missing 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 { vertical-align: top; }
    </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>
    <hr>
    <h2>Report</h2>
    <?php
    /**
    */
    include 'lib.php';

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

    $s = '';
    foreach ($enFiles as $f) {

        if (is_dir($f)) continue;
        
        $stats['en']['files'] += 1;

        $s .= sprintf('<tr><td><a href="%s">%s</a></td>',
            $f, $f);

        foreach ($otherLangs as $l) {

            $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']) . ' missing<br>';
                        }
                        if (count($test['notrans']) > 0) {
                            $s .= count($test['notrans']) . ' untranslated';
                        }
                        $s .= '</a></td>';
                    }
                }
                $stats[$l]['strings'] += $test['b'];

            } else {
                $stats[$l]['files'] += 0;
                $stats[$l]['strings'] += 0;
                $s .= '<td class="missing">missing</td>';
            }
        }
        $s .= '</tr>';
    }

    $th = '';
    array_shift($otherLangs);
    foreach ($otherLangs as $l) {
        $th .= '<th>' . $langs[$l] . '<br>' . $l . '</th>';
    }
    
    $ths = '';
    foreach ($stats as $l => $data) {
        if ($l == 'en') continue;
        $ths .= '<th>' . $data['files'] . ' / ' . $data['strings'] . '<br>' . round($data['strings'] / $stats['en']['strings'] * 100). '%</th>';
    }

    echo <<<S
<table border="1">
<thead>
    <tr>
        <th colspan="2">English</th>
        {$th}
        <th><a href="">How to add a new language</a></th>
    </tr>
    <tr>
        <th colspan="2">Reference</th>
    </tr>
    <tr>
        <th>{$stats['en']['files']} files</th>
        <th col="scol">{$stats['en']['strings']} strings</th>
        {$ths}
    </tr>
</thead>
<tbody>
{$s}
</tbody>
</table>

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