diff options
Diffstat (limited to 'lib.php')
-rw-r--r-- | lib.php | 43 |
1 files changed, 39 insertions, 4 deletions
@@ -118,16 +118,51 @@ class l10n * * @return void */ - function load($lang) { - $lang_file = __DIR__ . '/langs/' . $lang . '.lang'; + function load($lang) + { + global $_t; + $_t = array(); + + if ($lang == 'en') + return; + + $lang_file = __DIR__ . '/langs/' . $lang . '.lang'; + $cache_file = __DIR__ . '/var/tmp/cache/nav_lang_' . $lang . '.php'; + $lang_ts = filemtime($lang_file); + + if (file_exists($cache_file)) { + include $cache_file; + if ($_ts > $lang_ts) + return; + } + if (file_exists($lang_file)) { - global $_t; + $f = file($lang_file); + foreach ($f as $k => $v) { - if (substr($v, 0, 1) == ';' && !empty($f[$k+1])) { + + if (substr($v, 0, 1) == ';' + && !empty($f[$k+1])) + { $_t[trim(substr($v, 1))] = trim($f[$k+1]); } } + + // + $_t_data = var_export($_t, true); + $cache = <<<P +<?php +/**! Generated. Do not edit. */ + +// filemtime($lang_file) +\$_ts = $lang_ts; + +// $lang strings +global \$_t; +\$_t = $_t_data; +P; + file_put_contents($cache_file, $cache); } } |