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