From 813ada35e87d3405b3ad84c080472c62b85f4d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Sun, 29 Sep 2024 18:56:30 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-135106=20=E8=A1=A8=E6=A0=BC=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98=E5=92=8C=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E5=AF=BC=E8=87=B4=E7=9A=84=E5=9B=BE=E8=A1=A8=E6=B6=88?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/editor/script/editor.js | 3 + .../com/fr/design/editor/script/i18n.js | 86 +++++++++++++++++-- 2 files changed, 84 insertions(+), 5 deletions(-) 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 ec4de690d8..54a268c63d 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 @@ -128,6 +128,9 @@ if (key === "src") { return; } + + value = window.transformI18nText(value); + str += " " + key + "=\"" + value + "\""; if (key === "alt" && dataIdMap[value.trim()]) { 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 index 205117f3cd..f80cc05e7c 100644 --- 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 @@ -21,7 +21,12 @@ "BI-Basic_Save": "保存", "BI-Basic_More": "更多", "BI-Custom_Color": "自定义颜色", - "BI-Transparent_Color": "透明" + "BI-Transparent_Color": "透明", + "Fine-Design_Chart_Category_Use_Name": "分类名", + "Fine-Design_Chart_Series_Name": "系列名", + "Fine-Design_Chart_Use_Value": "值", + "Fine-Design_Chart_Use_Percent": "百分比", + "Fine-Design_Chart_Use_Summary_Value": "汇总值" }; var taiwan = { @@ -45,7 +50,12 @@ "BI-Basic_Save": "保存", "BI-Basic_More": "更多", "BI-Custom_Color": "自定義顏色", - "BI-Transparent_Color": "透明" + "BI-Transparent_Color": "透明", + "Fine-Design_Chart_Category_Use_Name": "分類名", + "Fine-Design_Chart_Series_Name": "系列名", + "Fine-Design_Chart_Use_Value": "值", + "Fine-Design_Chart_Use_Percent": "百分比", + "Fine-Design_Chart_Use_Summary_Value": "匯總值" }; var english = { @@ -69,7 +79,12 @@ "BI-Basic_Save": "Save", "BI-Basic_More": "More", "BI-Custom_Color": "Custom Color", - "BI-Transparent_Color": "Transparent Color" + "BI-Transparent_Color": "Transparent Color", + "Fine-Design_Chart_Category_Use_Name": "Category Name", + "Fine-Design_Chart_Series_Name": "Series", + "Fine-Design_Chart_Use_Value": "Value", + "Fine-Design_Chart_Use_Percent": "Percentage", + "Fine-Design_Chart_Use_Summary_Value": "Summary Value" }; var japanese = { @@ -93,7 +108,12 @@ "BI-Basic_Save": "セーブ", "BI-Basic_More": "もっと", "BI-Custom_Color": "カスタムカラー", - "BI-Transparent_Color": "トランスペアレント" + "BI-Transparent_Color": "トランスペアレント", + "Fine-Design_Chart_Category_Use_Name": "分類名", + "Fine-Design_Chart_Series_Name": "系列名", + "Fine-Design_Chart_Use_Value": "値", + "Fine-Design_Chart_Use_Percent": "パーセンテージ", + "Fine-Design_Chart_Use_Summary_Value": "まとめ値" }; var korean = { @@ -117,7 +137,12 @@ "BI-Basic_Save": "저장", "BI-Basic_More": "더", "BI-Custom_Color": "맞춤 색상", - "BI-Transparent_Color": "투명한" + "BI-Transparent_Color": "투명한", + "Fine-Design_Chart_Category_Use_Name": "카테고리 명", + "Fine-Design_Chart_Series_Name": "표시값", + "Fine-Design_Chart_Use_Value": "값", + "Fine-Design_Chart_Use_Percent": "백분율", + "Fine-Design_Chart_Use_Summary_Value": "요약 값" }; function transformI18n(language) { @@ -144,5 +169,56 @@ } } + /** + * 将一个text转换成当前国际化语言环境的text + * @param text + * @returns {*} + */ + function transformI18nText(text) { + var i18nKey = _findI18nKey(text); + return window.BI.i18nText(i18nKey); + } + + /** + * 根据text找到i18n的key + * @param text + * @returns {string} + * @private + */ + function _findI18nKey(text) { + for (var [key, value] of Object.entries(chinese)) { + if (value === text) { + return key; + } + } + + for ([key, value] of Object.entries(taiwan)) { + if (value === text) { + return key; + } + } + + for ([key, value] of Object.entries(english)) { + if (value === text) { + return key; + } + } + + for ([key, value] of Object.entries(japanese)) { + if (value === text) { + return key; + } + } + + for ([key, value] of Object.entries(korean)) { + if (value === text) { + return key; + } + } + + return ''; + } + window.transformI18n = transformI18n; + window.transformI18nText = transformI18nText; }()); \ No newline at end of file