From a2a845a50b9f0537b5e2f7179cb646f2c23da1f7 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 3 Jul 2019 11:33:55 +0800 Subject: [PATCH] * adjust for build lang file. --- framework/router.class.php | 2 +- module/action/lang/zh-cn.php | 2 +- module/translate/model.php | 24 +++++++++++++++------ module/translate/view/choosemodule.html.php | 16 +++++++++++++- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/framework/router.class.php b/framework/router.class.php index eaf740558f..dae5246afe 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -21,7 +21,7 @@ include dirname(__FILE__) . '/base/router.class.php'; class router extends baseRouter { /** - * Add config langs. + * Add custom langs when set client lang. * * @param string $lang zh-cn|zh-tw|zh-hk|en * @access public diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 5666def159..665d1098c3 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -210,7 +210,7 @@ $lang->action->label->createchildren = "创建子任务"; $lang->action->label->managed = "维护"; /* 动态信息按照对象分组 */ -$lang->action->dynamicAction = new stdclass; +$lang->action->dynamicAction = new stdclass(); $lang->action->dynamicAction->todo['opened'] = '创建待办'; $lang->action->dynamicAction->todo['edited'] = '编辑待办'; $lang->action->dynamicAction->todo['erased'] = '删除待办'; diff --git a/module/translate/model.php b/module/translate/model.php index 4933fa3beb..8d0d61ce8e 100644 --- a/module/translate/model.php +++ b/module/translate/model.php @@ -152,6 +152,7 @@ class translateModel extends model { if(strpos($line, '$lang') === 0 and strpos($line, '=') !== false) { + if(strpos($line, '.=') !== false) continue; $position = strpos($line, '='); $key = trim(substr($line, 0, $position)); $value = trim(substr($line, $position + 1)); @@ -229,8 +230,14 @@ class translateModel extends model * @access public * @return int */ - public function getLangItemCount() + public function getLangItemCount($module = '') { + if(!empty($module)) + { + $items = $this->getModuleLangs($module, 'zh-cn'); + return count($items); + } + $moduleGroups = $this->getModules(); $moduleRoot = $this->app->getModuleRoot(); $itemCount = 0; @@ -455,7 +462,7 @@ class translateModel extends model $inFlow = false; foreach($flows as $flow) { - if(strpos($line, 'config->global->flow') !== false and strpos($line, $flow) === false) + if(strpos($line, 'config->global->flow') !== false and strpos($line, $flow) !== false) { $inFlow = true; break; @@ -481,7 +488,7 @@ class translateModel extends model { $content .= $line . "\n"; } - elseif($inFlow and strpos($line, '$lang') === 0 and strpos($line, '=') !== false) + elseif($inFlow and strpos($line, '$lang') === 0 and strpos($line, '=') !== false and strpos($line, '.=') === false) { $position = strpos($line, '='); $key = trim(substr($line, 0, $position)); @@ -493,7 +500,7 @@ class translateModel extends model { if(strpos($value, '.') === false) { - $value = '"' . addslashes($value) . '"'; + $value = "'" . addslashes($value) . "'"; } else { @@ -569,6 +576,10 @@ class translateModel extends model $content .= $line . "\n"; } } + else + { + $content .= $line . "\n"; + } } return $content; } @@ -583,8 +594,9 @@ class translateModel extends model public function checkNeedTranslate($value) { $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 strpos($value, '.') === false) $result = false; + $tolowerValue = strtolower($value); + if($tolowerValue == 'new stdclass()' or $tolowerValue == 'new stdclass') $result = false; + if(strpos($value, '$') === 0 and strpos($value, '$lang->productCommon') === false and strpos($value, '$lang->projectCommon') === false and strpos($value, '.') === false and !preg_match('/[^\$\-\>\w]/', $value)) $result = false; if($value == '$lang->productCommon' or $value == '$lang->projectCommon') $result = false; return $result; diff --git a/module/translate/view/choosemodule.html.php b/module/translate/view/choosemodule.html.php index 8e3c3cf937..271166d891 100644 --- a/module/translate/view/choosemodule.html.php +++ b/module/translate/view/choosemodule.html.php @@ -41,7 +41,21 @@ - + count = $this->translate->getLangItemCount($module); + } + else + { + $moduleStatistics = new stdclass(); + $moduleStatistics->count = $this->translate->getLangItemCount($module); + $moduleStatistics->translated = 0; + $moduleStatistics->changed = 0; + $moduleStatistics->reviewed = 0; + } + ?>