Browse Source

Chinese translation for coverager

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@124 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
1.1
Xuefer 15 years ago
parent
commit
e96f9d50d0
  1. 5
      coverager/common-en.lang.php
  2. 25
      coverager/common-zh-simplified-utf-8.lang.php
  3. 75
      coverager/common.php
  4. 39
      coverager/config.php.example
  5. 7
      coverager/coverager.css
  6. 21
      coverager/coverager.php
  7. 35
      coverager/coverager.tpl.php

5
coverager/common-en.lang.php

@ -0,0 +1,5 @@
<?php
$GLOBALS['show_todo_strings'] = false;
?>

25
coverager/common-zh-simplified-utf-8.lang.php

@ -0,0 +1,25 @@
<?php
$strings = array(
'root'
=> '开始',
'Directory'
=> '目录',
'File'
=> '文件',
'Percent'
=> '覆盖率',
'Hits'
=> '命中',
'Lines'
=> '行数',
'TODO'
=> '闲置文件',
'XCache PHP Code Coverage Viewer'
=> 'XCache PHP 代码覆盖查看器',
'module'
=> '模块',
''
=> '',
);

75
coverager/common.php

@ -0,0 +1,75 @@
<?php
function get_language_file_ex($name, $l, $s)
{
static $map = array(
'zh' => 'zh-simplified',
'zh-hk' => 'zh-traditional',
'zh-tw' => 'zh-traditional',
);
if (isset($map[$l])) {
$l = $map[$l];
}
if (file_exists($file = "$name-$l-$s.lang.php")) {
return $file;
}
if (file_exists($file = "$name-$l.lang.php")) {
return $file;
}
return null;
}
function get_language_file($name)
{
global $charset, $lang;
$s = strtolower($charset);
if (isset($lang)) {
$file = get_language_file_ex($name, strtolower($lang), $s);
}
else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l) {
$l = strtok($l, ';');
$file = get_language_file_ex($name, $l, $s);
if (isset($file)) {
$lang = $l;
break;
}
if (strpos($l, '-') !== false) {
$ll = strtok($l, '-');
$file = get_language_file_ex($name, $ll, $s);
if (isset($file)) {
$lang = $l;
break;
}
}
}
}
return isset($file) ? $file : "$name-en.lang.php";
}
function _T($str)
{
if (isset($GLOBALS['strings'][$str])) {
return $GLOBALS['strings'][$str];
}
if (!empty($GLOBALS['show_todo_strings'])) {
return '<span style="color:red">' . htmlspecialchars($str) . '</span>';
}
return $str;
}
error_reporting(E_ALL);
define('REQUEST_TIME', time());
$charset = "UTF-8";
if (file_exists("./config.php")) {
include("./config.php");
}
include(get_language_file("common"));
if (!isset($lang)) {
$lang = 'en-us';
}
?>

39
coverager/config.php.example

@ -1,8 +1,16 @@
<?php
// should be named as config.php
// this is an example only
// write your own config and name it as config.php
// detected by browser
// $lang = 'en-us';
$charset = "UTF-8";
// developers only
$show_todo_strings = false;
// $include_paths = array("/www/my-php-project/");
// $exclude_paths = array("/www/my-php-project/tmp/");
$syntaxhiglight = true;
@ -12,8 +20,37 @@ $usecache = false;
function ob_filter_path_nicer($o)
{
$o = str_replace($_SERVER['DOCUMENT_ROOT'], "{DOCROOT}/", $o);
$xcachedir = realpath(dirname(__FILE__) . "/../");
$o = str_replace($xcachedir . "/", "{XCache}/", $o);
$o = str_replace("/home/", "{H}/", $o);
return $o;
}
// implement your auth here if needed
// {{{ home made login example
// this is an example only, it's won't work for you without your implemention.
function check_admin_auth()
{
require("/path/to/user-login-and-permission-lib.php");
session_start();
if (!user_logined()) {
if (!ask_the_user_to_login()) {
exit;
}
}
user_load_permissions();
if (!user_is_admin()) {
die("Permission denied");
}
return true;
}
// uncomment:
// check_admin_auth()
// }}}
?>

7
coverager/coverager.css

