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);