Browse Source

REPORT-39341 【回归】文件没有读写权限报告弹窗是英文

修改解决方案:经过多位大佬提醒,最好不要直接修改传过来的Locale,因此转变思路为如果接收到了比较奇怪的Locale,尽量找到一个在本项目中使用的最接近的Locale返回,如传入参数为zh-Hans-CN时,返回zh_CN,而不是之前的en_US
feature/big-screen
Yvan 4 years ago
parent
commit
fe6973e495
  1. 8
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 18
      designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java

8
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -1424,11 +1424,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return * @return
*/ */
private Locale checkLocale(Locale locale) { private Locale checkLocale(Locale locale) {
// Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN,转成zh_CN // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN这种,需要找到项目中最匹配的Locale
if (locale != null) { return SupportLocale.getInstance().isSupport(locale) ?
locale = new Locale(locale.getLanguage(), locale.getCountry()); locale : SupportLocale.getInstance().getSuitableLocale(locale);
}
return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US;
} }
private void readReportLengthUnit(XMLableReader reader) { private void readReportLengthUnit(XMLableReader reader) {

18
designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java

@ -1,8 +1,6 @@
package com.fr.design; package com.fr.design;
import com.fr.invoke.Reflect;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock;
import java.util.Locale; import java.util.Locale;
@ -19,20 +17,4 @@ public class DesignerEnvManagerTest extends TestCase{
assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE); assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE);
} }
public void testCheckLocale() {
DesignerEnvManager envManager = EasyMock.createMock(DesignerEnvManager.class);
Reflect on = Reflect.on(envManager);
//验证zh-Hans-CN
Locale locale = Reflect.on(Locale.class).call("getInstance", "zh", "", "CN", "", null).get();
assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", locale).get());
//验证其它语言
assertEquals(Locale.SIMPLIFIED_CHINESE, on.call("checkLocale", Locale.SIMPLIFIED_CHINESE).get());
assertEquals(Locale.TRADITIONAL_CHINESE, on.call("checkLocale", Locale.TRADITIONAL_CHINESE).get());
assertEquals(Locale.US, on.call("checkLocale", Locale.US).get());
assertEquals(Locale.JAPAN, on.call("checkLocale", Locale.JAPAN).get());
assertEquals(Locale.KOREA, on.call("checkLocale", Locale.KOREA).get());
}
} }

Loading…
Cancel
Save