* Adjust language of router.
This commit is contained in:
@@ -1384,21 +1384,25 @@ class baseRouter
|
||||
$modulePath = $this->getModuleRoot($appName) . $moduleName . DS;
|
||||
if(is_dir($modulePath)) return $modulePath;
|
||||
|
||||
/* 2. 尝试查找商业版本是否有此模块。 Try to find the module in other editon. */
|
||||
/* 2. 尝试查找喧喧是否有此模块。 Try to find the module in xuan. */
|
||||
$modulePath = $this->getExtensionRoot() . 'xuan' . DS . $moduleName . DS;
|
||||
if(is_dir($modulePath)) return $modulePath;
|
||||
|
||||
/* 3. 尝试查找商业版本是否有此模块。 Try to find the module in other editon. */
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$modulePath = $this->getExtensionRoot() . $this->config->edition . DS . $moduleName . DS;
|
||||
if(is_dir($modulePath)) return $modulePath;
|
||||
}
|
||||
|
||||
/* 3. 如果设置过vision,尝试在vision中查找。 If vision is set, try to find the module in the vision. */
|
||||
/* 4. 如果设置过vision,尝试在vision中查找。 If vision is set, try to find the module in the vision. */
|
||||
if($this->config->vision != 'rnd')
|
||||
{
|
||||
$modulePath = $this->getExtensionRoot() . $this->config->vision . DS . $moduleName . DS;
|
||||
if(is_dir($modulePath)) return $modulePath;
|
||||
}
|
||||
|
||||
/* 4. 最后尝试在定制开发中寻找。 Finally, try to find the module in the custom dir. */
|
||||
/* 5. 最后尝试在定制开发中寻找。 Finally, try to find the module in the custom dir. */
|
||||
return $this->getExtensionRoot() . 'custom' . DS . $moduleName . DS;
|
||||
}
|
||||
}
|
||||
@@ -2394,6 +2398,48 @@ class baseRouter
|
||||
echo json_encode($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主语言文件。
|
||||
* Get main lang file.
|
||||
*
|
||||
* @param string $moduleName the module name
|
||||
* @param string $appName the app name
|
||||
* @access public
|
||||
* @return string.
|
||||
*/
|
||||
private function getMainLangFile($moduleName, $appName = '')
|
||||
{
|
||||
$path = $moduleName . DS . 'lang' . DS . $this->clientLang . '.php';
|
||||
|
||||
/* 1. 如果通用版本里有此模块,优先使用。 If module is in the open edition, use it. */
|
||||
$modulePath = $this->getModuleRoot($appName);
|
||||
if(file_exists($modulePath . $path)) return $modulePath . $path;
|
||||
|
||||
/* 2. 尝试查找喧喧是否有此模块。 Try to find the module in other editon. */
|
||||
$modulePath = $this->getExtensionRoot() . 'xuan' . DS;
|
||||
if(file_exists($modulePath . $path)) return $modulePath . $path;
|
||||
|
||||
/* 3. 尝试查找商业版本是否有此模块。 Try to find the module in other editon. */
|
||||
if($this->config->edition != 'open')
|
||||
{
|
||||
$modulePath = $this->getExtensionRoot() . $this->config->edition . DS;
|
||||
if(file_exists($modulePath . $path)) return $modulePath . $path;
|
||||
}
|
||||
|
||||
/* 4. 如果设置过vision,尝试在vision中查找。 If vision is set, try to find the module in the vision. */
|
||||
if($this->config->vision != 'rnd')
|
||||
{
|
||||
$modulePath = $this->getExtensionRoot() . $this->config->vision . DS;
|
||||
if(file_exists($modulePath . $path)) return $modulePath . $path;
|
||||
}
|
||||
|
||||
/* 5. 最后尝试在定制开发中寻找。 Finally, try to find the module in the custom dir. */
|
||||
$modulePath = $this->getExtensionRoot() . 'custom' . DS;
|
||||
if(file_exists($modulePath . $path)) return $modulePath . $path;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载语言文件,返回全局$lang对象。
|
||||
* Load lang and return it as the global lang object.
|
||||
@@ -2411,8 +2457,8 @@ class baseRouter
|
||||
$langFilesToLoad = array();
|
||||
|
||||
/* 判断主语言文件是否存在。Whether the main lang file exists or not. */
|
||||
$mainLangFile = $modulePath . 'lang' . DS . $this->clientLang . '.php';
|
||||
if(file_exists($mainLangFile)) $langFilesToLoad[] = $mainLangFile;
|
||||
$mainLangFile = $this->getMainLangFile($moduleName, $appName);
|
||||
if($mainLangFile) $langFilesToLoad[] = $mainLangFile;
|
||||
|
||||
/* 获取扩展语言文件。If extensionLevel > 0, get extension lang files. */
|
||||
if($this->config->framework->extensionLevel > 0)
|
||||
@@ -2424,6 +2470,7 @@ class baseRouter
|
||||
if($this->config->framework->extensionLevel >= 1)
|
||||
{
|
||||
if(!empty($extLangPath['common'])) $commonExtLangFiles = helper::ls($extLangPath['common'] . $this->clientLang, '.php');
|
||||
if(!empty($extLangPath['xuan'])) $commonExtLangFiles = helper::ls($extLangPath['xuan'] . $this->clientLang, '.php');
|
||||
if(!empty($extLangPath['vision'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['vision'] . $this->clientLang, '.php'));
|
||||
if(!empty($extLangPath['custom'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['custom'] . $this->clientLang, '.php'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user