From b11b86295108d8b25ad2cd7b1ba016b3555cee0d Mon Sep 17 00:00:00 2001 From: liurunze <1414556676@qq.com> Date: Tue, 28 Jul 2020 10:27:39 +0800 Subject: [PATCH] fix(locale,formula): locale,formula 1. internationalization 2.if formula generator, insert formula --- src/controllers/ifFormulaGenerator.js | 76 +++++++++++++++++---------- src/controllers/insertFormula.js | 38 +++++++++----- src/controllers/menuButton.js | 27 +++++----- src/css/luckysheet-core.css | 2 +- src/locale/en.js | 67 ++++++++++++++++++++++- src/locale/zh.js | 65 ++++++++++++++++++++++- 6 files changed, 217 insertions(+), 58 deletions(-) diff --git a/src/controllers/ifFormulaGenerator.js b/src/controllers/ifFormulaGenerator.js index c0bf6f39f..35a17a938 100644 --- a/src/controllers/ifFormulaGenerator.js +++ b/src/controllers/ifFormulaGenerator.js @@ -4,13 +4,16 @@ import luckysheetupdateCell from './updateCell'; import { modelHTML } from './constant'; import { replaceHtml } from '../utils/util'; import Store from '../store'; +import locale from '../locale/locale'; //if公式生成器 const ifFormulaGenerator = { singleRangeFocus: false, init: function(){ let _this = this; - + const _locale = locale(); + const locale_formula = _locale.formula; + const locale_button = _locale.button; //点击选择单元格 $(document).off("focus.IFcompareValue").on("focus.IFcompareValue", "#luckysheet-ifFormulaGenerator-dialog #compareValue", function(){ $("#luckysheet-modal-dialog-mask").hide(); @@ -143,7 +146,7 @@ const ifFormulaGenerator = { $(document).off("click.IFcreateBtn").on("click.IFcreateBtn", "#luckysheet-ifFormulaGenerator-dialog #createBtn", function(){ let compareValue = $(this).parents("#luckysheet-ifFormulaGenerator-dialog").find("#compareValue").val().trim(); if(compareValue == ""){ - _this.info("比较值不能为空!"); + _this.info(locale_formula.ifGenTipNotNullValue); return; } @@ -161,7 +164,7 @@ const ifFormulaGenerator = { ''+ ''+ ''+ - '标签:'+ + ''+locale_formula.ifGenTipLableTitile+':'+ ''+ ''+ ''; @@ -173,11 +176,11 @@ const ifFormulaGenerator = { let DivisionMethodVal = $(this).parents("#luckysheet-ifFormulaGenerator-dialog").find("#DivisionMethodVal").val().trim(); if(smallRange == "" || largeRange == ""){ - _this.info("范围不能为空!"); + _this.info(locale_formula.ifGenTipRangeNotforNull); return; } else if(DivisionMethodVal == ""){ - _this.info("划分值不能为空!"); + _this.info(locale_formula.ifGenTipCutValueNotforNull); return; } @@ -204,7 +207,7 @@ const ifFormulaGenerator = { let markText = $(e).find(".markText").val().trim(); if(markText == ""){ - markText = "标签" + (i + 1); + markText = locale_formula.ifGenTipLableTitile + (i + 1); } if(smallNum == "" && largeNum == ""){ @@ -247,7 +250,7 @@ const ifFormulaGenerator = { }) if(str.length == 0){ - _this.info("没有生成可用的条件!"); + _this.info(locale_formula.ifGenTipNotGenCondition); return; } @@ -281,6 +284,10 @@ const ifFormulaGenerator = { ifFormulaDialog: function(fp){ let _this = this; + const _locale = locale(); + const locale_formula = _locale.formula; + const locale_button = _locale.button; + $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-ifFormulaGenerator-dialog").remove(); @@ -321,7 +328,7 @@ const ifFormulaGenerator = { ''+ ''+ ''+ - '标签:'+ + ''+locale_formula.ifGenTipLableTitile+':'+ ''+ ''+ ''; @@ -331,31 +338,31 @@ const ifFormulaGenerator = { let content = '
'+ '
'+ - ''+ + ''+ '
'+ ''+ - ''+ + ''+ '
'+ '
'+ '
'+ - ''+ + ''+ ''+ - ''+ + ' '+ locale_formula.ifGenRangeTo +' '+ ''+ '
'+ - ' 范围评估 '+ - ''+ + ' '+ locale_formula.ifGenRangeEvaluate +' '+ + ''+ '
'+ '
'+ '
'+ - ''+ + ''+ ''+ ''+ - '
生成
'+ + '
'+ locale_formula.ifGenCutSame +'
'+ '
'+ '
'+ '
'+ifListHtml+'
'; @@ -363,9 +370,9 @@ const ifFormulaGenerator = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-ifFormulaGenerator-dialog", "addclass": "luckysheet-ifFormulaGenerator-dialog", - "title": "if公式生成器", + "title": locale_formula.ifGenerate, "content": content, - "botton": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-ifFormulaGenerator-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 590).end(), @@ -417,6 +424,10 @@ const ifFormulaGenerator = { $("#luckysheet-ifFormulaGenerator-dialog").hide(); $("#luckysheet-ifFormulaGenerator-singleRange-dialog").remove(); + const _locale = locale(); + const locale_formula = _locale.formula; + const locale_button = _locale.button; + if(value == null){ value = ""; } @@ -424,9 +435,9 @@ const ifFormulaGenerator = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-ifFormulaGenerator-singleRange-dialog", "addclass": "luckysheet-ifFormulaGenerator-singleRange-dialog", - "title": "选择单元格", - "content": '', - "botton": '', + "title": locale_formula.ifGenTipSelectCell, + "content": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-ifFormulaGenerator-singleRange-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), @@ -441,12 +452,16 @@ const ifFormulaGenerator = { $("#luckysheet-ifFormulaGenerator-dialog").hide(); $("#luckysheet-ifFormulaGenerator-multiRange-dialog").remove(); + const _locale = locale(); + const locale_formula = _locale.formula; + const locale_button = _locale.button; + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-ifFormulaGenerator-multiRange-dialog", "addclass": "luckysheet-ifFormulaGenerator-multiRange-dialog", - "title": "选择范围", - "content": '', - "botton": '', + "title": locale_formula.ifGenTipSelectRange, + "content": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-ifFormulaGenerator-multiRange-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), @@ -514,7 +529,7 @@ const ifFormulaGenerator = { ''+ ''+ ''+ - '标签:'+ + ''+locale_formula.ifGenTipLableTitile+':'+ ''+ ''+ ''; @@ -525,12 +540,15 @@ const ifFormulaGenerator = { $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-ifFormulaGenerator-info").remove(); + const _locale = locale(); + const locale_button = _locale.button; + $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-ifFormulaGenerator-info", "addclass": "", "title": title, "content": "", - "botton": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-ifFormulaGenerator-info").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(), diff --git a/src/controllers/insertFormula.js b/src/controllers/insertFormula.js index 862e3e23a..16f464fd9 100644 --- a/src/controllers/insertFormula.js +++ b/src/controllers/insertFormula.js @@ -7,11 +7,15 @@ import { modelHTML } from './constant'; import { luckysheet_count_show } from './select'; import { replaceHtml, getObjType } from '../utils/util'; import Store from '../store'; +import locale from '../locale/locale'; //插入函数 const insertFormula = { init: function(){ let _this = this; + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; + let locale_button = _locale.button $(document).off("keyup.fxSFLI").on("keyup.fxSFLI", "#searchFormulaListInput", function(){ $("#formulaTypeList").empty(); @@ -92,7 +96,7 @@ const insertFormula = { let parmCount = $("#luckysheet-search-formula-parm .parmBox").length; if(parmCount < 5 && parmIndex == (parmCount - 1)){ - $('
值'+ (parmCount + 1) +'
=
').appendTo($("#luckysheet-search-formula-parm .parmListBox")); + $('
'+ locale_formulaMore.valueTitle +''+ (parmCount + 1) +'
=
').appendTo($("#luckysheet-search-formula-parm .parmListBox")); } } }); @@ -133,9 +137,9 @@ const insertFormula = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-search-formula-parm-select", "addclass": "luckysheet-search-formula-parm-select", - "title": "选取数据范围", - "content": "", - "botton": '', + "title": locale_formulaMore.tipSelectDataRange, + "content": "", + "botton": '', "style": "z-index:100003" })); } @@ -143,9 +147,9 @@ const insertFormula = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-search-formula-parm-select", "addclass": "luckysheet-search-formula-parm-select", - "title": "选取数据范围", - "content": "", - "botton": '', + "title": locale_formulaMore.tipSelectDataRange, + "content": "", + "botton": '', "style": "z-index:100003" })); } @@ -178,6 +182,10 @@ const insertFormula = { formulaListDialog: function(){ let _this = this; + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; + let locale_button = _locale.button + $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-search-formula").remove(); @@ -185,8 +193,8 @@ const insertFormula = { "id": "luckysheet-search-formula", "addclass": "luckysheet-search-formula", "title": "", - "content": "
", - "botton": '', + "content": "
", + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-search-formula").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(), @@ -215,6 +223,10 @@ const insertFormula = { parm_content = '', parm_list_content = ''; + let _locale = locale(); + let locale_formulaMore = _locale.formulaMore; + let locale_button = _locale.button + for(let i = 0; i < functionlist.length; i++){ if(functionlist[i].n == formulaTxt.toUpperCase()){ parm_title = functionlist[i].n; @@ -226,7 +238,7 @@ const insertFormula = { '
'+ functionlist[i].p[j].name +'
'+ '
'+ '' + - ''+ + ''+ '
'+ '
=
'+ ''; @@ -241,7 +253,7 @@ const insertFormula = { '
'+ functionlist[i].p[j].name +'
'+ '
'+ ''+ - ''+ + ''+ '
'+ '
=
'+ ''; @@ -252,7 +264,7 @@ const insertFormula = { '
'+ parm_list_content +'
'+ '
'+ functionlist[i].d +'
'+ '
'+ - '
计算结果 =
'+ + '
'+locale_formulaMore.calculationResult+' =
'+ ''; } } @@ -266,7 +278,7 @@ const insertFormula = { "addclass": "luckysheet-search-formula-parm", "title": parm_title, "content": parm_content, - "botton": '', + "botton": '', "style": "z-index:100003" })); let $t = $("#luckysheet-search-formula-parm").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(), diff --git a/src/controllers/menuButton.js b/src/controllers/menuButton.js index f688cd9cb..af19b5eda 100644 --- a/src/controllers/menuButton.js +++ b/src/controllers/menuButton.js @@ -1933,17 +1933,20 @@ const menuButton = { $("#luckysheet-icon-function-menu").click(function(){ let menuButtonId = $(this).attr("id") + "-menuButton"; let $menuButton = $("#" + menuButtonId); + + const _locale = locale(); + const locale_formula = _locale.formula; if($menuButton.length == 0){ let itemdata = [ - {"text": "求和", "value": "SUM", "example": 'SUM'}, - {"text": "平均值", "value": "AVERAGE", "example": 'AVERAGE'}, - {"text": "计数", "value": "COUNT", "example": 'COUNT'}, - {"text": "最大值", "value": "MAX", "example": 'MAX'}, - {"text": "最小值", "value": "MIN", "example": 'MIN'}, + {"text": locale_formula.sum, "value": "SUM", "example": 'SUM'}, + {"text": locale_formula.average, "value": "AVERAGE", "example": 'AVERAGE'}, + {"text": locale_formula.count, "value": "COUNT", "example": 'COUNT'}, + {"text": locale_formula.max, "value": "MAX", "example": 'MAX'}, + {"text": locale_formula.min, "value": "MIN", "example": 'MIN'}, {"text": "", "value": "split", "example": ""}, - {"text": "if公式生成器", "value": "if", "example": 'IF'}, - {"text": "函数查找 ...", "value": "formula", "example": ""} + {"text": locale_formula.ifGenerate, "value": "if", "example": 'IF'}, + {"text": locale_formula.find+" ...", "value": "formula", "example": ""} ]; let itemset = _this.createButtonMenu(itemdata); @@ -1951,7 +1954,7 @@ const menuButton = { let menu = replaceHtml(_this.menu, { "id": "function-menu", "item": itemset, "subclass": "", "sub": "" }); $("body").append(menu); - $menuButton = $("#" + menuButtonId).width(150); + $menuButton = $("#" + menuButtonId).width(180); $menuButton.find(".luckysheet-cols-menuitem").click(function(){ $menuButton.hide(); @@ -1972,10 +1975,10 @@ const menuButton = { } else{ if(isEditMode()){ - alert("该单元格函数不属于if公式!"); + alert(locale_formula.tipNotBelongToIf); } else{ - tooltip.info("该单元格函数不属于if公式!",""); + tooltip.info(locale_formula.tipNotBelongToIf,""); } return; } @@ -1990,10 +1993,10 @@ const menuButton = { //点击函数查找弹出框 if(Store.luckysheet_select_save.length == 0){ if(isEditMode()){ - alert("请选择单元格插入函数"); + alert(locale_formula.tipSelectCell); } else{ - tooltip.info("请选择单元格插入函数",""); + tooltip.info(locale_formula.tipSelectCell,""); } return; diff --git a/src/css/luckysheet-core.css b/src/css/luckysheet-core.css index 1aaebe5d5..b2f2db6cd 100644 --- a/src/css/luckysheet-core.css +++ b/src/css/luckysheet-core.css @@ -5752,7 +5752,7 @@ fieldset[disabled] a.btn { } #luckysheet-ifFormulaGenerator-dialog .ifAttr .attrBox label{ display: block; - width: 50px; + width: 100px; height: 100%; line-height: 30px; padding: 0 5px; diff --git a/src/locale/en.js b/src/locale/en.js index 7d2951d0e..b6254d843 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -71,11 +71,11 @@ export default { button: { confirm: 'OK', cancel: 'Cancel', - colse:"close" + close:"Close" }, paint:{ start: 'Paint format start', - end: 'ESC key to exit', + end: 'ESC', tipSelectRange:"Please select the range to be copied", tipNotMulti:"Cannot perform this operation on multiple selection range", @@ -676,5 +676,68 @@ export default { rimless: 'Rimless', bordered: 'Bordered', }, + formula:{ + sum:"Sum", + average:"Average", + count:"Count", + max:"Max", + min:"Min", + ifGenerate:"If formula generator", + find:"Learn more", + + tipNotBelongToIf:"This cell function does not belong to the if formula!", + tipSelectCell:"Please select the cell to insert the function", + + ifGenCompareValueTitle:"Comparison value", + ifGenSelectCellTitle:"Click to select cell", + ifGenRangeTitle:"Range", + ifGenRangeTo:"to", + ifGenRangeEvaluate:"Range evaluate", + ifGenSelectRangeTitle:"Click to select range", + ifGenCutWay:"Partition way", + ifGenCutSame:"Same Partition value", + ifGenCutNpiece:"Partition by N", + ifGenCutCustom:"Custom", + ifGenCutConfirm:"Confirm", + + ifGenTipSelectCell:"Select cells", + ifGenTipSelectCellPlace:"Please select cells", + + ifGenTipSelectRange:"Select range", + ifGenTipSelectRangePlace:"Please select range", + + ifGenTipNotNullValue:"The comparison value cannot be empty!", + ifGenTipLableTitile:"Label", + ifGenTipRangeNotforNull:"The range cannot be empty!", + ifGenTipCutValueNotforNull:"The partition value cannot be empty!", + ifGenTipNotGenCondition:"No conditions are available for generation!", + }, + formulaMore:{ + valueTitle:"Value", + tipSelectDataRange:"Select data range", + tipDataRangeTile:"Data range", + findFunctionTitle:"Search function", + tipInputFunctionName:"Function name or brief description of function", + + "Array":"Array", + "Database":"Database", + "Date":"Date", + "Engineering":"Engineering", + "Filter":"Filter", + "Financial":"Financial", + "luckysheet":"Luckysheet", + "other":"Other", + "Logical":"Logical", + "Lookup":"Lookup", + "Math":"Math", + "Operator":"Operator", + "Parser":"Parser", + "Statistical":"Statistical", + "Text":"Text", + "dataMining":"DataMining", + + "selectFunctionTitle":"Select a function", + "calculationResult":"Result", + } }; \ No newline at end of file diff --git a/src/locale/zh.js b/src/locale/zh.js index f880de2b1..2872c7660 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -71,7 +71,7 @@ export default { button: { confirm: '确定', cancel: '取消', - colse:"关闭" + close:"关闭" }, paint: { start: '格式刷开启', @@ -685,4 +685,67 @@ export default { rimless: '无边框', bordered: '有边框', }, + formula:{ + sum:"求和", + average:"平均值", + count:"计数", + max:"最大值", + min:"最小值", + ifGenerate:"if公式生成器", + find:"更多函数", + + tipNotBelongToIf:"该单元格函数不属于if公式!", + tipSelectCell:"请选择单元格插入函数", + + ifGenCompareValueTitle:"比较值", + ifGenSelectCellTitle:"点击选择单元格", + ifGenRangeTitle:"范围", + ifGenRangeTo:"至", + ifGenRangeEvaluate:"范围评估", + ifGenSelectRangeTitle:"点击选择范围", + ifGenCutWay:"划分方式", + ifGenCutSame:"划分值相同", + ifGenCutNpiece:"划分为N份", + ifGenCutCustom:"自定义输入", + ifGenCutConfirm:"生成", + + ifGenTipSelectCell:"选择单元格", + ifGenTipSelectCellPlace:"请选择单元格", + + ifGenTipSelectRange:"选择单范围", + ifGenTipSelectRangePlace:"请选择范围", + + ifGenTipNotNullValue:"比较值不能为空!", + ifGenTipLableTitile:"标签", + ifGenTipRangeNotforNull:"范围不能为空!", + ifGenTipCutValueNotforNull:"划分值不能为空!", + ifGenTipNotGenCondition:"没有生成可用的条件!", + }, + formulaMore:{ + valueTitle:"值", + tipSelectDataRange:"选取数据范围", + tipDataRangeTile:"数据范围", + findFunctionTitle:"查找函数", + tipInputFunctionName:"请输入您要查找的函数名称或函数功能的简要描述", + + "Array":"数组", + "Database":"数据源", + "Date":"日期", + "Engineering":"工程计算", + "Filter":"过滤器", + "Financial":"财务", + "luckysheet":"Luckysheet内置", + "other":"其它", + "Logical":"逻辑", + "Lookup":"查找", + "Math":"数学", + "Operator":"运算符", + "Parser":"转换工具", + "Statistical":"统计", + "Text":"文本", + "dataMining":"数据挖掘", + + "selectFunctionTitle":"选择函数", + "calculationResult":"计算结果", + } };