\n"; while (!feof($fp)) { $line = fgets($fp, 4096); if (trim($line) == "") $headers = false; if (!$headers) fwrite($fl, $line); } fclose($fp); fclose($fl); } } if (is_file(LANGDIR."$lang_prefix$file")) return LANGDIR."$lang_prefix$file"; else return false; } function lang_selection($lang) { include(update_from_svn('', 'index.inc')); $out = ""; return $out; } function build_localization($lang, $file) { global $orig_values, $edit_values; $array = $file == "messages.inc" ? '$messages' : '$labels'; $fpath = $lang != "_NEW_" ? update_from_svn($lang, $file) : 'nope'; if (!strstr($fpath, 'http') && !is_file($fpath)) $fpath = realpath("./$file"); $out = ""; if ($fpath && ($fp = fopen($fpath, 'r'))) { while (!feof($fp)) { $line = trim(fgets($fp)); if (empty($line) && empty($out)) continue; $out .= str_replace('#lang', $lang, $line) . "\n"; // reached begin of php array if (strstr($line, $array)) break; } } else { $out .= ' $t_value) { $t_value = get_input_value('t_'.$t_key, true); if (empty($t_value) && isset($edit_values[$t_key])) $t_value = $edit_values[$t_key]; if (!empty($t_value)) $out .= $array . "['$t_key'] = '" . addcslashes($t_value, "'") . "';\n"; } $out .= "\n?>\n"; return $out; } function count_lines($lang, $file) { $count = 0; $lines = array(); if ($filename = update_from_svn($lang, $file)) $lines = file($filename); // count lines starting with $ ($labels/$messages) foreach($lines as $line) if(strpos($line, '$') === 0) $count++; return $count; } function localization_stats($force = false) { $cachefile = LANGDIR . 'langstats.txt'; // use saved file (cache) if (!$force && file_exists($cachefile)) if (filemtime($cachefile) + 60*60*12 > time()) return file_get_contents($cachefile); $us_count = count_lines(ORIGINAL, LABELS); $us_count += count_lines(ORIGINAL, MESSAGES); include(LANGDIR . 'index.inc'); $i = 0; foreach ((array)$rcube_languages as $l_key => $l_value) { if ($l_key == ORIGINAL) continue; $count = count_lines($l_key, LABELS); $count += count_lines($l_key, MESSAGES); $percent = min(100, ($count * 100) / $us_count); $rows[] = sprintf("%s%.1f %%\n", ($i%2 ? ' zebra' : ''), htmlspecialchars($l_value), ($i%2 ? ' zebra' : ''), $percent); $i++; } // format output tables $result = '
'; for($i=0; $i