/[web]/nav/lib.php
ViewVC logotype

Diff of /nav/lib.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1305 by rda, Mon Jun 11 12:15:13 2012 UTC revision 1306 by rda, Mon Jun 11 12:15:14 2012 UTC
# Line 118  class l10n Line 118  class l10n
118       *       *
119       * @return void       * @return void
120      */      */
121      function load($lang) {      function load($lang)
122          $lang_file = __DIR__ . '/langs/' . $lang . '.lang';      {
123            global $_t;
124            $_t = array();
125    
126            if ($lang == 'en')
127                return;
128    
129            $lang_file  = __DIR__ . '/langs/' . $lang . '.lang';
130            $cache_file = __DIR__ . '/var/tmp/cache/nav_lang_' . $lang . '.php';
131            $lang_ts    = filemtime($lang_file);
132    
133            if (file_exists($cache_file)) {
134                include $cache_file;
135                if ($_ts > $lang_ts)
136                    return;
137            }
138    
139          if (file_exists($lang_file)) {          if (file_exists($lang_file)) {
140              global $_t;  
141              $f = file($lang_file);              $f = file($lang_file);
142    
143              foreach ($f as $k => $v) {              foreach ($f as $k => $v) {
144                  if (substr($v, 0, 1) == ';' && !empty($f[$k+1])) {  
145                    if (substr($v, 0, 1) == ';'
146                        && !empty($f[$k+1]))
147                    {
148                      $_t[trim(substr($v, 1))] = trim($f[$k+1]);                      $_t[trim(substr($v, 1))] = trim($f[$k+1]);
149                  }                  }
150              }              }
151    
152                //
153                $_t_data = var_export($_t, true);
154                $cache   = <<<P
155    <?php
156    /**! Generated. Do not edit. */
157    
158    // filemtime($lang_file)
159    \$_ts = $lang_ts;
160    
161    // $lang strings
162    global \$_t;
163    \$_t = $_t_data;
164    P;
165                file_put_contents($cache_file, $cache);
166          }          }
167      }      }
168    

Legend:
Removed from v.1305  
changed lines
  Added in v.1306

  ViewVC Help
Powered by ViewVC 1.1.30