From 8b638027035bb958ef175c4a0476ca2cf05427c7 Mon Sep 17 00:00:00 2001 From: obo Date: Thu, 26 Sep 2024 17:39:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=94=BE=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=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);