diff options
Diffstat (limited to 'translator')
| -rw-r--r-- | translator/func.php | 27 | ||||
| -rw-r--r-- | translator/index.php | 8 | ||||
| -rw-r--r-- | translator/styles.css | 4 |
3 files changed, 21 insertions, 18 deletions
diff --git a/translator/func.php b/translator/func.php index ec530f79c..fce85fa70 100644 --- a/translator/func.php +++ b/translator/func.php @@ -42,7 +42,7 @@ function update_from_svn($lang, $file) $headers = true; if ($fp && !$err && ($fl = @fopen(LANGDIR."$lang_prefix$file", 'w'))) { - // echo '<div class="console">Update from SVN: '.$lang_dir.$file.'</div>'; + echo '<!-- Update from SVN: ' . $lang_dir.$file . "-->\n"; while (!feof($fp)) { $line = fgets($fp, 4096); @@ -130,12 +130,12 @@ function build_localization($lang, $file) return $out; } -function count_lines($filename) +function count_lines($lang, $file) { $count = 0; $lines = array(); - if(file_exists($filename)) + if ($filename = update_from_svn($lang, $file)) $lines = file($filename); // count lines starting with $ ($labels/$messages) @@ -146,17 +146,18 @@ function count_lines($filename) return $count; } -function localization_stats() +function localization_stats($force = false) { + $cachefile = LANGDIR . 'langstats.txt'; // use saved file (cache) - if(file_exists('langstats.txt')) - if(filemtime('langstats.txt') + 60*60*2 > time()) - return file_get_contents('langstats.txt'); + if (!$force && file_exists($cachefile)) + if (filemtime($cachefile) + 60*60*12 > time()) + return file_get_contents($cachefile); - $us_count = count_lines(LANGDIR.'/'.ORIGINAL.'/'.LABELS); - $us_count += count_lines(LANGDIR.'/'.ORIGINAL.'/'.MESSAGES); + $us_count = count_lines(ORIGINAL, LABELS); + $us_count += count_lines(ORIGINAL, MESSAGES); - include(LANGDIR.'/index.inc'); + include(LANGDIR . 'index.inc'); $i = 0; foreach ((array)$rcube_languages as $l_key => $l_value) @@ -164,8 +165,8 @@ function localization_stats() if ($l_key == ORIGINAL) continue; - $count = count_lines(LANGDIR.'/'.$l_key.'/'.LABELS); - $count += count_lines(LANGDIR.'/'.$l_key.'/'.MESSAGES); + $count = count_lines($l_key, LABELS); + $count += count_lines($l_key, MESSAGES); $percent = ($count * 100) / $us_count; $rows[] = sprintf("<tr><td class=\"lang%s\">%s</td><td class=\"percent%s\">%.1f %%</td></tr>\n", @@ -184,7 +185,7 @@ function localization_stats() $result .= '</td></tr></table>'; // save to cache file - file_put_contents('langstats.txt', $result); + file_put_contents($cachefile, $result); return $result; } diff --git a/translator/index.php b/translator/index.php index 54253f8c1..9e033515c 100644 --- a/translator/index.php +++ b/translator/index.php @@ -115,9 +115,11 @@ if (isset($_POST["save"]) && $file && $lang) echo '<p><input id="hilight" class="button" type="button" value="Select all" onclick="javascript:this.form.text_area.focus();this.form.text_area.select();" /></p>'; echo "\n</form></div>"; } -else - - echo '<div align="center">'.localization_stats().'</div>'; +else if (empty($file)) +{ + echo '<h4>Current completeness status</h4>'; + echo '<div>'.localization_stats().'</div>'; +} ?> </div> diff --git a/translator/styles.css b/translator/styles.css index 49e884df5..e37211b73 100644 --- a/translator/styles.css +++ b/translator/styles.css @@ -103,7 +103,7 @@ table.stats td { table.langstats { width: 300px; border-collapse: collapse; - border: 1px #999 solid; + border: 1px #bbb solid; } td.lang { @@ -119,7 +119,7 @@ td.percent { } td.zebra { - background-color: silver; + background-color: #eaeaea; } /*****************/ |
