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

$documentation['installer'     ][4] = array('ca','cs','de','el','en','eo','es','et','fr','id','nl','pl','pt_br','ro','ru','sv','tr','uk');
$documentation['control_center'][4] = array('en','et','ru','uk');

$documentation['installer'     ][3] = array('de','el','en','es','et','fr','nl','pt_br','ru','uk');
$documentation['control_center'][3] = array('en','et','fr');

$documentation['installer'     ][2] = array('de','el','en','eo','fr','nl','pt_br','uk');

function doc_list($documentation_name, $type, $version, $link, $epub_link = null, $pdf_link = null)
{
    global $locale;
    global $langs;
    global $documentation;
    preg_match("/(..)(-)(..)/", $locale, $parsed_locale);
    if(isset($parsed_locale[3])) { // create pt_br.po from pt-br and alike
        $link_locale = $parsed_locale[1] . '_' . $parsed_locale[3];
    } else {
        $link_locale = $locale;
    }
    $your_language = '';
    $others = '';
    $text_others = '';
    $your_language_present = FALSE;
    $other_languages_present = FALSE;
    $note_printed = FALSE;
    // temporary hidding of the EPUB and PDF links
    $hide_epub_pdf = TRUE;
    $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 ($documentation[$type][$version] 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 ($link_locale == $lng) {
            $your_language_present = TRUE;
            if (is_null($epub_link) or is_null($pdf_link) or $hide_epub_pdf) {
                $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) or $hide_epub_pdf) {
                $others[] = sprintf('%s<br/>%s', $lng_name, sprintf($link, $lng));
            } else {
                if(!$note_printed) {
                    $note = _t('also as');
                    $note_printed = TRUE;
                } else {
                    $note = '';
                }
                $others[] = sprintf('%s<br/>%s <span style="font-size: 07pt;">(%s%s , %s)</span>',
                $lng_name, sprintf($link, $lng), $note, 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 {
        foreach($documentation[$type] as $single_version => $all_languages) {
            if($single_version < $version && in_array($link_locale, $all_languages)) {
                $language_present_before = "\t\t<tr><td>" .
                    sprintf("Translation was present in %s before.<br/>Maybe you can check documentation for %s in Mageia %s.",
                            $langs[$locale], $documentation_name, $single_version) . "</td></tr>" . PHP_EOL;
                break;
            } else {
                $language_present_before = '';
            }
        }
        $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 . '%s' .
                        "\t\t<tr><td>&nbsp;</td></tr>" . PHP_EOL,
                        '<span style="font-weight:bold">' . $documentation_name . '</span>', $text_your_language, $language_present_before);
    }
    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;
}