以下代码的前提: 按照 配置成功,并且成功汉化。
注意:由于cookie问题,可能无法彻底,所以有必要的时候要清空cookie.
editor.html
在关闭按钮代码后面加入:
1 2 3 4 5 6 7 8 |
<div class="btn-group pull-right" ng-show="!secondaryItems.length"> <div class="btn-toolbar pull-right" ng-controller="ToolbarController"> <button title="" ng-repeat="item in secondaryItems" ng-switch on="item.type" class="btn btn-inverse" ng-class="{'separator': item.type == 'separator'}" ng-disabled="item.type == 'separator'" onclick="switchLanauge()" id=""> 中/英 </button> </div> </div> |
在modeler.html的不加入js代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<script type="text/javascript"> designerLanauge = EDITOR.UTIL.getParameterByName('local'); if(typeof(designerLanauge)=="undefined"||designerLanauge==null||designerLanauge==""){ designerLanauge="zh"; } function switchLanauge() { if(designerLanauge=="en"){ //jQuery(jQuery(document.getElementById("designer-lanauge"))[0]).val("zh"); window.location.href="http://192.168.0.198:8082/PandyWebApp/modeler.html?modelId=8&local=zh"; }else { //jQuery(jQuery(document.getElementById("designer-lanauge"))[0]).val("en"); window.location.href="http://192.168.0.198:8082/PandyWebApp/modeler.html?modelId=8&local=en"; } } </script> |
在url-config.js修改代码:
1 2 3 4 |
getStencilSet: function() { //return ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now(); return ACTIVITI.CONFIG.contextRoot + '/editor/stencilsetLocal?local='+designerLanauge+'&version=' + Date.now(); } |
在oryx.debug.js修改代码:
1 2 3 4 5 6 7 8 9 10 11 12 |
if(ORYX.CONFIG.BACKEND_SWITCH) { this._baseUrl = "editor/stencilsets/bpmn2.0/"; this._source = "stencilsets/bpmn2.0/bpmn2.0.json"; //new Ajax.Request(ACTIVITI.CONFIG.contextRoot + '/editor/stencilset?version=' + Date.now(), { new Ajax.Request(ACTIVITI.CONFIG.contextRoot + '/editor/stencilsetLocal?local='+designerLanauge+'&version=' + Date.now(), { asynchronous: false, method: 'get', onSuccess: this._init.bind(this), onFailure: this._cancelInit.bind(this) }); } |
增加或者修改StencilsetRestResource.java, 增加一个方法:
1 2 3 4 5 6 7 8 9 |
@RequestMapping(value="/editor/stencilsetLocal", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public @ResponseBody String getStencilsetLocal(@RequestParam("local") String local) { InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("stencilset.json."+local); try { return IOUtils.toString(stencilsetStream, "utf-8"); } catch (Exception e) { throw new ActivitiException("Error while loading stencil set", e); } } |
修改app.js的代码
1 2 3 4 |
//$translateProvider.preferredLanguage('en'); //$translateProvider.preferredLanguage('zh'); $translateProvider.preferredLanguage(designerLanauge); console.log("选择语言:"+designerLanauge); |