Merge branch 'master' of https://github.com/easysoft/zentaopms
This commit is contained in:
@@ -1 +0,0 @@
|
||||
td .item{float:left; margin-right:20px;}
|
||||
+102
-23
@@ -34,25 +34,7 @@ class translateModel extends model
|
||||
{
|
||||
$moduleName = basename($modulePath);
|
||||
$this->initModuleLang($moduleName, $data->code, $data->reference);
|
||||
|
||||
$mainLangFile = $modulePath . DS . 'lang' . DS . $data->reference . '.php';
|
||||
if(file_exists($mainLangFile))
|
||||
{
|
||||
$targetFile = $modulePath . DS . 'lang' . DS . $data->code . '.php';
|
||||
if(!copy($mainLangFile, $targetFile)) dao::$errors[] = sprintf($this->lang->translate->notice->failCopyFile, $mainLangFile, $targetFile);
|
||||
}
|
||||
|
||||
$extLangPath = $modulePath . DS . 'ext' . DS . 'lang' . DS . $data->reference;
|
||||
if(is_dir($extLangPath))
|
||||
{
|
||||
mkdir($modulePath . DS . 'ext' . DS . 'lang' . DS . $data->code);
|
||||
$extLangFiles = glob($extLangPath . DS . '*.php');
|
||||
foreach($extLangFiles as $extLangFile)
|
||||
{
|
||||
$targetFile = $modulePath . DS . 'ext' . DS . 'lang' . DS . $data->code . DS . basename($extLangFile);
|
||||
if(!copy($extLangPath, $targetFile)) dao::$errors[] = sprintf($this->lang->translate->notice->failCopyFile, $extLangFile, $targetFile);
|
||||
}
|
||||
}
|
||||
$this->buildLangFile($data->code, $moduleName, $data->reference);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -314,7 +296,7 @@ class translateModel extends model
|
||||
$moduleRoot = $this->app->getModuleRoot();
|
||||
$newLangFile = $moduleRoot . $module . "/lang/{$language}.php";
|
||||
$translations = $this->dao->select('*')->from(TABLE_TRANSLATION)->where('lang')->eq($language)->andWhere('module')->eq($module)->fetchGroup('mode', 'key');
|
||||
$newContent = "<?php\n";
|
||||
$newContent = "";
|
||||
|
||||
$mainReferLangFile = $moduleRoot . $module . "/lang/{$referLang}.php";
|
||||
if(file_exists($mainReferLangFile)) $newContent .= $this->getTranslatedLang($mainReferLangFile, $translations) . "\n";
|
||||
@@ -323,7 +305,35 @@ class translateModel extends model
|
||||
$extLangFiles = glob($moduleRoot . $module . "/ext/lang/{$referLang}/*.php");
|
||||
foreach($extLangFiles as $extLangFile) $newContent .= $this->getTranslatedLang($extLangFile, $translations) . "\n";
|
||||
}
|
||||
file_put_contents($newLangFile, $newContent);
|
||||
if(!empty($newContent))
|
||||
{
|
||||
$translateInfo = $this->getTranslateInfo($translations);
|
||||
$newContent = "<?php\n" . $translateInfo . $newContent;
|
||||
file_put_contents($newLangFile, $newContent);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTranslateInfo($translateGroups)
|
||||
{
|
||||
$translators = $reviewers = array();
|
||||
$lastReviewTime = '';
|
||||
foreach($translateGroups as $mode => $translatedItems)
|
||||
{
|
||||
foreach($translatedItems as $key => $translation)
|
||||
{
|
||||
$translators[$translation->translator] = $translation->translator;
|
||||
$reviewers[$translation->reviewer] = $translation->reviewer;
|
||||
if(empty($lastReviewTime)) $lastReviewTime = $translation->reviewTime;
|
||||
if($lastReviewTime < $translation->reviewTime) $lastReviewTime = $translation->reviewTime;
|
||||
}
|
||||
}
|
||||
|
||||
$translateInfo = "/**\n";
|
||||
$translateInfo .= " * Translators : " . join(' ', $translators) . "\n";
|
||||
$translateInfo .= " * Reviewers : " . join(' ', $reviewers) . "\n";
|
||||
$translateInfo .= " * Last Review Time : " . $lastReviewTime . "\n";
|
||||
$translateInfo .= " */\n";
|
||||
return $translateInfo;
|
||||
}
|
||||
|
||||
public function getTranslatedLang($referLang, $translations)
|
||||
@@ -392,7 +402,76 @@ class translateModel extends model
|
||||
$value = $translation->value;
|
||||
if($this->checkNeedTranslate($value) and strpos($value, 'array(') === false)
|
||||
{
|
||||
$value = '"' . addslashes($value) . '"';
|
||||
if(strpos($value, '.') === false)
|
||||
{
|
||||
$value = '"' . addslashes($value) . '"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts = explode('.', $value);
|
||||
$value = '';
|
||||
$isJoin = false;
|
||||
$preFirst = '';
|
||||
$preLast = '';
|
||||
foreach($parts as $part)
|
||||
{
|
||||
$part = trim($part);
|
||||
if(empty($part)) continue;
|
||||
|
||||
$firstLetter = $part{0};
|
||||
$lastLetter = $part{strlen($part) - 1};
|
||||
/* Item like "a" or 'b'. */
|
||||
if($firstLetter == $lastLetter and ($firstLetter == '"' or $firstLetter == "'"))
|
||||
{
|
||||
$isJoin = true;
|
||||
$value = empty($value) ? $part : $value . " . $part";
|
||||
}
|
||||
/* Item like $test or $test). */
|
||||
elseif($firstLetter != $lastLetter and $firstLetter == '$')
|
||||
{
|
||||
$isJoin = true;
|
||||
if($lastLetter == ')') $part = "'$part'";
|
||||
$value = empty($value) ? $part : $value . " . $part";
|
||||
}
|
||||
/* Item like <a href="www.baidu.com"> or $test . exec(). */
|
||||
elseif(($preLast and strpos('\'|"', $preLast) === false or $preFirst == '$') and strpos('\'|"', $firstLetter) === false)
|
||||
{
|
||||
if($preFirst == '$')
|
||||
{
|
||||
$isJoin = true;
|
||||
$value .= " . '" . addslashes($part) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$value .= '.' . $part;
|
||||
}
|
||||
}
|
||||
/* Item like "aaa" . exec() or $test . exec(). */
|
||||
elseif(($preLast and strpos('\'|"', $preLast) !== false or $preFirst == '$') and strpos('\'|"', $firstLetter) === false)
|
||||
{
|
||||
$isJoin = true;
|
||||
$value .= " . '" . addslashes($part) . "'";
|
||||
}
|
||||
/* Item like `echo test`. */
|
||||
elseif($firstLetter == $lastLetter and strpos('\'|"', $firstLetter) === false)
|
||||
{
|
||||
$value = empty($value) ? "'" . addslashes($part) . "'" : $value . " . '" . addslashes($part) . "'";
|
||||
}
|
||||
elseif($lastLetter == ')')
|
||||
{
|
||||
$part = "'" . addslashes($part) . "'";
|
||||
$value = empty($value) ? $part : $value . " . $part";
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = empty($value) ? $part : $value . ".$part";
|
||||
}
|
||||
|
||||
$preFirst = $firstLetter;
|
||||
$preLast = $lastLetter;
|
||||
}
|
||||
if(!$isJoin) $value = '"' . addslashes($value) . '"';
|
||||
}
|
||||
}
|
||||
$content .= $key . " = $value;\n";
|
||||
}
|
||||
@@ -409,7 +488,7 @@ class translateModel extends model
|
||||
{
|
||||
$result = true;
|
||||
if($value == 'new stdclass()') $result = false;
|
||||
if(strpos($value, '$') === 0 and strpos($value, '$lang->productCommon') === false and strpos($value, '$lang->projectCommon') === false and preg_match('/["\'] *\.[^\.]/', $value) == 0 and preg_match('/[^\.]\. *["\']/', $value) == 0) $result = false;
|
||||
if(strpos($value, '$') === 0 and strpos($value, '$lang->productCommon') === false and strpos($value, '$lang->projectCommon') === false and strpos($value, '.') === false) $result = false;
|
||||
if($value == '$lang->productCommon' or $value == '$lang->projectCommon') $result = false;
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -17,19 +17,23 @@
|
||||
</div>
|
||||
<table class='table table-bordered table-hover'>
|
||||
<thead>
|
||||
<tr>
|
||||
<tr class='text-center'>
|
||||
<th><?php echo $lang->translate->group;?></th>
|
||||
<th><?php echo $lang->dev->moduleList;?></th>
|
||||
<th class='text-left'><?php echo $lang->dev->moduleList;?></th>
|
||||
<th class='w-80px'><?php echo $lang->translate->allTotal;?></th>
|
||||
<th class='w-100px'><?php echo $lang->translate->translatedTotal;?></th>
|
||||
<th class='w-100px'><?php echo $lang->translate->changedTotal;?></th>
|
||||
<?php if($config->translate->needReview):?>
|
||||
<th class='w-100px'><?php echo $lang->translate->reviewedTotal;?></th>
|
||||
<?php endif;?>
|
||||
<th class='w-80px'><?php echo $lang->translate->translatedProgress;?></th>
|
||||
<?php if($config->translate->needReview):?>
|
||||
<th class='w-80px'><?php echo $lang->translate->reviewedProgress;?></th>
|
||||
<th class='w-80px'><?php echo $lang->actions;?></th>
|
||||
<?php endif;?>
|
||||
<th class='w-110px'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class='text-center'>
|
||||
<?php foreach($lang->dev->groupList as $group => $groupName):?>
|
||||
<?php if(!isset($modules[$group])) continue;?>
|
||||
<?php $i = 0;?>
|
||||
@@ -37,22 +41,28 @@
|
||||
<?php $moduleStatistics = $statistics[$module];?>
|
||||
<tr>
|
||||
<?php if($i == 0):?>
|
||||
<th rowspan='<?php echo count($modules[$group]);?>' class='w-100px text-top'>
|
||||
<div class='item'><?php echo $groupName;?></div>
|
||||
<th rowspan='<?php echo count($modules[$group]);?>' class='w-100px text-middle'>
|
||||
<div><?php echo $groupName;?></div>
|
||||
</th>
|
||||
<?php endif;?>
|
||||
<td><?php echo zget($lang->dev->tableList, $module, $module);?></td>
|
||||
<td class='text-center'><?php echo $moduleStatistics->count;?></td>
|
||||
<td class='text-center'><?php echo $moduleStatistics->translated + $moduleStatistics->reviewed;?></td>
|
||||
<td class='text-center'><?php echo $moduleStatistics->changed;?></td>
|
||||
<td class='text-center'><?php echo $moduleStatistics->reviewed;?></td>
|
||||
<td class='text-center'><?php echo (round(($moduleStatistics->translated + $moduleStatistics->reviewed) / $moduleStatistics->count, 3) * 100) . '%';?></td>
|
||||
<td class='text-center'><?php echo (round($moduleStatistics->reviewed / $moduleStatistics->count, 3) * 100) . '%';?></td>
|
||||
<td class='text-left'><?php echo zget($lang->dev->tableList, $module, $module);?></td>
|
||||
<td><?php echo $moduleStatistics->count;?></td>
|
||||
<td><?php echo $moduleStatistics->translated + $moduleStatistics->reviewed;?></td>
|
||||
<td><?php echo $moduleStatistics->changed;?></td>
|
||||
<?php if($config->translate->needReview):?>
|
||||
<td><?php echo $moduleStatistics->reviewed;?></td>
|
||||
<?php endif;?>
|
||||
<td><?php echo (round(($moduleStatistics->translated + $moduleStatistics->reviewed) / $moduleStatistics->count, 3) * 100) . '%';?></td>
|
||||
<?php if($config->translate->needReview):?>
|
||||
<td><?php echo (round($moduleStatistics->reviewed / $moduleStatistics->count, 3) * 100) . '%';?></td>
|
||||
<?php endif;?>
|
||||
<td>
|
||||
<div class='btn-group'>
|
||||
<?php
|
||||
if(common::hasPriv('translate', 'module')) echo html::a($this->createLink('translate', 'module', "language=$language&module=$module"), $lang->translate->common);
|
||||
if(common::hasPriv('translate', 'review') and $config->translate->needReview) echo html::a($this->createLink('translate', 'review', "language=$language&module=$module"), $lang->translate->review);
|
||||
if(common::hasPriv('translate', 'module')) echo html::a($this->createLink('translate', 'module', "language=$language&module=$module"), $lang->translate->common, '', "class='btn btn-sm'");
|
||||
if(common::hasPriv('translate', 'review') and $config->translate->needReview) echo html::a($this->createLink('translate', 'review', "language=$language&module=$module"), $lang->translate->review, '', "class='btn btn-sm'");
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $i++;?>
|
||||
|
||||
Reference in New Issue
Block a user