Changeset 2178 in subversion


Ignore:
Timestamp:
Dec 18, 2008 1:04:51 PM (4 years ago)
Author:
thomasb
Message:

Use update_from_svn() to get localization files for stats;
Store stats file in (writeable) localization folder;
Increase cache time to 12 hours;
Some style tweaks

Location:
trunk/translator
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/translator/func.php

    r2173 r2178  
    4343                if ($fp && !$err && ($fl = @fopen(LANGDIR."$lang_prefix$file", 'w'))) 
    4444                { 
    45                         // echo '<div class="console">Update from SVN: '.$lang_dir.$file.'</div>'; 
     45                        echo '<!-- Update from SVN: ' . $lang_dir.$file . "-->\n"; 
    4646                        while (!feof($fp)) 
    4747                        { 
     
    131131} 
    132132 
    133 function count_lines($filename) 
     133function count_lines($lang, $file) 
    134134{ 
    135135        $count = 0; 
    136136        $lines = array(); 
    137137         
    138         if(file_exists($filename)) 
     138        if ($filename = update_from_svn($lang, $file)) 
    139139                $lines = file($filename); 
    140140         
     
    147147} 
    148148 
    149 function localization_stats() 
    150 { 
     149function localization_stats($force = false) 
     150{ 
     151        $cachefile = LANGDIR . 'langstats.txt'; 
    151152        // use saved file (cache) 
    152         if(file_exists('langstats.txt')) 
    153                 if(filemtime('langstats.txt') + 60*60*2 > time()) 
    154                         return file_get_contents('langstats.txt'); 
    155  
    156         $us_count = count_lines(LANGDIR.'/'.ORIGINAL.'/'.LABELS); 
    157         $us_count += count_lines(LANGDIR.'/'.ORIGINAL.'/'.MESSAGES); 
    158  
    159         include(LANGDIR.'/index.inc'); 
     153        if (!$force && file_exists($cachefile)) 
     154                if (filemtime($cachefile) + 60*60*12 > time()) 
     155                        return file_get_contents($cachefile); 
     156 
     157        $us_count = count_lines(ORIGINAL, LABELS); 
     158        $us_count += count_lines(ORIGINAL, MESSAGES); 
     159 
     160        include(LANGDIR . 'index.inc'); 
    160161         
    161162        $i = 0; 
     
    165166                        continue; 
    166167 
    167                 $count = count_lines(LANGDIR.'/'.$l_key.'/'.LABELS); 
    168                 $count += count_lines(LANGDIR.'/'.$l_key.'/'.MESSAGES); 
     168                $count = count_lines($l_key, LABELS); 
     169                $count += count_lines($l_key, MESSAGES); 
    169170                $percent = ($count * 100) / $us_count; 
    170171                 
     
    185186         
    186187        // save to cache file 
    187         file_put_contents('langstats.txt', $result); 
     188        file_put_contents($cachefile, $result); 
    188189         
    189190        return $result; 
  • trunk/translator/index.php

    r2173 r2178  
    116116        echo "\n</form></div>"; 
    117117} 
    118 else 
    119  
    120         echo '<div align="center">'.localization_stats().'</div>'; 
     118else if (empty($file)) 
     119{ 
     120        echo '<h4>Current completeness status</h4>'; 
     121        echo '<div>'.localization_stats().'</div>'; 
     122} 
    121123 
    122124?> 
  • trunk/translator/styles.css

    r2173 r2178  
    104104        width: 300px; 
    105105        border-collapse: collapse; 
    106         border: 1px #999 solid; 
     106        border: 1px #bbb solid; 
    107107} 
    108108 
     
    120120 
    121121td.zebra { 
    122         background-color: silver; 
     122        background-color: #eaeaea; 
    123123} 
    124124 
Note: See TracChangeset for help on using the changeset viewer.