Subversion Repositories LCARS

Rev

Rev 214 | 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';
227 PointedEar 27
$klingon = 'tlh-Latn';
210 PointedEar 28
$vulcan = 'vuh-Latn-Gol-modern';
63 PointedEar 29
$languages = array(
30
  'en' => 'English',
191 PointedEar 31
  'de' => 'Deutsch',
210 PointedEar 32
  'ru' => 'по-русски',
227 PointedEar 33
  $klingon => array(
34
    'key'  => 'tlh',
35
    'name' => 'tlhIngan Hol'
36
  ),
210 PointedEar 37
  $vulcan => array(
227 PointedEar 38
    'key' => 'vuh',
39
    'name' => 'Gen-lis Vuhlkansu'
210 PointedEar 40
  )
63 PointedEar 41
);
42
 
210 PointedEar 43
/**
44
 * Returns the short language key.
45
 *
46
 * Needed for safely mapping extra-terrestrial languages.
47
 */
48
function language_key_short ($key)
49
{
50
  global $languages;
51
  preg_match('/^[^-]{2,3}/', $key, $matches);
52
  $language = $languages[$key];
214 PointedEar 53
  return (is_array($language) && isset($language['key'])
54
    ? $language['key']
55
    : $matches[0]);
210 PointedEar 56
}
57
 
58
/**
59
 * Returns the language name.
60
 *
61
 * Needed for safely mapping extra-terrestrial languages.
62
 */
63
function language_name ($key)
64
{
65
  global $languages;
66
  $language = $languages[$key];
214 PointedEar 67
  return (is_array($language) && isset($language['name'])
68
    ? $language['name']
69
    : $language);
210 PointedEar 70
}
71
 
154 PointedEar 72
require_once 'Zend/Loader/StandardAutoloader.php';
73
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
74
$loader->register();
75
 
151 PointedEar 76
$translator = new Zend\I18n\Translator\Translator();
154 PointedEar 77
// $translator->setCache(new Zend\Cache\Storage\*Adapter());
151 PointedEar 78
$type = 'gettext';
189 PointedEar 79
$baseDir = './i18n/LocaleData';
137 PointedEar 80
$textDomain = 'de.pointedears';
191 PointedEar 81
$pattern = "%s/LC_MESSAGES/{$textDomain}.mo";
151 PointedEar 82
$translator->addTranslationFilePattern($type, $baseDir, $pattern, $textDomain);
63 PointedEar 83
 
151 PointedEar 84
/**
85
 * Returns the translation of the parameter, if any,
86
 * using Zend Framework 2.1 Translate
156 PointedEar 87
 *
151 PointedEar 88
 * @param string $s
214 PointedEar 89
 *   String to be translated
90
 * @param string $lang = null
91
 *   Target language.  The default is the document language
92
 *   ($language).
151 PointedEar 93
 * @return string
94
 */
210 PointedEar 95
function tr ($s, $lang = null)
141 PointedEar 96
{
151 PointedEar 97
  global $translator;
98
  global $textDomain;
99
  global $language;
170 PointedEar 100
 
210 PointedEar 101
  if ($lang === null)
102
  {
103
    $lang = $language;
104
  }
105
 
191 PointedEar 106
  /* DEBUG */
107
//   echo "return \$translator->translate(\"$s\", \"$textDomain\", \"$language\");<br>\n";
108
 
210 PointedEar 109
  return $translator->translate($s, $textDomain, $lang);
137 PointedEar 110
}
111
 
63 PointedEar 112
$menu = array(
210 PointedEar 113
  'scripts'   => array('path' => 'scripts/', 'text' => tr('Scripting')),
71 PointedEar 114
  'es-matrix' => array(
115
    'path'  => 'es-matrix',
116
    'text'  => 'ES Matrix',
151 PointedEar 117
    'title' => 'ECMAScript Support Matrix: ' . tr("A comparison of features of ECMAScript implementations")
71 PointedEar 118
  ),
210 PointedEar 119
  'devel'     => array('path' => 'wsvn/',   'text' => tr('Software projects')),
71 PointedEar 120
  'series'    => array('path' => "media/video/series/", 'text' => 'Seri-o-meter'),
121
  'ufpdb'     => array(
63 PointedEar 122
    'path'  => "ufpdb/index.$language",
123
    'text'  => 'UFPDB',
151 PointedEar 124
    'title' => tr('United Federation of Planets DataBase')
63 PointedEar 125
  )
140 PointedEar 126
);