aboutsummaryrefslogtreecommitdiffstats
path: root/langs.php
blob: a106b15e04288a4f88fdb7f4f1e30af4dbdbeb3d (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
/**
*/

$g_app_root = realpath(dirname(__FILE__));
define('G_APP_ROOT', $g_app_root);

$g_donate_amount = '8800,62&nbsp;&euro;';

$G_coord_assos = <<<T
  Assocation Mageia.Org
  8B rue de la Terrasse
  75017 Paris
  France
T;
$G_coord_assos_bank = <<<T
  CIC Paris Villiers
  14 avenue de Villiers
  75017 Paris
  France

  IBAN: FR76 3006 6108 7600 0200 6450 123
  BIC:  CMCIFRPP
T;

require_once 'langs.inc.php';

$sru = trim($_SERVER['REQUEST_URI']);
$sel = explode('/', $sru);
array_shift($sel);
$locale = array_shift($sel);
$page   = count($sel) > 0 ? implode('/', $sel) : null;

$list_langs = array();
$options = array();

foreach ($langs as $k => $v)
{
    $list_langs[] = sprintf('<a href="/%s"%s>%s</a>',
        $page != null ? implode('/', array($k, $page)) : $k,
        $k == $locale ? ' class="sel"' : '',
        $v);

    $options[] = sprintf('<option value="%s"%s>%s</option>',
        $k,
        $k == $locale ? ' selected="selected"' : '',
        $v);
}

// prevent 404 error on /{$locale}/ with missing translation
function locale_path($path)
{
	$pathtofile = "/home/projects/mageia/public_html";
        $loc = $_SERVER['REQUEST_URI'];
        $filename = "$pathtofile$loc$path";
        $url = "/en/$path";
        if (file_exists($filename))
        {
                $url = "$loc$path";
        }
        return $url;
}

// global nav
$nav_list = array(
    "/{$locale}/" => 'Mageia',
    /*
    '/news' => 'News',
    '/downloads' => 'Downloads',
    '/comm' => 'Community',
    '/about' => 'About Us'
    */
    "http://blog.mageia.org/{$locale}" => array(
        'el' => 'Ιστολόγιο',
        'en' => 'Blog',
        'et' => 'Ajaveeb',
        'tr' => 'Web Günlüğü',
        'ru' => 'Блог'
    ),
    "/{$locale}/alpha/" => 'Alpha',
    //locale_path('alpha') => 'Alpha', 
    '/wiki/' => array(
        'en' => 'Wiki',
        'ru' => 'Вики'
    ),
    'http://forums.mageia.org/en/' => 'Forums',
    '/en/calendar/' => array(
        'de' => 'Kalender',
        'el' => 'Ημερολόγιο',
        'en' => 'Calendar',
        'es' => 'Calendario',
        'et' => 'Kalender',
        'fr' => 'Calendrier',
        'pl' => 'Kalendarz',
        'pt' => 'Calendário',
        'tr' => 'Takvim',
        'ro' => 'Calendar',
        'ru' => 'Календарь'
    ),
    /*
    "/{$locale}/faq/" => array(
    //locale_path('faq') => array(
        'en' => 'FAQ',
        'es' => 'Preguntas Frecuentes',
        'et' => 'KKK',
        'tr' => 'S.S.S.',
        'ro' => 'Întrebări frecvente'
    ),
    */
    //
    /*
    "http://mageia.org/wiki/doku.php?id=press" => array(
        'de' => 'Presse',
        'el' => 'Τύπος',
        'en' => 'Press',
        'es' => 'Prensa',
        'et' => 'Ajakirjandus',
        'fr' => 'Presse',
        'pl' => 'Prasa o nas ',
        'ro' => 'Presă',
        'ru' => 'Пресса',
        'tr' => 'Basın'
    ),
    */
    '/en/about/' => array(
        'en' => 'About',
        'fr' => 'À propos'
    ),
    "/{$locale}/donate/" => array(
    //locale_path('donate') => array(
    //"http://www.mageia.org/en/donate//{$locale}/" => array(
        'de' => 'Spenden',
        'el' => 'Δωρεές',
        'en' => 'Donations',
        'es' => 'Donaciones',
        'et' => 'Annetused',
        'fr' => 'Dons',
        'pl' => 'Dotacje',
        'pt' => 'Doações',
        'tr' => 'Bağışlar',
        'ro' => 'Donații',
        'ru' => 'Пожертвования'
    ),
        /*
    "/{$locale}/about/values" => array(
    //locale_path('about/values') => array(
        'de' => 'Werte',
        'el' => 'Αξίες',
        'en' => 'Values',
        'es' => 'Valores',
        'et' => 'Väärtused',
        'fr' => 'Valeurs',
        'pl' => 'Wartości',
        'pt' => 'Valores',
        'tr' => 'Değerler',
        'ro' => 'Valori',
        'ru' => 'Цели'
    ),
    "/{$locale}/about/code-of-conduct" => array(
    //locale_path('about/code-of-conduct') => array(
        'de' => 'Verhaltenskodex',
        'el' => 'Κώδικας συμπεριφοράς',
        'en' => 'Code of Conduct',
        'es' => 'Código de Conducta',
        'et' => 'Käitumisjuhised',
        'fr' => 'Code de conduite',
        'pl' => 'Kodeks postępowania',
        'pt' => 'Código de Conduta',
        'tr' => 'Temel İlkeler',
        'ro' => 'Codul de conduită',
        'ru' => 'Кодекс поведения'
    ),
    */
    //*/
);

$list_menu = array();
foreach ($nav_list as $k => $v)
{
    if (is_array($v))
        $title = array_key_exists($locale, $v) ? $v[$locale] : $v['en'];
    else
        $title = $v;

    $accessKey = null;
    if ($title == 'Mageia')
        $accessKey = ' accesskey="1"';

    $list_menu[] = sprintf('<a href="%s"%s%s>%s</a>',
        $k,
        $k == $sru ? ' class="sel"' : '',
        $accessKey,
        $title);
}

echo sprintf('<div class="nav"><!--googleoff: all--><div class="nav2"><p class="loc">%s</p>', implode(' | ', $list_menu));

$options = implode($options);
echo <<<H
<form id="lang_form" dir="ltr" method="get" action="/">
    <!--<label for="flang">Autres langues&nbsp;:</label>-->
    <input type="hidden" name="furl" value="{$_SERVER['REQUEST_URI']}" />
    <select id="flang" name="flang" dir="ltr" onchange="this.form.submit()">
        {$options}
    </select>
    <noscript><div><input type="submit" id="lang_submit" value="Hop!" /></div></noscript>
</form>
</div><!--googleon: all--></div>
H;
/*
echo sprintf('<p class="loc">%s</p>', implode(' | ', $list_langs));
*/