diff --git a/module/custom/model.php b/module/custom/model.php index c6def684f5..ae2f629a47 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -45,7 +45,7 @@ class customModel extends model { if(isset($sectionLang[$customLang->module][$customLang->section]['all']) && isset($sectionLang[$customLang->module][$customLang->section][$currentLang]) && $customLang->lang == 'all') continue; - $sections = explode('.', $customLang->section); + $sections = explode('-', $customLang->section); $sectionIndex = count($sections) - 1; $sectionArr = array($customLang->key => $customLang->value); for($index = $sectionIndex; $index >= 0; $index --) $sectionArr = array($sections[$index] => $sectionArr); diff --git a/module/dev/control.php b/module/dev/control.php index 960de30b3e..b9441f8f12 100644 --- a/module/dev/control.php +++ b/module/dev/control.php @@ -120,8 +120,8 @@ class dev extends control $this->view->title = $this->lang->langItem; $this->view->type = $type; $this->view->featureBar = $this->lang->dev->featureBar['langItem']; - $this->view->originalLangs = $this->dev->getOriginalLang($type, $module, str_replace('_', '-', $language)); - $this->view->customedLangs = $this->dev->getCustomedLang($type, $module, str_replace('_', '-', $language)); + $this->view->originalLangs = $this->dev->getOriginalLang($type, $module, $method, $language); + $this->view->customedLangs = $this->dev->getCustomedLang($type, $module, $method, $language); $this->view->moduleName = $moduleName; $this->view->language = $language; $this->display(); diff --git a/module/dev/model.php b/module/dev/model.php index 42d5657139..7e53f8a9ff 100644 --- a/module/dev/model.php +++ b/module/dev/model.php @@ -1,6 +1,14 @@ app->getClientLang(); + + $defaultLang = $this->loadDefaultLang(); + if($type == 'feature') + { + $this->defaultLang = $defaultLang; + $defaultLang = $this->loadDefaultLang($clientLang, $module); + } + + $lang = new stdClass(); + $langKey = ''; if($type == 'common') { $projectKey = (int)$this->loadModel('setting')->getItem('owner=system&key=sprintConcept'); - $clientLang = $this->app->getClientLang(); $originalLangs['productCommon'] = $this->config->productCommonList[$clientLang][PRODUCT_KEY]; $originalLangs['projectCommon'] = $this->config->projectCommonList[$clientLang][PROJECT_KEY]; $originalLangs['executionCommon'] = $this->config->executionCommonList[$clientLang][$projectKey]; $originalLangs['URCommon'] = $this->lang->dev->UR; $originalLangs['SRCommon'] = $this->lang->dev->SR; } + elseif($type == 'feature') + { + $originalLangs = $defaultLang->$module->featureBar[$method]; + } + elseif($type == 'first') + { + $lang = $defaultLang->mainNav; + $langKey = 'mainMenu_'; + } + elseif($type == 'second') + { + $menus = new stdclass(); + if(isset($defaultLang->$module->homeMenu)) + { + foreach($defaultLang->$module->homeMenu as $menuKey => $menu) + { + $menuKey = 'homeMenu_' . $menuKey; + $menus->{$menuKey} = $menu; + } + } + + if(isset($defaultLang->$module->menu)) + { + foreach($defaultLang->$module->menu as $menuKey => $menu) + { + if(is_array($menu) and !isset($menu['link'])) continue; + + $newKey = 'menu_' . $menuKey; + $menus->{$newKey} = $menu; + + if(isset($menu['dropMenu'])) + { + foreach($menu['dropMenu'] as $menuKey => $menu) + { + $menuKey = 'dropMenu_' . $menuKey; + $menus->{$menuKey} = $menu; + } + } + } + } + $lang = $menus; + } + elseif($type == 'third') + { + $langKey = "{$module}SubMenu_menu_{$method}_"; + $lang = $defaultLang->$module->menu->$method['subMenu']; + } + + foreach($lang as $linkKey => $link) + { + if(is_array($link)) + { + if(!isset($link['link'])) continue; + $link = $link['link']; + } + + $link = strip_tags($link); + $link = explode('|', $link); + + if($type == 'second') $langKey = $module . 'Menu_' . $linkKey . '_'; + $originalLangs[$langKey . $linkKey] = trim($link[0]); + } return $originalLangs; } + /** + * Get customed lang. + * + * @param string $type + * @param string $module + * @param string $language + * @access public + * @return array + */ public function getCustomedLang($type, $module = '', $language = 'zh-cn') { $customedLangs = array(); @@ -331,18 +447,20 @@ class devModel extends model /** * Load default lang. * + * @param string $language + * @param string $module * @access public * @return object */ - public function loadDefaultLang($language = 'zh-cn') + public function loadDefaultLang($language = 'zh-cn', $module = 'common') { $clientLang = $this->app->clientLang; if($language != $clientLang) $this->app->clientLang = $language; - $langFilesToLoad = $this->app->getMainAndExtFiles('common'); + $langFilesToLoad = $this->app->getMainAndExtFiles($module); if($language != $clientLang) $this->app->clientLang = $clientLang; if(empty($langFilesToLoad)) return false; - $lang = new language(); + $lang = $module == 'common' ? new language() : $this->defaultLang; $lang->URCommon = $this->lang->URCommon; $lang->SRCommon = $this->lang->SRCommon; $lang->productCommon = $this->lang->productCommon;