diff --git a/designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java b/designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java index 64ed36435..2c914bd47 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/LocalePane.java @@ -122,12 +122,14 @@ public class LocalePane extends BasicPane { private void initPredefinedProperties() { Map supportLocaleMap = InterProviderFactory.getProvider().getSupportLocaleMap(); - - Map map; + + // richie:暂时去掉设计器中国际化键值对的显示 + Map map = new HashMap<>(); List sortKeys = new ArrayList(); - - map = InterProviderFactory.getProvider().getLocalBundle(Locale.SIMPLIFIED_CHINESE).getMap(); + + //map = InterProviderFactory.getProvider().getLocalBundle(Locale.SIMPLIFIED_CHINESE).getMap(); + sortKeys.addAll(map.keySet()); Collections.sort(sortKeys); diff --git a/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java b/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java index ad4dff6a4..79bb37bb0 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java +++ b/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java @@ -1,48 +1,57 @@ 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 key 格式化文本 * @param args 格式化参数 * @return 国际化值 */ 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); - } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java index 87ace0b0b..de7e5ec8a 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java +++ b/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() { @@ -49,7 +53,12 @@ public class ChartDesignerActivator extends Activator { DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance()); DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); } - + + @Override + public void prepare() { + addMutable(InterMutableKey.Path, LocaleMarker.create("com/fr/design/i18n/chart", LocaleScope.DESIGN)); + } + @Override public void stop() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java index 2d6ebc8a2..f91b0d9a1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppActivator.java @@ -11,29 +11,29 @@ import java.util.List; * Created by juhaoyu on 2018/6/27. */ public class DesignerAppActivator extends Activator implements Prepare { - + @Override public void start() { - + List appList = rightCollectMutable(App.KEY); for (App app : appList) { DesignerFrame.registApp(app); } } - + @Override public void stop() { - + List appList = rightCollectMutable(App.KEY); for (App app : appList) { DesignerFrame.removeApp(app); } } - + @Override public void prepare() { - + addMutable(App.KEY, new CptApp(), new FormApp(), new XlsApp(), new XlsxApp()); - + } } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 4922f3db4..bac7d7247 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/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 logHandler = null; @Override public void start() { + List 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"); - } } \ No newline at end of file