From 907226c74297882896f527b9c54a88a11d592a4d Mon Sep 17 00:00:00 2001 From: wpxp123456 <2677556700@qq.com> Date: Fri, 24 Jul 2020 23:31:13 +0800 Subject: [PATCH] feat(zh-cn): zh-cn zh-cn --- src/controllers/conditionformat.js | 310 +++++++++++++++++------------ src/controllers/constant.js | 50 ++++- src/controllers/handler.js | 12 +- src/global/createdom.js | 2 +- src/locale/en.js | 77 ++++++- src/locale/zh.js | 77 ++++++- 6 files changed, 389 insertions(+), 139 deletions(-) diff --git a/src/controllers/conditionformat.js b/src/controllers/conditionformat.js index 29ae399..c9d3c6e 100644 --- a/src/controllers/conditionformat.js +++ b/src/controllers/conditionformat.js @@ -10,14 +10,55 @@ import { modelHTML, luckysheet_CFiconsImg } from './constant'; import server from './server'; import { selectionCopyShow } from './select'; import sheetmanage from './sheetmanage'; +import locale from '../locale/locale'; import Store from '../store'; //条件格式 const conditionformat = { fileClone: [], editorRule: null, //{"sheetIndex": sheetIndex,"itemIndex": itemIndex,"data": luckysheetfile[sheetIndex].luckysheet_conditionformat_save[itemIndex]} - ruleTypeHtml: '
基于各自值设置所有单元格的格式
只为包含以下内容的单元格设置格式
仅对排名靠前或靠后的数值设置格式
仅对高于或低于平均值的数值设置格式
仅对唯一值或重复值设置格式
', - textCellColorHtml: '
', + ruleTypeHtml: function(){ + const conditionformat_Text = locale().conditionformat; + + return `
+
+ + ${conditionformat_Text.ruleTypeItem1} +
+
+ + ${conditionformat_Text.ruleTypeItem2} +
+
+ + ${conditionformat_Text.ruleTypeItem3} +
+
+ + ${conditionformat_Text.ruleTypeItem4} +
+
+ + ${conditionformat_Text.ruleTypeItem5} +
+
`; + }, + textCellColorHtml: function(){ + const conditionformat_Text = locale().conditionformat; + + return `
+
+ + + +
+
+ + + +
+
`; + }, selectRange: [], selectStatus: false, dataBarList: [ @@ -1545,44 +1586,51 @@ const conditionformat = { administerRuleDialog: function(){ $("#luckysheet-modal-dialog-mask").show(); $("#luckysheet-administerRule-dialog").remove(); + + const conditionformat_Text = locale().conditionformat; //工作表 let opHtml = ''; for(let j = 0; j < Store.luckysheetfile.length; j++){ if(Store.luckysheetfile[j].status == "1"){ - opHtml += ''; + opHtml += ``; } else{ - opHtml += ''; + opHtml += ``; } } - let content = '
' + - '' + - '' + - '
' + - '
' + - '
' + - '' + - '' + - '' + - '
' + - '
' + - '
' + - '规则' + - '格式' + - '应用范围' + - '
' + - '
' + - '
' + - '
'; + let content = `
+ + +
+
+
+ + + +
+
+
+ ${conditionformat_Text.rule} + ${conditionformat_Text.format} + ${conditionformat_Text.applyRange} +
+
+
+
`; $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-administerRule-dialog", "addclass": "luckysheet-administerRule-dialog", - "title": "条件格式规则管理器", + "title": conditionformat_Text.manageRules, "content": content, - "botton": '', + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-administerRule-dialog") @@ -1609,9 +1657,8 @@ const conditionformat = { let ruleArr = _this.fileClone[getSheetIndex(index)].luckysheet_conditionformat_save; //条件格式规则集合 if(ruleArr != null && ruleArr.length > 0){ - let textColorHtml = ''; //文本颜色dom - let cellColorHtml = ''; //单元格颜色dom - + const conditionformat_Text = locale().conditionformat; + for(let i = 0; i < ruleArr.length; i++){ let type = ruleArr[i]["type"]; //规则类型 let format = ruleArr[i]["format"]; //规则样式 @@ -1620,17 +1667,17 @@ const conditionformat = { let ruleName; //规则名称 let formatHtml = ''; //样式dom if(type == "dataBar"){ - ruleName = "数据条"; + ruleName = conditionformat_Text.dataBar; formatHtml = ''; } else if(type == "colorGradation"){ - ruleName = "色阶"; + ruleName = conditionformat_Text.colorGradation; formatHtml = ''; } else if(type == "icons"){ - ruleName = "图标集"; + ruleName = conditionformat_Text.icons; formatHtml = ''; } @@ -1638,11 +1685,11 @@ const conditionformat = { ruleName = _this.getConditionRuleName(ruleArr[i].conditionName, ruleArr[i].conditionRange, ruleArr[i].conditionValue); if(format["textColor"] != null){ - formatHtml += ''; + formatHtml += ''; } if(format["cellColor"] != null){ - formatHtml += ''; + formatHtml += ''; } } @@ -1661,7 +1708,7 @@ const conditionformat = { '
' + formatHtml + '
' + '
' + '' + - '' + + '' + '
' + ''; @@ -1758,12 +1805,14 @@ const conditionformat = { v = conditionValue[0]; } + const conditionformat_Text = locale().conditionformat; + //返回条件格式规则名称 if(conditionName == "greaterThan"){ - return "单元格值 > " + v; + return conditionformat_Text.cellValue + " > " + v; } else if(conditionName == "lessThan"){ - return "单元格值 < " + v; + return conditionformat_Text.cellValue + " < " + v; } else if(conditionName == "betweenness"){ let v2; @@ -1773,47 +1822,49 @@ const conditionformat = { else{ v2 = conditionValue[1]; } - return "单元格值介于 "+ v +" 和 "+ v2 +" 之间"; + return conditionformat_Text.cellValue + " " + conditionformat_Text.between + " " + v + " " + conditionformat_Text.in + " " + v2 + " " + conditionformat_Text.between2; } else if(conditionName == "equal"){ - return "单元格值 = " + v; + return conditionformat_Text.cellValue + " = " + v; } else if(conditionName == "textContains"){ - return "单元格值包含 =" + v; + return conditionformat_Text.cellValue + conditionformat_Text.contain + " =" + v; } else if(conditionName == "occurrenceDate"){ return conditionValue; } else if(conditionName == "duplicateValue"){ if(conditionValue == "0"){ - return "重复值"; + return conditionformat_Text.duplicateValue; } if(conditionValue == "1"){ - return "唯一值"; + return conditionformat_Text.uniqueValue; } } else if(conditionName == "top10"){ - return "前 "+ v +" 个"; + return conditionformat_Text.top + " " + v + " " + conditionformat_Text.oneself; } else if(conditionName == "top10%"){ - return "前 "+ v +"% 个"; + return conditionformat_Text.top + " " + v + "% " + conditionformat_Text.oneself; } else if(conditionName == "last10"){ - return "后 "+ v +" 个"; + return conditionformat_Text.last + " " + v + " " + conditionformat_Text.oneself; } else if(conditionName == "last10%"){ - return "后 "+ v +"% 个"; + return conditionformat_Text.last + " " + v + "% " + conditionformat_Text.oneself; } else if(conditionName == "AboveAverage"){ - return "高于平均值"; + return conditionformat_Text.aboveAverage; } else if(conditionName == "SubAverage"){ - return "低于平均值"; + return conditionformat_Text.belowAverage; } }, newConditionRuleDialog: function(source){ let _this = this; + const conditionformat_Text = locale().conditionformat; + //规则说明 let ruleExplainHtml = _this.getRuleExplain(0); @@ -1823,9 +1874,9 @@ const conditionformat = { $("#luckysheet-newConditionRule-dialog").remove(); let content = '
' + - '
选择规则类型:
' + - _this.ruleTypeHtml + - '
编辑规则说明:
' + + '
' + conditionformat_Text.chooseRuleType + ':
' + + _this.ruleTypeHtml() + + '
' + conditionformat_Text.editRuleDescription + ':
' + '
' + ruleExplainHtml + '
' + @@ -1834,9 +1885,10 @@ const conditionformat = { $("body").append(replaceHtml(modelHTML, { "id": "luckysheet-newConditionRule-dialog", "addclass": "luckysheet-newEditorRule-dialog", - "title": "新建格式规则", + "title": conditionformat_Text.newFormatRule, "content": content, - "botton": '', + "botton": ` + `, "style": "z-index:100003" })); let $t = $("#luckysheet-newConditionRule-dialog") @@ -1914,7 +1966,7 @@ const conditionformat = { let content = '
' + '
选择规则类型:
' + - _this.ruleTypeHtml + + _this.ruleTypeHtml() + '
编辑规则说明:
' + '
' + ruleExplainHtml + @@ -2094,85 +2146,87 @@ const conditionformat = { }).show(); }, getRuleExplain: function(index){ - let textCellColorHtml = this.textCellColorHtml; + const conditionformat_Text = locale().conditionformat; + + let textCellColorHtml = this.textCellColorHtml(); let ruleExplainHtml; switch(index){ case 0: //基于各自值设置所有单元格的格式 - ruleExplainHtml = '
基于各自值设置所有单元格的格式:
' + - '
' + - '' + - '' + - '
' + - '
' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
'; + ruleExplainHtml = `
${conditionformat_Text.ruleTypeItem1}:
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
`; break; case 1: //只为包含以下内容的单元格设置格式 ruleExplainHtml = '
只为满足以下条件的单元格:
' + diff --git a/src/controllers/constant.js b/src/controllers/constant.js index 1cf06b5..fda50ca 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -424,7 +424,7 @@ function rightclickHTML(){
${rightclick.generateNewMatrix}
-
` +
`; } const pivottableconfigHTML = '
排序
排序依据
显示总计
', @@ -438,9 +438,53 @@ const pivottableconfigHTML = '
', filtermenuHTML = '
以A-Z升序排列
以Z-A降序排列
按颜色筛选
按条件过滤
按值过滤
全选 - 清除 - 反选
确 认
取 消
清除筛选
', - filtersubmenuHTML = '
单元格为空
单元格有数据
文本包含
文本不包含
文本开头为
文本结尾为
文本等于
日期等于
日期早于
日期晚于
大于
大于等于
小于
小于等于
等于
不等于
介于
不在其中
', - sheetconfigHTML = '
删除
复制
重命名
更改颜色
隐藏
取消隐藏
向左移
向右移
重置颜色
'; + filtersubmenuHTML = '
单元格为空
单元格有数据
文本包含
文本不包含
文本开头为
文本结尾为
文本等于
日期等于
日期早于
日期晚于
大于
大于等于
小于
小于等于
等于
不等于
介于
不在其中
'; +//底部 表格标签操作dom +function sheetconfigHTML(){ + const sheetconfig = locale().sheetconfig; + + return `
+
+
${sheetconfig.delete}
+
+
+
${sheetconfig.copy}
+
+
+
${sheetconfig.rename}
+
+
+
+ ${sheetconfig.changeColor} +
+
+ +
+
${sheetconfig.hide}
+
+
+
${sheetconfig.unhide}
+
+ +
+
${sheetconfig.moveLeft}
+
+
+
${sheetconfig.moveRight}
+
+
+
+
+
${sheetconfig.resetColor}
+
+
+
+ +
+
+
`; +} const luckysheetPivotTableHTML = '
数据透视表
编辑范围
选择需要添加到数据透视表的字段 清除
筛选
数值
'; diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 184e323..8649030 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -6468,8 +6468,8 @@ export default function luckysheetHandler() { hideAfterPaletteSelect: false, showSelectionPalette: true, maxPaletteSize: 10, - cancelText: "取消", - chooseText: "确定颜色", + cancelText: locale().sheetconfig.cancelText, + chooseText: locale().sheetconfig.chooseText, togglePaletteMoreText: "更多", togglePaletteLessText: "少于", clearText: "清除颜色选择", @@ -9656,9 +9656,11 @@ export default function luckysheetHandler() { let reg2Arr = regArr[i].match(reg2); - for(let j = 0; j < reg2Arr.length; j++){ - let cpValue = reg2Arr[j].replace(//g, "").replace(/<\/td>/g, ""); - cpRowArr.push(cpValue); + if(reg2Arr != null){ + for(let j = 0; j < reg2Arr.length; j++){ + let cpValue = reg2Arr[j].replace(//g, "").replace(/<\/td>/g, ""); + cpRowArr.push(cpValue); + } } cpDataArr.push(cpRowArr); diff --git a/src/global/createdom.js b/src/global/createdom.js index 976c6a0..34f7f1a 100644 --- a/src/global/createdom.js +++ b/src/global/createdom.js @@ -101,7 +101,7 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit $("body").append(inputHTML); $("body").append(replaceHtml(filtermenuHTML, { "menuid": "filter" })); $("body").append(replaceHtml(filtersubmenuHTML, { "menuid": "filter" })); - $("body").append(sheetconfigHTML); + $("body").append(sheetconfigHTML()); //批注 luckysheetPostil.buildAllPs(Store.flowdata); diff --git a/src/locale/en.js b/src/locale/en.js index 8f097a9..a193e0d 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -371,6 +371,81 @@ export default { byRow: 'By row', byCol: 'By column', generateNewMatrix: 'Generate new matrix', - } + }, + sheetconfig: { + delete: 'Delete', + copy: 'Copy', + rename: 'Rename', + changeColor: 'Change color', + hide: 'Hide', + unhide: 'Unhide', + moveLeft: 'Move left', + moveRight: 'Move right', + resetColor: 'Reset color', + cancelText: 'Cancel', + chooseText: 'Confirm color', + }, + conditionformat: { + rule: 'Rule', + newRule: 'New rule', + editRule: 'Edit rule', + deleteRule: 'Delete rule', + showRules: 'Show its formatting rules', + manageRules: 'Conditional Formatting Rule Manager', + format: 'Format', + applyRange: 'Apply range', + selectRange: 'Click to select application range', + ruleTypeItem1: 'Format all cells based on their respective values', + ruleTypeItem2: 'Only format cells that contain', + ruleTypeItem3: 'Format only the top or bottom numbers', + ruleTypeItem4: 'Format only values above or below the average', + ruleTypeItem5: 'Format only unique or repeated values', + textColor: 'Text color', + cellColor: 'Cell color', + confirm: 'Confirm', + cancel: 'Cancel', + close: 'Close', + sheet: 'Sheet', + currentSheet: 'CurrentSheet', + dataBar: 'dataBar', + dataBarColor: 'dataBar color', + colorGradation: 'colorGradation', + icons: 'icons', + cellValue: 'Cell value', + between: 'Between', + in: 'In', + between2: '', + contain: 'Contain', + duplicateValue: 'Duplicate value', + uniqueValue: 'Unique value', + top: 'Top', + last: 'Last', + oneself: '', + aboveAverage: 'Above average', + belowAverage: 'Below average', + chooseRuleType: 'Choose rule type', + editRuleDescription: 'Edit rule description', + newFormatRule: 'New format rule', + formatStyle: 'Format style', + fillType: 'Fill type', + color: 'Color', + twocolor: 'Two-color', + tricolor: 'Tricolor', + multicolor: 'Multi color', + grayColor: 'Gray color', + gradient: 'Gradient', + solid: 'Solid', + maxValue: 'Max value', + medianValue: 'Median value', + minValue: 'Min value', + threeWayArrow: 'Three-way arrow', + fourWayArrow: 'Four-way arrow', + fiveWayArrow: 'Five-way arrow', + threeTriangles: 'Three triangles', + threeColorTrafficLight: 'Three-color traffic light', + fourColorTrafficLight: 'Four-color traffic light', + rimless: 'Rimless', + bordered: 'Bordered', + }, }; \ No newline at end of file diff --git a/src/locale/zh.js b/src/locale/zh.js index e062e66..d415a3d 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -392,5 +392,80 @@ export default { byRow: '按行', byCol: '按列', generateNewMatrix: '生成新矩阵', - } + }, + sheetconfig: { + delete: '删除', + copy: '复制', + rename: '重命名', + changeColor: '更改颜色', + hide: '隐藏', + unhide: '取消隐藏', + moveLeft: '向左移', + moveRight: '向右移', + resetColor: '重置颜色', + cancelText: '取消', + chooseText: '确定颜色', + }, + conditionformat: { + rule: '规则', + newRule: '新建规则', + editRule: '编辑规则', + deleteRule: '删除规则', + showRules: '显示其格式规则', + manageRules: '条件格式规则管理器', + format: '格式', + applyRange: '应用范围', + selectRange: '点击选择应用范围', + ruleTypeItem1: '基于各自值设置所有单元格的格式', + ruleTypeItem2: '只为包含以下内容的单元格设置格式', + ruleTypeItem3: '仅对排名靠前或靠后的数值设置格式', + ruleTypeItem4: '仅对高于或低于平均值的数值设置格式', + ruleTypeItem5: '仅对唯一值或重复值设置格式', + textColor: '文本颜色', + cellColor: '单元格颜色', + confirm: '确定', + cancel: '取消', + close: '关闭', + sheet: '表', + currentSheet: '当前工作表', + dataBar: '数据条', + dataBarColor: '数据条颜色', + colorGradation: '色阶', + icons: '图标集', + cellValue: '单元格值', + between: '介于', + in: '和', + between2: '之间', + contain: '包含', + duplicateValue: '重复值', + uniqueValue: '唯一值', + top: '前', + last: '后', + oneself: '个', + aboveAverage: '高于平均值', + belowAverage: '低于平均值', + chooseRuleType: '选择规则类型', + editRuleDescription: '编辑规则说明', + newFormatRule: '新建格式规则', + formatStyle: '格式样式', + fillType: '填充类型', + color: '颜色', + twocolor: '双色', + tricolor: '三色', + multicolor: '彩色', + grayColor: '灰色', + gradient: '渐变', + solid: '实心', + maxValue: '最大值', + medianValue: '中间值', + minValue: '最小值', + threeWayArrow: '三向箭头', + fourWayArrow: '四向箭头', + fiveWayArrow: '五向箭头', + threeTriangles: '3个三角形', + threeColorTrafficLight: '三色交通灯', + fourColorTrafficLight: '四色交通灯', + rimless: '无边框', + bordered: '有边框', + }, };