diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java index 6158540888..b369911bf9 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java @@ -9,6 +9,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; @@ -82,7 +83,7 @@ public class AboutPane extends JPanel { addPhoneAndQQPane(contentPane); // 官网 - JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireConf("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL)); + JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), UrlI18nManager.getInstance().getI18nUrl("website")); // 支持邮箱 String defaultEmail = CloudCenter.getInstance().acquireConf("support.email", ProductConstants.SUPPORT_EMAIL); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index f1094d3315..bf7dd942d8 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,6 +1,7 @@ package com.fr.design.actions.help; import com.fr.design.i18n.Toolkit; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.login.AbstractDesignerSSO; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; @@ -28,7 +29,7 @@ public class TutorialAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com"); + return UrlI18nManager.getInstance().getI18nUrl("help"); } public String getOffLineWarnMessage() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 0da46965b1..6f8e737ae5 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -159,7 +160,8 @@ public class JDBCDefPane extends JPanel { odbcTipsLink.setPreferredSize(new Dimension(GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Odbc_Tips")), odbcTipsLink.getPreferredSize().height)); odbcTipsLink.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { - String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); + //String url = CloudCenter.getInstance().acquireUrlByKind("odbc.help"); + String url = UrlI18nManager.getInstance().getI18nUrl("odbc.help"); BrowseUtils.browser(url); } }); diff --git a/designer-base/src/main/java/com/fr/design/i18n/UrlI18nManager.java b/designer-base/src/main/java/com/fr/design/i18n/UrlI18nManager.java new file mode 100644 index 0000000000..aa498213eb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/UrlI18nManager.java @@ -0,0 +1,97 @@ +package com.fr.design.i18n; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.locale.LocaleBundle; +import com.fr.locale.LocaleFiles; +import com.fr.locale.LocaleManager; +import com.fr.locale.impl.FineLocaleManager; +import com.fr.stable.ProductConstants; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + + +public class UrlI18nManager { + private static final String I18N_URL_PATH = "com/fr/design/i18n/url"; + + private static UrlI18nManager instance = new UrlI18nManager(); + + public static UrlI18nManager getInstance() { + return instance; + } + + private LocaleManager localeManager = FineLocaleManager.create(); + + private UrlI18nManager() { + localeManager.addResource(I18N_URL_PATH); + } + + public String getI18nUrl(String key) { + String i18NUrl = getI18nUrlFromCloudCenter(key); + if (StringUtils.isBlank(i18NUrl)) { + i18NUrl = getI18nUrlFromLocal(key); + } + return i18NUrl; + } + + private String getI18nUrlFromCloudCenter(String key) { + List availableKeys = getCloudCenterAvailableKeys(key); + for (String availableKey : availableKeys) { + String i18NUrl = CloudCenter.getInstance().acquireConf(availableKey); + if (!StringUtils.isBlank(i18NUrl)) { + return i18NUrl; + } + } + return StringUtils.EMPTY; + } + + private List getCloudCenterAvailableKeys(String key) { + List availableKeys = new ArrayList<>(); + availableKeys.add(key + "." + GeneralContext.getLocale() + "." + ProductConstants.MAIN_VERSION); + availableKeys.add(key + "." + Locale.ENGLISH + "." + ProductConstants.MAIN_VERSION); + availableKeys.add(key + "." + Locale.CHINA + "." + ProductConstants.MAIN_VERSION); + availableKeys.add(key + "." + GeneralContext.getLocale()); + availableKeys.add(key + "." + Locale.ENGLISH); + availableKeys.add(key + "." + Locale.CHINA); + availableKeys.add(key + "." + ProductConstants.MAIN_VERSION); + availableKeys.add(key); + return availableKeys; + } + + private String getI18nUrlFromLocal(String key) { + List availableLocales = getAvailableLocales(); + LocaleBundle localeBundle = null; + for (Locale availableLocale : availableLocales) { + localeBundle = localeManager.getLocalBundle(availableLocale); + if (isExist(localeBundle, localeManager, key)) { + break; + } + } + if (localeBundle != null) { + return localeBundle.getText(localeManager, key); + } else { + return StringUtils.EMPTY; + } + } + + private List getAvailableLocales() { + List availableLocales = new ArrayList<>(); + availableLocales.add(GeneralContext.getLocale()); + availableLocales.add(Locale.ENGLISH); + availableLocales.add(Locale.CHINA); + return availableLocales; + } + + private boolean isExist(LocaleBundle localeBundle, LocaleManager localeManager, String key) { + List filesList = localeManager.getReverseList(); + for (LocaleFiles files : filesList) { + if (files.contains(localeBundle.getLocale(), key)) { + return true; + } + } + return false; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java index 0671ed1b63..86021733d0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java @@ -5,6 +5,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.CloudCenter; @@ -49,7 +50,8 @@ public class CheckFontInfoDialog extends JDialog implements ActionListener { JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"), Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"), - CloudCenter.getInstance().acquireUrlByKind("help.install.font", "https://help.fanruan.com/finereport/doc-view-3999.html")); + UrlI18nManager.getInstance().getI18nUrl("help.install.font") + ); linkMessage.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink")); messagePanel.add(linkMessage); diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java index c717ce6ea6..b0d5eab328 100644 --- a/designer-base/src/main/java/com/fr/env/HelpLink.java +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -1,5 +1,6 @@ package com.fr.env; +import com.fr.design.i18n.UrlI18nManager; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.locale.InterProviderFactory; @@ -18,8 +19,7 @@ public class HelpLink { public static String getLink(String solution) { Map map = new HashMap<>(); - LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); - String link = linkMark.getValue(); + String link = UrlI18nManager.getInstance().getI18nUrl("help.remote.design"); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link); diff --git a/designer-base/src/main/resources/com/fr/design/i18n/url_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/url_en.properties new file mode 100644 index 0000000000..7f4fafc35c --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/url_en.properties @@ -0,0 +1,7 @@ +help=https://help.fanruan.com/finereport-en/ +help.remote.design=https://help.fanruan.com/finereport-en/doc-view-3862.html?source=4 +odbc.help=https://help.fanruan.com/finereport-en/doc-view-289.html +plugin.mobile.style=https://help.fanruan.com/finereport-en/doc-view-2656.html +help.install.font=https://help.fanruan.com/finereport-en/doc-view-3875.html +website=https://www.finereport.com/en/ +nine.point.help=https://help.fanruan.com/finereport-en/doc-view-3876.html \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/url_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/url_ja_JP.properties new file mode 100644 index 0000000000..6d0a960fa6 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/url_ja_JP.properties @@ -0,0 +1,7 @@ +help=https://help.fanruan.com/finereport-jp/ +help.remote.design=https://help.fanruan.com/finereport-jp/doc-view-3891.html +odbc.help=https://help.fanruan.com/finereport-jp/doc-view-289.html +plugin.mobile.style=https://help.fanruan.com/finereport-jp/doc-view-2656.html +help.install.font=https://help.fanruan.com/finereport-jp/doc-view-3892.html +website=https://www.finereport.com/jp/ +nine.point.help=https://help.fanruan.com/finereport-jp/doc-view-3896.html \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/url_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/url_ko_KR.properties new file mode 100644 index 0000000000..4078962317 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/url_ko_KR.properties @@ -0,0 +1 @@ +website=https://www.finereport.com/kr/ \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/url_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/url_zh.properties new file mode 100644 index 0000000000..ef25a7bf89 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/url_zh.properties @@ -0,0 +1,7 @@ +help=https://help.fanruan.com/finereport/ +help.remote.design=https://help.fanruan.com/finereport/doc-view-3925.html +odbc.help=https://help.fanruan.com/finereport/doc-view-289.html +plugin.mobile.style=https://help.fanruan.com/finereport/doc-view-2656.html +help.install.font=https://help.fanruan.com/finereport/doc-view-3999.html +website=https://www.finereport.com/ +nine.point.help=https://help.fanruan.com/finereport/doc-view-4135.html \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/i18n/url_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/url_zh_TW.properties new file mode 100644 index 0000000000..1a207e9f3f --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/url_zh_TW.properties @@ -0,0 +1,7 @@ +help=https://help.fanruan.com/finereport-tw/ +help.remote.design=https://help.fanruan.com/finereport/doc-view-3925.html +odbc.help=https://help.fanruan.com/finereport/doc-view-289.html +plugin.mobile.style=https://help.fanruan.com/finereport/doc-view-2656.html +help.install.font=https://help.fanruan.com/finereport/doc-view-3999.html +website=https://www.finereport.com/tw/ +nine.point.help=https://help.fanruan.com/finereport-tw/doc-view-4519.html \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 0f2b853d1b..3d2e86c592 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -20,6 +20,7 @@ import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -121,7 +122,7 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { public void actionPerformed(ActionEvent e) { Desktop desktop = Desktop.getDesktop(); try { - desktop.browse(new URI(TWEAK_NINE_POINT_HELP_URL)); + desktop.browse(new URI(UrlI18nManager.getInstance().getI18nUrl("nine.point.help"))); } catch (IOException | URISyntaxException ioException) { ioException.printStackTrace(); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java index 906fa6e55e..759a05ba7f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ParaMobileDefinePane.java @@ -9,6 +9,7 @@ import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.fun.ParameterExpandablePaneUIProvider; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.UrlI18nManager; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -104,7 +105,7 @@ public class ParaMobileDefinePane extends MobileWidgetDefinePane { @Override public void mouseClicked(MouseEvent e) { try { - Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("plugin.mobile.style"))); + Desktop.getDesktop().browse(new URI(UrlI18nManager.getInstance().getI18nUrl("plugin.mobile.style"))); } catch (Exception exp) { FineLoggerFactory.getLogger().error(exp.getMessage(), exp); }