Skip to content

Commit 19b7647

Browse files
author
杨利兵
committed
优化Msg翻译器
1 parent 92f5d91 commit 19b7647

File tree

5 files changed

+14
-54
lines changed

5 files changed

+14
-54
lines changed

src/com/yanglb/utilitys/codegen/core/translator/BaseMsgTranslator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ protected void onBeforeTranslate() throws CodeGenException {
3838
fileName = this.msgLang;
3939
} else {
4040
if(!this.isDefaultLanguage()) {
41-
fileName = fileName + "." + this.msgLang;
41+
fileName = fileName + this.getSplitString() + this.msgLang;
4242
}
4343
}
4444

4545
this.writableModel.setFileName(fileName);
4646
}
4747

48+
protected String getSplitString() {
49+
return ".";
50+
}
51+
4852
/**
4953
* 文件名,优先使用--fn参数指定的文件名,如不指定使用excel名称
5054
* @return 文件名

src/com/yanglb/utilitys/codegen/core/translator/impl/MsgCSTranslatorImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015 yanglb.com
2+
* Copyright 2020 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,9 @@ public class MsgCSTranslatorImpl extends BaseMsgTranslator {
2626
@Override
2727
protected void onBeforeTranslate() throws CodeGenException {
2828
super.onBeforeTranslate();
29+
2930
this.writableModel.setExtension("resx");
31+
this.writableModel.setFilePath("msg/resx");
3032
}
3133

3234
@Override

src/com/yanglb/utilitys/codegen/core/translator/impl/MsgJavaTranslatorImpl.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,15 @@
2323
import com.yanglb.utilitys.codegen.utility.StringUtility;
2424

2525
public class MsgJavaTranslatorImpl extends BaseMsgTranslator {
26-
protected String msgLang = "";
27-
26+
@Override
27+
protected String getSplitString() {
28+
return "_";
29+
}
30+
2831
@Override
2932
protected void onBeforeTranslate() throws CodeGenException {
3033
super.onBeforeTranslate();
3134

32-
// 当前生成的国际化语言
33-
this.msgLang = this.settingMap.get("MsgLang");
34-
35-
// 文件名
36-
String fileName = getFileName();
37-
if (fileName.equals("")) {
38-
// 空文件名
39-
fileName = this.msgLang;
40-
} else {
41-
if(!this.msgLang.equals("default")) {
42-
fileName = fileName + "_" + this.msgLang;
43-
}
44-
}
45-
46-
this.writableModel.setFileName(fileName);
4735
this.writableModel.setExtension("properties");
4836
this.writableModel.setFilePath("msg/properties");
4937
}

src/com/yanglb/utilitys/codegen/core/translator/impl/MsgJsTranslatorImpl.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,10 @@
2323
import com.yanglb.utilitys.codegen.utility.StringUtility;
2424

2525
public class MsgJsTranslatorImpl extends BaseMsgTranslator {
26-
protected String msgLang = "";
27-
2826
@Override
2927
protected void onBeforeTranslate() throws CodeGenException {
3028
super.onBeforeTranslate();
31-
32-
// 当前生成的国际化语言
33-
this.msgLang = this.settingMap.get("MsgLang");
34-
35-
// 文件名
36-
String fileName = getFileName();
37-
if (fileName.equals("")) {
38-
// 空文件名
39-
fileName = this.msgLang;
40-
} else {
41-
if(!this.msgLang.equals("default")) {
42-
fileName = fileName + "." + this.msgLang;
43-
}
44-
}
45-
46-
this.writableModel.setFileName(fileName);
29+
4730
this.writableModel.setExtension("js");
4831
this.writableModel.setFilePath("msg/js");
4932
}

src/com/yanglb/utilitys/codegen/core/translator/impl/MsgJsonTranslatorImpl.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,10 @@
2323
import com.yanglb.utilitys.codegen.utility.StringUtility;
2424

2525
public class MsgJsonTranslatorImpl extends BaseMsgTranslator {
26-
protected String msgLang = "";
27-
2826
@Override
2927
protected void onBeforeTranslate() throws CodeGenException {
3028
super.onBeforeTranslate();
3129

32-
// 当前生成的国际化语言
33-
this.msgLang = this.settingMap.get("MsgLang");
34-
35-
// 文件名
36-
String fileName = getFileName();
37-
if (fileName.equals("")) {
38-
// 空文件名
39-
fileName = this.msgLang;
40-
} else {
41-
if(!this.msgLang.equals("default")) {
42-
fileName = fileName + "." + this.msgLang;
43-
}
44-
}
45-
46-
this.writableModel.setFileName(fileName);
4730
this.writableModel.setExtension("json");
4831
this.writableModel.setFilePath("msg/json");
4932
}

0 commit comments

Comments
 (0)