Rev 211 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 211 | Rev 213 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | $encoding = 'UTF-8'; |
3 | $encoding = 'UTF-8'; |
4 | header("Content-Type: text/html" . ($encoding ? "; charset=$encoding" : "")); |
4 | header("Content-Type: text/html" . ($encoding ? "; charset=$encoding" : "")); |
5 | 5 | ||
6 | $modi = max(array( |
6 | $modi = max(array( |
7 | @filemtime(__FILE__), |
7 | @filemtime(__FILE__), |
8 | @filemtime('LocaleData'), |
8 | @filemtime('LocaleData'), |
9 | @filemtime('index.phtml'), |
9 | @filemtime('index.phtml'), |
10 | @filemtime('footer.phtml'), |
10 | @filemtime('footer.phtml'), |
11 | @filemtime('styles/lcars-basic.css'), |
11 | @filemtime('styles/lcars-basic.css'), |
12 | @filemtime('styles/lcars22.css'), |
12 | @filemtime('styles/lcars22.css'), |
13 | @filemtime('styles/lcars22-ie6.css'), |
13 | @filemtime('styles/lcars22-ie6.css'), |
14 | @filemtime('styles/lcars-ani.css'), |
14 | @filemtime('styles/lcars-ani.css'), |
15 | @filemtime('scripts/object.js'), |
15 | @filemtime('scripts/object.js'), |
16 | )); |
16 | )); |
17 | 17 | ||
18 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $modi) . ' GMT'); |
18 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $modi) . ' GMT'); |
19 | 19 | ||
20 | /* Cached resource expires in HTTP/1.1 caches 24h after last retrieval */
|
20 | /* Cached resource expires in HTTP/1.1 caches 24h after last retrieval */
|
21 | header('Cache-Control: max-age=86400, s-maxage=86400, must-revalidate, proxy-revalidate'); |
21 | header('Cache-Control: max-age=86400, s-maxage=86400, must-revalidate, proxy-revalidate'); |
22 | 22 | ||
23 | /* Cached resource expires in HTTP/1.0 caches 24h after last retrieval */
|
23 | /* Cached resource expires in HTTP/1.0 caches 24h after last retrieval */
|
24 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); |
24 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT'); |
25 | 25 | ||
26 | // $vulcan = 'x-vulcan-latin';
|
26 | // $vulcan = 'x-vulcan-latin';
|
27 | $vulcan = 'vuh-Latn-Gol-modern'; |
27 | $vulcan = 'vuh-Latn-Gol-modern'; |
28 | $languages = array( |
28 | $languages = array( |
29 | 'en' => 'English', |
29 | 'en' => 'English', |
30 | 'de' => 'Deutsch', |
30 | 'de' => 'Deutsch', |
31 | 'ru' => 'по-русски', |
31 | 'ru' => 'по-русски', |
32 | // 'x-klingon-latin' => array(
|
32 | // 'x-klingon-latin' => array(
|
33 | // 'key' => 'tlh',
|
33 | // 'key' => 'tlh',
|
34 | // 'name' => 'tlhIngan Hol'
|
34 | // 'name' => 'tlhIngan Hol'
|
35 | // ),
|
35 | // ),
|
36 | // $vulcan => array(
|
36 | // $vulcan => array(
|
37 | // 'key' => 'vu',
|
37 | // 'key' => 'vu',
|
38 | // 'name' => '<abbr title="Gen-lis">G-l</abbr> Vuhlkansu'
|
38 | // 'name' => '<abbr title="Gen-lis">G-l</abbr> Vuhlkansu'
|
39 | // )
|
39 | // )
|
40 | ); |
40 | ); |
41 | 41 | ||
42 | 42 | ||
43 | /**
|
43 | /**
|
44 | * Returns the short language key.
|
44 | * Returns the short language key.
|
45 | *
|
45 | *
|
46 | * Needed for safely mapping extra-terrestrial languages.
|
46 | * Needed for safely mapping extra-terrestrial languages.
|
47 | */
|
47 | */
|
48 | function language_key_short ($key) |
48 | function language_key_short ($key) |
49 | {
|
49 | {
|
50 | global $languages; |
50 | global $languages; |
51 | preg_match('/^[^-]{2,3}/', $key, $matches); |
51 | preg_match('/^[^-]{2,3}/', $key, $matches); |
52 | $language = $languages[$key]; |
52 | $language = $languages[$key]; |
53 | return isset($language['key']) ? $language['key'] : $matches[0]; |
53 | return (is_array($language) && isset($language['key']) |
- | 54 | ? $language['key'] |
|
- | 55 | : $matches[0]); |
|
54 | }
|
56 | }
|
55 | 57 | ||
56 | /**
|
58 | /**
|
57 | * Returns the language name.
|
59 | * Returns the language name.
|
58 | *
|
60 | *
|
59 | * Needed for safely mapping extra-terrestrial languages.
|
61 | * Needed for safely mapping extra-terrestrial languages.
|
60 | */
|
62 | */
|
61 | function language_name ($key) |
63 | function language_name ($key) |
62 | {
|
64 | {
|
63 | global $languages; |
65 | global $languages; |
64 | $language = $languages[$key]; |
66 | $language = $languages[$key]; |
65 | return isset($language['name']) ? $language['name'] : $language; |
67 | return (is_array($language) && isset($language['name']) |
- | 68 | ? $language['name'] |
|
- | 69 | : $language); |
|
66 | }
|
70 | }
|
67 | 71 | ||
68 | require_once 'Zend/Loader/StandardAutoloader.php'; |
72 | require_once 'Zend/Loader/StandardAutoloader.php'; |
69 | $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); |
73 | $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); |
70 | $loader->register(); |
74 | $loader->register(); |
71 | 75 | ||
72 | $translator = new Zend\I18n\Translator\Translator(); |
76 | $translator = new Zend\I18n\Translator\Translator(); |
73 | // $translator->setCache(new Zend\Cache\Storage\*Adapter());
|
77 | // $translator->setCache(new Zend\Cache\Storage\*Adapter());
|
74 | $type = 'gettext'; |
78 | $type = 'gettext'; |
75 | $baseDir = './i18n/LocaleData'; |
79 | $baseDir = './i18n/LocaleData'; |
76 | $textDomain = 'de.pointedears'; |
80 | $textDomain = 'de.pointedears'; |
77 | $pattern = "%s/LC_MESSAGES/{$textDomain}.mo"; |
81 | $pattern = "%s/LC_MESSAGES/{$textDomain}.mo"; |
78 | $translator->addTranslationFilePattern($type, $baseDir, $pattern, $textDomain); |
82 | $translator->addTranslationFilePattern($type, $baseDir, $pattern, $textDomain); |
79 | 83 | ||
80 | /**
|
84 | /**
|
81 | * Returns the translation of the parameter, if any,
|
85 | * Returns the translation of the parameter, if any,
|
82 | * using Zend Framework 2.1 Translate
|
86 | * using Zend Framework 2.1 Translate
|
83 | *
|
87 | *
|
84 | * @param string $s
|
88 | * @param string $s
|
- | 89 | * String to be translated
|
|
- | 90 | * @param string $lang = null
|
|
- | 91 | * Target language. The default is the document language
|
|
- | 92 | * ($language).
|
|
85 | * @return string
|
93 | * @return string
|
86 | */
|
94 | */
|
87 | function tr ($s, $lang = null) |
95 | function tr ($s, $lang = null) |
88 | {
|
96 | {
|
89 | global $translator; |
97 | global $translator; |
90 | global $textDomain; |
98 | global $textDomain; |
91 | global $language; |
99 | global $language; |
92 | 100 | ||
93 | if ($lang === null) |
101 | if ($lang === null) |
94 | {
|
102 | {
|
95 | $lang = $language; |
103 | $lang = $language; |
96 | }
|
104 | }
|
97 | 105 | ||
98 | /* DEBUG */
|
106 | /* DEBUG */
|
99 | // echo "return \$translator->translate(\"$s\", \"$textDomain\", \"$language\");<br>\n";
|
107 | // echo "return \$translator->translate(\"$s\", \"$textDomain\", \"$language\");<br>\n";
|
100 | 108 | ||
101 | return $translator->translate($s, $textDomain, $lang); |
109 | return $translator->translate($s, $textDomain, $lang); |
102 | }
|
110 | }
|
103 | 111 | ||
104 | $menu = array( |
112 | $menu = array( |
105 | 'scripts' => array('path' => 'scripts/', 'text' => tr('Scripting')), |
113 | 'scripts' => array('path' => 'scripts/', 'text' => tr('Scripting')), |
106 | 'es-matrix' => array( |
114 | 'es-matrix' => array( |
107 | 'path' => 'es-matrix', |
115 | 'path' => 'es-matrix', |
108 | 'text' => 'ES Matrix', |
116 | 'text' => 'ES Matrix', |
109 | 'title' => 'ECMAScript Support Matrix: ' . tr("A comparison of features of ECMAScript implementations") |
117 | 'title' => 'ECMAScript Support Matrix: ' . tr("A comparison of features of ECMAScript implementations") |
110 | ), |
118 | ), |
111 | 'devel' => array('path' => 'wsvn/', 'text' => tr('Software projects')), |
119 | 'devel' => array('path' => 'wsvn/', 'text' => tr('Software projects')), |
112 | 'series' => array('path' => "media/video/series/", 'text' => 'Seri-o-meter'), |
120 | 'series' => array('path' => "media/video/series/", 'text' => 'Seri-o-meter'), |
113 | 'ufpdb' => array( |
121 | 'ufpdb' => array( |
114 | 'path' => "ufpdb/index.$language", |
122 | 'path' => "ufpdb/index.$language", |
115 | 'text' => 'UFPDB', |
123 | 'text' => 'UFPDB', |
116 | 'title' => tr('United Federation of Planets DataBase') |
124 | 'title' => tr('United Federation of Planets DataBase') |
117 | )
|
125 | )
|
118 | ); |
126 | ); |
119 | 127 |