From 5ae02c176ca6cf89402bd50103eefba41c3bd59b Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Mon, 23 Nov 2020 19:03:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?CHART-16853=20=E5=A4=84=E7=90=86=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/VanChartRichEditorPane.java | 13 ++ .../com/fr/design/editor/rich_editor.html | 19 +-- .../com/fr/design/editor/script/editor.js | 2 +- .../fr/design/editor/script/editor.model.js | 6 +- .../com/fr/design/editor/script/enums.js | 15 +++ .../com/fr/design/editor/script/i18n.js | 123 ++++++++++++++++++ 6 files changed, 157 insertions(+), 21 deletions(-) create mode 100644 designer-chart/src/main/resources/com/fr/design/editor/script/enums.js create mode 100644 designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java index 1ccc146c1f..4d5509c88c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.designer.component; import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.DesignerEnvManager; import com.fr.design.ui.ModernUIPane; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.type.TextAlign; @@ -63,6 +65,11 @@ public class VanChartRichEditorPane { browser = event.getBrowser(); browser.getCacheStorage().clearCache(); + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); + browser.executeJavaScript(generateTransformI18nJS()); + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); + JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); ns.asObject().setProperty(variable, model); } @@ -110,6 +117,12 @@ public class VanChartRichEditorPane { return new RichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); } + public static String generateTransformI18nJS() { + String language = DesignerEnvManager.getEnvManager().getLanguage().toString(); + + return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; + } + public static class RichEditorModel { private String content = StringUtils.EMPTY; private boolean auto = true; diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html index 07fbb3ec72..e6c769f0a3 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html @@ -5,26 +5,9 @@ - - - + diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js index bb5370e4fc..f3e0536797 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js @@ -52,7 +52,7 @@ type: "bi.htape", items: [{ type: "bi.label", - text: "字体样式: ", + text: BI.i18nText("BI-Design_Font_Style") + ": ", textAlign: "left", width: 70 }, { diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js index f430fea6c5..c901fd31ea 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js @@ -17,8 +17,9 @@ fontStyleItems: function () { return [{ type: "bi.single_select_radio_item", - text: "自动", + text: BI.i18nText("BI-Basic_Auto"), hgap: 5, + width: 50, logic: { dynamic: true }, @@ -26,8 +27,9 @@ selected: this.options.isAuto }, { type: "bi.single_select_radio_item", - text: "自定义", + text: BI.i18nText("BI-Basic_Custom"), hgap: 5, + width: 60, logic: { dynamic: true }, diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/enums.js b/designer-chart/src/main/resources/com/fr/design/editor/script/enums.js new file mode 100644 index 0000000000..461625ebc5 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/enums.js @@ -0,0 +1,15 @@ +window.BICst = window.BICst || {}; +BICst.RICH_TEXT_INFO = { + DATA_ID: "data-id", + DATA_NAME: "data-name", + DATA_FULL_NAME: "data-full-name", + DATA_ORIGIN_ID: "data-origin-id", + DATA_ORIGIN_NAME: "data-origin-name", + DATA_ORIGIN_FULL_NAME: "data-origin-full-name", + DATA_IS_INSERT_PARAM: "data-is-insert-param", + DATA_IS_MISSING_FIELD: "data-is-missing-field", + DATA_UN_VALID: "data-unvalid", + NAME: "name", + ALT: "alt", + SRC: "src" +}; \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js new file mode 100644 index 0000000000..95b4585c94 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/i18n.js @@ -0,0 +1,123 @@ +!(function () { + + var chinese = { + "BI-Design_Font_Style": "字体样式", + "BI-Font_Size": "字号", + "BI-Basic_Auto": "自动", + "BI-Basic_Custom": "自定义", + "BI-Basic_Default": "默认", + "BI-Basic_Sim_Hei": "黑体", + "BI-Basic_Sim_Sun": "宋体", + "BI-Basic_Fang_Song": "仿宋", + "BI-Basic_Kai_Ti": "楷体", + "BI-Basic_Bold": "加粗", + "BI-Basic_Italic": "斜体", + "BI-Basic_Underline": "下划线", + "BI-Basic_Font_Color": "文字颜色", + "BI-Word_Align_Left": "文字居左", + "BI-Word_Align_Center": "文字居中", + "BI-Word_Align_Right": "文字居右" + }; + + var taiwan = { + "BI-Design_Font_Style": "字體樣式", + "BI-Font_Size": "字號", + "BI-Basic_Auto": "自動", + "BI-Basic_Custom": "自定義", + "BI-Basic_Default": "默認", + "BI-Basic_Sim_Hei": "黑體", + "BI-Basic_Sim_Sun": "宋體", + "BI-Basic_Fang_Song": "仿宋", + "BI-Basic_Kai_Ti": "楷體", + "BI-Basic_Bold": "加粗", + "BI-Basic_Italic": "斜體", + "BI-Basic_Underline": "下劃線", + "BI-Basic_Font_Color": "文字顏色", + "BI-Word_Align_Left": "文字居左", + "BI-Word_Align_Center": "文字居中", + "BI-Word_Align_Right": "文字居右" + }; + + var english = { + "BI-Design_Font_Style": "Font style", + "BI-Font_Size": "Font size", + "BI-Basic_Auto": "auto", + "BI-Basic_Custom": "custom", + "BI-Basic_Default": "default", + "BI-Basic_Sim_Hei": "Sim_Hei", + "BI-Basic_Sim_Sun": "Sim_Sun", + "BI-Basic_Fang_Song": "Fang_Song", + "BI-Basic_Kai_Ti": "Kai_Ti", + "BI-Basic_Bold": "Bold", + "BI-Basic_Italic": "Italic", + "BI-Basic_Underline": "UnderLine", + "BI-Basic_Font_Color": "Font Color", + "BI-Word_Align_Left": "Align Left", + "BI-Word_Align_Center": "Align Center", + "BI-Word_Align_Right": "Align Right" + }; + + var japanese = { + "BI-Design_Font_Style": "フォントスタイル", + "BI-Font_Size": "フォントサイズ", + "BI-Basic_Auto": "自動", + "BI-Basic_Custom": "カスタマイズ", + "BI-Basic_Default": "デフォルト", + "BI-Basic_Sim_Hei": "黒い体", + "BI-Basic_Sim_Sun": "ソンティ", + "BI-Basic_Fang_Song": "イミテーションソング", + "BI-Basic_Kai_Ti": "イタリック", + "BI-Basic_Bold": "大胆な", + "BI-Basic_Italic": "イタリック", + "BI-Basic_Underline": "アンダースコア", + "BI-Basic_Font_Color": "テキストの色", + "BI-Word_Align_Left": "左のテキスト", + "BI-Word_Align_Center": "テキスト中心", + "BI-Word_Align_Right": "右のテキスト" + }; + + var korean = { + "BI-Design_Font_Style": "글꼴 스타일", + "BI-Font_Size": "글꼴 크기", + "BI-Basic_Auto": "자동적 인", + "BI-Basic_Custom": "맞춤 설정", + "BI-Basic_Default": "기본", + "BI-Basic_Sim_Hei": "블랙 바디", + "BI-Basic_Sim_Sun": "송티", + "BI-Basic_Fang_Song": "모조 노래", + "BI-Basic_Kai_Ti": "기울임 꼴", + "BI-Basic_Bold": "굵게", + "BI-Basic_Italic": "이탤릭체", + "BI-Basic_Underline": "밑줄", + "BI-Basic_Font_Color": "텍스트 색상", + "BI-Word_Align_Left": "왼쪽 텍스트", + "BI-Word_Align_Center": "텍스트 중심", + "BI-Word_Align_Right": "오른쪽 텍스트" + }; + + function transformI18n(language) { + var BI = window.BI; + + if (BI == null) { + return; + } + + if (language == null) { + BI.addI18n(chinese); + } + + if (language.indexOf('zh_TW') > -1) { + BI.addI18n(taiwan); + } else if (language.indexOf('en_US') > -1) { + BI.addI18n(english); + } else if (language.indexOf('ja_JP') > -1) { + BI.addI18n(japanese); + } else if (language.indexOf('ko_KR') > -1) { + BI.addI18n(korean); + } else { + BI.addI18n(chinese); + } + } + + window.transformI18n = transformI18n; +}()); \ No newline at end of file From 38e53e5163b4fd5303058a60324974d03650ca4c Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Mon, 23 Nov 2020 19:15:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/designer/component/VanChartRichEditorPane.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java index 4d5509c88c..6f308ad431 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -13,6 +13,7 @@ import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -118,7 +119,13 @@ public class VanChartRichEditorPane { } public static String generateTransformI18nJS() { - String language = DesignerEnvManager.getEnvManager().getLanguage().toString(); + String language = "zh_CN"; + + Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); + + if (locale != null) { + language = locale.toString(); + } return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; }