aboutsummaryrefslogtreecommitdiffstats
path: root/en/doc/doc.php
blob: 25dc0a742e3772ecc02da60cb9574ecd626e7c88 (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
<?php

$mga4_installer = array('ca','cs','de','el','en','eo','es','et','fr','id','nl','pl','pt_br','ro','ru','sv','tr','uk');
$mga4_control_center = array('de','en','et','fr','id','nl','ru','tr','uk');

$mga3_installer = array('de','el','en','es','et','fr','nl','pt_br','ru','uk');
$mga3_control_center = array('en','et','fr');

$mga2_installer = array('de','el','en','eo','fr','nl','pt_br','uk');

function doc_list($documentation_name, $languages, $link, $epub_link = null, $pdf_link = null)
{
    global $locale;
    global $langs;
    $your_language = '';
    $others = '';
    $text_others = '';
    $your_language_present = FALSE;
    $other_languages_present = FALSE;
    $table = PHP_EOL . '<table class="dlt2 dlinfo"  style="font-size: 10pt;">' . PHP_EOL;
//    $table .= '<thead><tr><th></th></tr></thead>';
    $table .= "\t<tbody>" . PHP_EOL;
    foreach ($languages as $lng) {
        // hopefully temporary exception for pt-br as convention for lang-abbrev in /langs.inc.php is different as link in doc.mageia.org
        if ($lng == 'pt_br') {
            $lng_name = $langs['pt-br'];
        } else if ($lng == 'sv') { // hopefully temporary exception for sv which does not exist yet in www.mageia.org
            $lng_name = 'Svenska';
        } else {
            $lng_name = $langs[$lng];
        }

        if ($locale == $lng) {
            $your_language_present = TRUE;
            if (is_null($epub_link) or is_null($pdf_link)) {
                $your_language = sprintf(_t('%s available in %s') . '<br/>%s',
                                        '<span style="font-weight:bold">' . $documentation_name . '</span>', $lng_name, sprintf($link, $lng));
            } else {
                $your_language = sprintf(_t('%s available in %s') . '<br/>%s <span style="font-size: 07pt;">('.
                                        _t('also as') . '%s , %s)</span>',
                                        '<span style="font-weight:bold">' . $documentation_name . '</span>',
                                        $lng_name, sprintf($link, $lng), sprintf($epub_link, $lng), sprintf($pdf_link, $lng));
            }
        } else {
            $other_languages_present = TRUE;
            if (is_null($epub_link) or is_null($pdf_link)) {
                $others[] = sprintf('%s<br/>%s', $lng_name, sprintf($link, $lng));
            } else {
                $others[] = sprintf('%s<br/>%s <span style="font-size: 07pt;">(%s , %s)</span>',
                $lng_name, sprintf($link, $lng), sprintf($epub_link, $lng), sprintf($pdf_link, $lng), sprintf($link, $lng));
            }
        }
    }
    if ($your_language_present) {
        $text_your_language = '<span style="font-weight:bold">' . _t('Documentation in your language:') . '</span><br/>';
        if ($other_languages_present) {
            $text_others = '<span style="font-weight:bold">' . _t('Other languages:') . '</span>';
        }
        $table .= sprintf("\t\t<tr><td>%s</td></tr>" . PHP_EOL .
                        "\t\t<tr><td>&nbsp;</td></tr>" . PHP_EOL .
                        "\t\t<tr><td>%s</td></tr>" . PHP_EOL,
                        $your_language, $text_others);
    } else {
        $text_your_language = _t('Please help <a href="../community/">us</a> translate it in your language.') . '<br/>';
        $table .= sprintf("\t\t<tr><td>%s</td></tr>" . PHP_EOL .
                        "\t\t<tr><td>%s</td></tr>" . PHP_EOL .
                        "\t\t<tr><td>&nbsp;</td></tr>" . PHP_EOL,
                        '<span style="font-weight:bold">' . $documentation_name . '</span>', $text_your_language);
    }
    foreach ($others as $other_languages) {
        $table .= sprintf("\t\t<tr><td>%s</td></tr>" . PHP_EOL, $other_languages);
    }
    $table .= "\t</tbody>" . PHP_EOL;
    $table .= "</table>" . PHP_EOL;

    echo $table;
}