aboutsummaryrefslogtreecommitdiffstats
path: root/langs.php
blob: c971aecefb752e5914bf4f8ddaf7e652883230e4 (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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/**
*/

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

$g_donate_amount = 'EUR&nbsp;12 181.52';
$g_amount_remain = 'EUR&nbsp;8 600.98';

$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);
if (!isset($locale))
    $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;
}

$blog_link = 'http://blog.mageia.org/';
if (in_array($locale, array('de', 'el', 'en', 'es', 'fr', 'it', 'nl', 'pl', 'pt', 'ro', 'ru', 'tr')))
    $blog_link .= $locale . '/';

$forums_link = 'https://forums.mageia.org/';
// TODO pt, zh-tw, el
if (in_array($locale, array('fr', 'de', 'es', 'pt-br')))
    $forums_link .= $locale . '/';

// global nav
$nav_list = array(
    "/{$locale}/" => 'Mageia',
    "/{$locale}/1/" => '1',
    $blog_link => array(
        'el' => 'Ιστολόγιο',
        'en' => 'Blog',
        'et' => 'Ajaveeb',
        //'fr' => 'Actus',
        'pt' => 'Blogue',
        'pt-br' => 'Blog',
        'tr' => 'Web Günlüğü',
        'ru' => 'Блог',
        'tr' => 'Web Günlüğü'
    ),
    "/{$locale}/downloads/" => array(
        'de' => 'Herunterladen',
        'el' => 'Λήψεις',
        'en' => 'Downloads',
        'es' => 'Descargas',
        'et' => 'Allalaadimine',
        'fr' => 'Téléchargements',
        'it' => 'Scarica',
        'pt' => 'Transferências',
        'pt-br' => 'Downloads',
        'ro' => 'Descărcați',
        'ru' => 'Загрузить',
        'zh-tw' => '下載',
        'tr' => 'İndirmeler'
    ),
    "/{$locale}/support/" => array(
        'de' => 'Unterstützung',
        'el' => 'Υποστήριξη',
        'en' => 'Support',
        'es' => 'Soporte',
        'fr' => 'Assistance',
        'it' => 'Supporto',
        'pt' => 'Suporte',
        'pt-br' => 'Suporte',
        'ro' => 'Suport',
        'tr' => 'Destek'
    ),
    /*
    '/community/' => array(
        'en' => 'Community',
        'fr' => 'Communauté'
    ),
    */
    $forums_link => array(
        'el' => 'Φόρουμ',
        'en' => 'Forum',
        'es' => 'Foro',
        'pt' => 'Fórum',
        'pt-br' => 'Forum',
        'tr' => 'Forum'
    ),
    "/{$locale}/contribute/" => array(
        'de' => 'Mitwirken',
        'el' => 'Συνεισφέρετε',
        'en' => 'Contribute',
        'es' => 'Contribuir',
        'fr' => 'Contribuer',
        'it' => 'Contribuire',
        'pt' => 'Contribuir',
        'pt-br' => 'Contribuir',
        'ro' => 'Contribuiți',
        'tr' => 'Katkıda Bulunun'
    ),
    '/wiki/' => 'Wiki',
    'https://bugs.mageia.org/' => 'Bugzilla',
    /*
    '/en/calendar/' => array(
        'de' => 'Kalender',
        'el' => 'Ημερολόγιο',
        'en' => 'Calendar',
        'es' => 'Calendario',
        'et' => 'Kalender',
        'fr' => 'Calendrier',
        'pl' => 'Kalendarz',
        'pt' => 'Calendário',
        'tr' => 'Takvim',
        'ro' => 'Calendar',
        'ru' => 'Календарь'
    ),
    */
    /*
    "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'
    ),
    */
    "/{$locale}/donate/" => array(
        'de' => 'Spenden',
        'el' => 'Δωρεές',
        'en' => 'Donations',
        'es' => 'Donaciones',
        'et' => 'Annetused',
        'fr' => 'Dons',
        'it' => 'Donazioni',
        'pl' => 'Dotacje',
        'pt' => 'Doações',
        'pt-br' => 'Doações',
        'tr' => 'Bağışlar',
        'ro' => 'Donații',
        'ru' => 'Пожертвования',
        'tr' => 'Bağışlar'
    ),
    "/{$locale}/about/" => array(
        'de' => 'Über',
        'el' => 'Σχετικά',
        'en' => 'About',
        'es' => 'Acerca de',
        'fr' => 'À propos',
        'it' => 'A proposito di',
        'pt' => 'Acerca',
        'pt-br' => 'Acerca',
        'ro' => 'Despre noi',
        'tr' => 'Hakkında'
    ),
);

$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);
}

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

$options = implode($options);
$hsnav .= <<<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;

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

if (!defined('HLANG'))
    echo $hsnav;

/*
echo sprintf('<p class="loc">%s</p>', implode(' | ', $list_langs));
*/