From d17b810076546d44ded1117fb421d3c2bf770daf Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 26 Sep 2024 11:09:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-135046=20feat:=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E8=AF=AD=E8=A8=80=E5=88=87=E6=8D=A2=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=96=B0=E8=AF=AD=E7=A7=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/PreferencePane.java | 17 +++++++++++------ .../java/com/fr/design/utils/DesignUtils.java | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index f8703275f8..64e59dfff0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -40,19 +40,17 @@ import com.fr.design.mainframe.vcs.ui.UIPositiveIntEditor; import com.fr.design.mainframe.vcs.ui.VcsMovePanel; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.unit.UnitConvertUtil; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; -import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.log.Log4jConfig; import com.fr.io.attr.ImageExportAttr; -import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.report.ReportConfigManager; -import com.fr.scheduler.tool.FineScheduler; import com.fr.stable.Constants; import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.logging.log4j.Level; @@ -76,7 +74,6 @@ import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFileChooser; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; @@ -89,7 +86,15 @@ import javax.swing.UIManager; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -816,7 +821,7 @@ public class PreferencePane extends BasicPane { } private UIDictionaryComboBox createLanguageComboBox() { - Map map = InterProviderFactory.getProvider().getSupportLocaleMap(); + Map map = DesignUtils.getAvailableLanguages(); int size = map.size(); Locale[] keys = new Locale[size]; String[] values = new String[size]; diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index e8c528ade2..c2be9dad09 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -19,10 +19,13 @@ import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.GeneralContext; +import com.fr.general.SupportLocale; +import com.fr.i18n.LanguageConfig; import com.fr.log.FineLoggerFactory; import com.fr.plugin.injectable.PluginModule; import com.fr.stable.ArrayUtils; import com.fr.stable.CommonCodeUtils; +import com.fr.stable.CommonUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.ObjectHolder; @@ -50,8 +53,11 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.util.Collections; import java.util.Enumeration; +import java.util.LinkedHashMap; import java.util.Locale; +import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; @@ -496,4 +502,15 @@ public class DesignUtils { return Utils.getAvailableFontFamilyNames4Report(); } + /** + * 获取设计器可用的开放的语言配置,包括默认开放的五种语言和finedb扩展项 + * @return Locale和翻译对应的key + */ + public static Map getAvailableLanguages() { + Map map = new LinkedHashMap<>(SupportLocale.getInstance().getLocaleMap()); + for (Map.Entry entry : LanguageConfig.getInstance().getExtendedDesignLocales().entrySet()) { + map.put(CommonUtils.stringToLocale(entry.getKey()), entry.getValue()); + } + return Collections.unmodifiableMap(map); + } } From 8b638027035bb958ef175c4a0476ca2cf05427c7 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 26 Sep 2024 17:39:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../i18n/DesignExtendLanguageConfig.java | 57 +++++++++++++++++++ .../java/com/fr/design/utils/DesignUtils.java | 4 +- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java b/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java new file mode 100644 index 0000000000..d2294faa83 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java @@ -0,0 +1,57 @@ +package com.fr.design.i18n; + +import com.fr.config.ConfigContext; +import com.fr.config.DefaultConfiguration; +import com.fr.config.Identifier; +import com.fr.config.holder.factory.Holders; +import com.fr.config.holder.impl.MapConf; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * 设计器语言扩展配置 + * + * @author obo + * @since 11.0 + * Created on 2024/09/26 + */ +public class DesignExtendLanguageConfig extends DefaultConfiguration { + + private static volatile DesignExtendLanguageConfig designExtendLanguageConfig = null; + + /** + * + * @return + */ + public static DesignExtendLanguageConfig getInstance() { + if (designExtendLanguageConfig == null) { + designExtendLanguageConfig = ConfigContext.getConfigInstance(DesignExtendLanguageConfig.class); + } + return designExtendLanguageConfig; + } + + /** + * 设计器扩展的语言 + * key为localeString,例如en_US或en;value为改语言对应的国际化翻译key + */ + @Identifier("extendDesignLocales") + private MapConf> extendDesignLocales = Holders.map(new HashMap<>(), String.class, String.class); + + public Map getExtendedDesignLocales() { + return Collections.unmodifiableMap(extendDesignLocales.get()); + } + + public void setExtendedDesignLocales(Map map) { + extendDesignLocales.set(map); + } + + @Override + public Object clone() throws CloneNotSupportedException { + DesignExtendLanguageConfig cloned = (DesignExtendLanguageConfig) super.clone(); + cloned.extendDesignLocales = ( MapConf>) extendDesignLocales.clone(); + return cloned; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index c2be9dad09..52059552b6 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -11,6 +11,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.fun.DefaultValueAdjustProvider; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; +import com.fr.design.i18n.DesignExtendLanguageConfig; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; @@ -20,7 +21,6 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.GeneralContext; import com.fr.general.SupportLocale; -import com.fr.i18n.LanguageConfig; import com.fr.log.FineLoggerFactory; import com.fr.plugin.injectable.PluginModule; import com.fr.stable.ArrayUtils; @@ -508,7 +508,7 @@ public class DesignUtils { */ public static Map getAvailableLanguages() { Map map = new LinkedHashMap<>(SupportLocale.getInstance().getLocaleMap()); - for (Map.Entry entry : LanguageConfig.getInstance().getExtendedDesignLocales().entrySet()) { + for (Map.Entry entry : DesignExtendLanguageConfig.getInstance().getExtendedDesignLocales().entrySet()) { map.put(CommonUtils.stringToLocale(entry.getKey()), entry.getValue()); } return Collections.unmodifiableMap(map); From 83ad455a6794b2661942849b12b965f32c8c3f51 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 26 Sep 2024 17:40:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/i18n/DesignExtendLanguageConfig.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java b/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java index d2294faa83..27d0c839f7 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignExtendLanguageConfig.java @@ -22,8 +22,7 @@ public class DesignExtendLanguageConfig extends DefaultConfiguration { private static volatile DesignExtendLanguageConfig designExtendLanguageConfig = null; /** - * - * @return + * 获取实例 */ public static DesignExtendLanguageConfig getInstance() { if (designExtendLanguageConfig == null) {