Browse Source

CORE-116 国际化拆分设计器、服务器和web

final/10.0
richie 6 years ago
parent
commit
3317c4604f
  1. 6
      designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java
  2. 29
      designer-base/src/main/java/com/fr/design/i18n/Toolkit.java
  3. 11
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  4. 19
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

6
designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java

@ -123,11 +123,13 @@ public class LocalePane extends BasicPane {
Map<Locale, String> supportLocaleMap = InterProviderFactory.getProvider().getSupportLocaleMap();
Map<String, String> map;
// richie:暂时去掉设计器中国际化键值对的显示
Map<String, String> map = new HashMap<>();
List<String> sortKeys = new ArrayList<String>();
map = InterProviderFactory.getProvider().getLocalBundle(Locale.SIMPLIFIED_CHINESE).getMap();
//map = InterProviderFactory.getProvider().getLocalBundle(Locale.SIMPLIFIED_CHINESE).getMap();
sortKeys.addAll(map.keySet());
Collections.sort(sortKeys);

29
designer-base/src/main/java/com/fr/design/i18n/Toolkit.java

@ -1,25 +1,41 @@
package com.fr.design.i18n;
import com.fr.general.GeneralContext;
import com.fr.general.log.MessageFormatter;
import com.fr.locale.InterProviderFactory;
import com.fr.locale.LocaleManager;
import com.fr.locale.impl.FineLocaleManager;
/**
* 设计器国际化类后面会不再依赖InterProviderFactory
*/
public class Toolkit {
private static LocaleManager localeManager = FineLocaleManager.create();
static {
addResource("com/fr/design/i18n/main");
}
public static void addResource(String path) {
localeManager.addResource(path);
}
/**
* 设计器国际化方法
*
* @param key 国际化键
* @return 国际化值
*/
public static String i18nText(String key) {
return InterProviderFactory.getProvider().getLocText(key);
return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, key);
}
/**
* 带格式化内容的国际化方法
* Toolkit.i18nText("Fine-Design_xxx", 1, 2)假设Fine-Design_xxx的中文值为我来计算{}+{}输出结果为我来计算1+2
*
* @param key 格式化文本
* @param args 格式化参数
* @return 国际化值
@ -27,22 +43,15 @@ public class Toolkit {
public static String i18nText(String key, Object... args) {
String format = InterProviderFactory.getProvider().getLocText(key);
MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(format, args);
return tuple.getMessage();
return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, tuple.getMessage());
}
/**
* 太鸡儿多了改不完先加上慢慢改
*
* @deprecated
*/
public static String i18nTextArray(String[] keys) {
return InterProviderFactory.getProvider().getLocText(keys);
}
/**
* 太鸡儿多了改不完先加上慢慢改
* @deprecated
*/
public static String i18nTextArray(String[] keys, String[] delimiter) {
return InterProviderFactory.getProvider().getLocText(keys, delimiter);
}
}

11
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -11,7 +11,11 @@ import com.fr.design.module.ChartHyperlinkGroup;
import com.fr.design.module.ChartPreStyleAction;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartEditor;
import com.fr.locale.InterMutableKey;
import com.fr.locale.LocaleMarker;
import com.fr.locale.LocaleScope;
import com.fr.module.Activator;
import com.fr.module.extension.Prepare;
import com.fr.plugin.chart.vanchart.imgevent.design.DesignImageEvent;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider;
@ -21,7 +25,7 @@ import com.fr.van.chart.map.server.ChartMapEditorAction;
/**
* Created by juhaoyu on 2018/6/27.
*/
public class ChartDesignerActivator extends Activator {
public class ChartDesignerActivator extends Activator implements Prepare {
@Override
public void start() {
@ -50,6 +54,11 @@ public class ChartDesignerActivator extends Activator {
DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper());
}
@Override
public void prepare() {
addMutable(InterMutableKey.Path, LocaleMarker.create("com/fr/design/i18n/chart", LocaleScope.DESIGN));
}
@Override
public void stop() {

19
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -27,6 +27,7 @@ import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.hyperlink.ReportletHyperlinkPane;
import com.fr.design.hyperlink.WebHyperlinkPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptImplPane;
import com.fr.design.javascript.ParameterJavaScriptPane;
@ -58,7 +59,6 @@ import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.form.stable.ElementCaseThumbnailProcessor;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ModuleContext;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.js.EmailJavaScript;
@ -67,10 +67,11 @@ import com.fr.js.ParameterJavaScript;
import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import com.fr.locale.InterMutableKey;
import com.fr.locale.LocaleMarker;
import com.fr.locale.LocaleScope;
import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler;
import com.fr.module.Activator;
import com.fr.module.extension.Prepare;
import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor;
import com.fr.quickeditor.cellquick.CellDSColumnEditor;
import com.fr.quickeditor.cellquick.CellFormulaQuickEditor;
@ -114,12 +115,18 @@ import static com.fr.stable.module.Module.ENGINE_MODULE;
* 触发原来的DesignerModule的启动
* 之后慢慢将DesignerModule拆成Activator
*/
public class DesignerActivator extends Activator implements Prepare {
public class DesignerActivator extends Activator {
private LogHandler<DesignerLogAppender> logHandler = null;
@Override
public void start() {
List<LocaleMarker> markers = rightCollectMutable(InterMutableKey.Path);
for (LocaleMarker marker : markers) {
if (marker.match(LocaleScope.DESIGN)) {
Toolkit.addResource(marker.getPath());
}
}
designerModuleStart();
preLoadPane();
loadLogAppender();
@ -403,10 +410,4 @@ public class DesignerActivator extends Activator implements Prepare {
unloadLogAppender();
DesignerSocketIO.close();
}
@Override
public void prepare() {
addMutable(InterMutableKey.Path, "com/fr/design/i18n/main", "com/fr/design/i18n/chart");
}
}
Loading…
Cancel
Save