@ -1,8 +1,9 @@
h1 { text-align: center; }
input, table { font-family: monospace; font-size: 11px; }
table.cycles { border: 1px solid black; background: white; margin-top: 5px; margin-bottom: 5px; }
table.cycles .col1 { background-color: #f5f5f5; }
table.cycles .col2 { background-color: #e0e0e0; }
table.cycles th { background-color: #707090; color: white; font-weight: bold; height: 20px; line-height: 16px; font-family: serif; }
table.cycles th { background-color: #707090; color: white; font-weight: bold; height: 20px; line-height: 18px; font-family: serif; }
th a { color: white; font-weight: bold; display: block; width: 100%; height: 100%; }
.coverFile {
@ -33,7 +34,7 @@ th a { color: white; font-weight: bold; display: block; width: 100%; height: 100
position: absolute;
width: 100%;
}
.coverBarHi, .coverBarMed, .coverBarLo { left: 1px; top: 1px; }
.coverBarHi, .coverBarMed, .coverBarLo { left: 1px; top: 1px; height: 14px; }
.coverBarHi { background-color: #A7FC9D; }
.coverBarMed { background-color: #FFEA20; }
.coverBarLo { background-color: #FF0000; }
@ -55,3 +56,5 @@ pre.code {
white-space: pre;
border: 1px solid gray;
}
.footnote { text-align: right; font-size: 12px; }

21
coverager/coverager.php

@ -1,7 +1,6 @@
<?php
error_reporting(E_ALL);
define('REQUEST_TIME', time());
include("./common.php");
class Cycle
{
@ -40,20 +39,25 @@ class XcacheCoverageViewer
var $include_paths = array();
var $exclude_paths = array();
var $charset = 'UTF-8';
var $lang = 'en-us';
var $datadir = null;
var $datadir_len = null;
var $path = null;
var $outpath = null;
function XcacheCoverageViewer()
{
$this->datadir = ini_get('xcache.coveragedump_directory');
// copy config
foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', 'usecache', 'datadir') as $k) {
if (isset($GLOBALS['usecache'])) {
$this->{$k} = $GLOBALS['usecache'];
foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', 'usecache', 'datadir', 'lang') as $k) {
if (isset($GLOBALS[$k])) {
$this->{$k} = $GLOBALS[$k];
}
}
$this->datadir = preg_replace('!/$!', '', $this->datadir);
$this->datadir_len = strlen($this->datadir);
$this->datadir_len = strlen($this->datadir);
$this->path = isset($_GET['path']) ? $_GET['path'] : '';
$this->path = preg_replace('!\.{2,}!', '.', $this->path);
@ -124,6 +128,7 @@ class XcacheCoverageViewer
$action = "no data";
}
$xcache_version = XCACHE_VERSION;
include("coverager.tpl.php");
}
@ -303,10 +308,6 @@ function sprint_cov($cov, $lines, $encode = true)
return implode('', $lines);
}
if (file_exists("config.php")) {
include("config.php");
}
$app = new XcacheCoverageViewer();
$app->main();

35
coverager/coverager.tpl.php

@ -5,14 +5,16 @@
<?php
echo <<<HEAD
<meta http-equiv="Content-Type" content="text/html; charset=$this->charset" />
<meta http-equiv="Content-Language" content="{$this->lang}" />
<script type="text/javascript" src="tablesort.js" charset="$this->charset"></script>
HEAD;
?>
<link rel="stylesheet" type="text/css" href="coverager.css" />
<title>XCache Coverage Viewer</title>
<title><?php echo _T("XCache PHP Code Coverage Viewer"); ?></title>
</head>
<body>
<h1><?php echo _T("XCache PHP Code Coverage Viewer"); ?></h1>
<?php
function calc_percent($info, &$percent, &$class)
@ -48,10 +50,15 @@ function dir_head()
{
global $cycle;
$cycle = new Cycle('class="col1"', 'class="col2"');
$l_dir = _T("Directory");
$l_per = _T("Percent");
$l_hit = _T("Hits");
$l_lns = _T("Lines");
$l_tds = _T("TODO");
return <<<EOS
<table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles">
<tr>
<th>Directory</th><th>Percent</th><th>Hits</th><th>Lines</th><th>TODO</th>
<th>{$l_dir}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th><th>{$l_tds}</th>
</tr>
EOS;
}
@ -104,11 +111,15 @@ function file_head()
{
global $cycle;
$cycle = new Cycle('class="col1"', 'class="col2"');
$l_fil = _T("File");
$l_per = _T("Percent");
$l_hit = _T("Hits");
$l_lns = _T("Lines");
return <<<EOS
<br>
<table align="center" cellpadding="2" cellspacing="1" border="0" class="cycles">
<tr>
<th>File</th><th>Percent</th><th>Hits</th><th>Lines</th>
<th>{$l_fil}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th>
</tr>
EOS;
}
@ -153,10 +164,14 @@ function file_foot()
EOS;
}
$l_root = _T("root");
if ($action == 'dir') {
if (function_exists('ob_filter_path_nicer')) {
ob_start('ob_filter_path_nicer');
}
$path_html = htmlspecialchars($path);
echo <<<EOS
<a href="?">root</a> $path<br />
<a href="?">$l_root</a> $path<br />
EOS;
echo dir_head($dirinfo);
echo dir_row($dirinfo, $path);
@ -177,10 +192,13 @@ EOS;
}
}
else if ($action == 'file') {
if (function_exists('ob_filter_path_nicer')) {
ob_start('ob_filter_path_nicer');
}
$dir_url = urlencode($dir);
$dir_html = htmlspecialchars($dir);
echo <<<EOS
<a href="?">root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br />
<a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<b>{$filename}</b><br />
EOS;
echo file_head();
@ -193,6 +211,9 @@ EOS;
<a href="#tpl">{$tplfile_html}</a><br />
EOS;
}
if (function_exists('ob_filter_path_nicer')) {
ob_end_flush();
}
echo <<<EOS
<pre class="code"><ol>{$filecov}</ol></pre>
EOS;
@ -208,5 +229,9 @@ else {
}
?>
<div class="footnote">
Powered By: XCache <?php echo $xcache_version; ?> coverager <?php echo _T("module"); ?>
</div>
</body>
</html>

Loading…
Cancel
Save