@@ -170,7 +170,7 @@
},
classifyCodeList () {
if (this.categoryList.length) {
- return [{ cnName: '所有', enName: 'all' }, ...this.categoryList, { cnName: '研发商店', enName: 'store' }]
+ return [{ cnName: this.$t('所有'), enName: 'all' }, ...this.categoryList, { cnName: this.$t('研发商店'), enName: 'store' }]
}
return []
}
@@ -261,9 +261,9 @@
getSelectText (checkerSet, index) {
let txt = ''
if (this.classifyCode === 'store' && !checkerSet.projectInstalled) {
- txt = '安装'
+ txt = this.$t('安装')
} else {
- txt = this.checkIsSelected(checkerSet.checkerSetId) ? this.currentHoverItem === index ? '取消选中' : '已选中' : '选择'
+ txt = this.checkIsSelected(checkerSet.checkerSetId) ? this.currentHoverItem === index ? this.$t('取消选中') : this.$t('已选中') : this.$t('选择')
}
return txt
},
@@ -340,21 +340,21 @@
this.loading = true
this.$store.dispatch('install', params).then(res => {
if (res.code === '0') {
- this.$bkMessage({ theme: 'success', message: '安装成功' })
+ this.$bkMessage({ theme: 'success', message: this.$t('安装成功') })
this.refresh()
}
}).catch(e => {
this.$bkMessage({
- message: '安装失败',
+ message: this.$t('安装失败'),
theme: 'error'
})
})
},
getToolTips (hasMultiLang, notCurLang) {
if (hasMultiLang) {
- return '该规则集不适用于当前插件'
+ return this.$t('该规则集不适用于当前插件')
} else if (notCurLang) {
- return '该规则集不适用于当前插件已选择的语言'
+ return this.$t('该规则集不适用于当前插件已选择的语言')
}
return { disabled: true }
},
diff --git a/src/frontend/src/components/RuleSetSelect.vue b/src/frontend/src/components/RuleSetSelect.vue
index 0627519..a9b4fd8 100644
--- a/src/frontend/src/components/RuleSetSelect.vue
+++ b/src/frontend/src/components/RuleSetSelect.vue
@@ -2,7 +2,7 @@
diff --git a/src/frontend/src/data/task.json b/src/frontend/src/data/task.json
index 4fd8bc1..2453b62 100644
--- a/src/frontend/src/data/task.json
+++ b/src/frontend/src/data/task.json
@@ -1,228 +1,246 @@
{
- "input": {
- "languages": {
- "rule": {},
- "type": "atom-checkbox-list",
- "required": true,
- "label": "工程语言",
- "list": [],
- "default": [],
- "desc": "不同代码语言,可选择相匹配的工具",
- "tabName": "basic"
- },
- "tools": {
- "rule": {},
- "required": true,
- "hidden": true,
- "type": "atom-checkbox-list",
- "label": "代码检查工具",
- "list": [],
- "default": [],
- "tabName": "basic"
- },
- "asyncTask": {
- "rule": {},
- "type": "enum-input",
- "label": "执行方式",
- "list": [
- {
- "value": false,
- "label": "同步"
- },
- {
- "value": true,
- "label": "异步"
- }
- ],
- "default": false,
- "desc": "",
- "tabName": "main",
- "inline": true
- },
- "asyncTaskId": {
- "rule": {
- "asyncTaskRequired": true
- },
- "type": "task-select",
- "label": "任务",
- "required": true,
- "tabName": "async",
- "inline": true,
- "list": {},
- "default": "",
- "rely": {},
- "desc": "可选择CodeCC服务中自建任务,也可以直接输入任务ID。ID可从CodeCC链接中获取到,例如/codecc/myproj/task/25324/中的数字。支持流水线变量。"
- },
- "goPath": {
- "rule": {},
- "type": "vuex-input",
- "label": "GOPATH",
- "default": "",
- "required": false,
- "desc": "可帮助工具查找依赖库代码路径,更好地扫描告警",
- "placeholder": "${WORKSPACE}下相对路径,多路径请用英文逗号分割,支持使用流水线变量",
- "tabName": "basic",
- "inline": true,
- "rely": {
- "operation": "AND",
- "expression": [
- {
- "key": "tools",
- "value": "GOML"
- }
- ]
- }
- },
- "pyVersion": {
- "rule": {},
- "type": "enum-input",
- "label": "Python版本",
- "required": true,
- "list": [
- {
- "label": "Python2",
- "value": "py2"
- },
- {
- "label": "Python3",
- "value": "py3"
- }
- ],
- "default": "py3",
- "tabName": "basic",
- "inline": true,
- "rely": {
- "operation": "AND",
- "expression": [
- {
- "key": "tools",
- "value": "PYLINT"
- }
- ]
- }
- },
- "scriptType": {
- "rule": {},
- "type": "enum-input",
- "label": "脚本类型",
- "required": true,
- "hidden": false,
- "list": [
- {
- "id": "sh",
- "value": "SHELL",
- "label": "Shell"
- }
- ],
- "default": "SHELL",
- "tabName": "basic",
- "lang": "sh",
- "inline": true
- },
- "script": {
- "rule": {
- "scriptRequired": true
- },
- "label": "脚本内容",
- "hidden": false,
- "default": "# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.sh\n# 确保build.sh能够编译代码\n# cd path/to/build.sh\n# sh build.sh",
- "required": true,
- "type": "atom-ace-editor",
- "desc": "相应工具将使用该脚本编译代码,以便追踪编译过程,发现代码缺陷",
- "tabName": "basic"
- },
- "languageRuleSetMap": {
- "hidden": true,
- "default": {}
- },
- "C_CPP_RULE": {
- "rule": {
- "ruleSetRequired": true
- },
- "type": "rule-set-select",
- "label": "C/C++",
- "required": true,
- "tabName": "basic",
- "inline": true,
- "list": {},
- "default": [],
- "rely": {
- "operation": "AND",
- "expression": [
- {
- "key": "languages",
- "value": "C_CPP"
- }
- ]
- }
- },
- "toolScanType": {
- "rule": {},
- "type": "radio-group",
- "label": "扫描方式",
- "required": true,
- "list": [
- {
- "label": "增量扫描(推荐)",
- "value": "1"
- },
- {
- "label": "MR/PR扫描",
- "value": "2"
- },
- {
- "label": "全量扫描",
- "value": "0"
- }
- ],
- "default": "1",
- "desc": "增量扫描:扫描本次构建与上次构建的差异代码。首次为全量扫描。\nMR/PR扫描:扫描MR/PR的源分支与目标分支的差异代码。源分支代码需拉取到工作空间。\n全量扫描:扫描全部代码。Klocwork、Pinpoint、Gometalinter、重复率仅支持该扫描方式。"
- },
- "mrCommentEnable": {
- "label": "",
- "default": true,
- "type": "atom-checkbox",
- "text": "将扫描出的问题同步到工蜂代码查看页面"
- },
- "newDefectJudgeFromDate": {
- "default": "",
- "label": "新告警判定",
- "desc": "所选日期之后产生的告警为新告警"
- },
- "transferAuthorList": {
- "default": [],
- "type": "author-transfer",
- "label": "处理人转换",
- "desc": "各工具原处理人的告警都将自动转给新处理人"
- },
- "path": {
- "default": [],
- "type": "item-edit"
- },
- "customPath": {
- "default": [],
- "type": "item-edit"
- },
- "openScanPrj": {
- "label": "",
- "default": false,
- "placeholder": "",
- "type": "atom-checkbox",
- "text": "是否是开源扫描项目",
- "desc": "选中则走开源扫描流程",
- "required": false,
- "disabled": false,
- "hidden": true
+ "atomCode": "CodeCCCheckAtom",
+ "execution": {
+ "packagePath": "CodeCCCheckAtom.jar",
+ "language": "java",
+ "minimumVersion": "1.8",
+ "deFmands": [],
+ "target": "$bk_java_path -Dfile.encoding=utf8 -jar CodeCCCheckAtom.jar"
+ },
+ "input": {
+ "languages": {
+ "rule": {},
+ "type": "atom-checkbox-list",
+ "required": true,
+ "label": "Programming Language",
+ "list": [],
+ "default": [],
+ "desc": "tools will match different programming language",
+ "tabName": "basic"
+ },
+ "tools": {
+ "rule": {},
+ "required": true,
+ "hidden": true,
+ "type": "atom-checkbox-list",
+ "label": "Code Review Tool",
+ "list": [],
+ "default": [],
+ "tabName": "basic"
+ },
+ "asyncTask": {
+ "rule": {},
+ "type": "enum-input",
+ "label": "Sync Method",
+ "list": [
+ {
+ "value": false,
+ "label": "Synchronize"
+ },
+ {
+ "value": true,
+ "label": "Asynchronous"
}
+ ],
+ "default": false,
+ "desc": "",
+ "tabName": "main",
+ "inline": true
},
- "output": {
- "BK_CI_CODECC_TASK_ID": {
- "type": "string",
- "description": "CodeCC的任务id"
- },
- "BK_CI_CODECC_TASK_STATUS": {
- "type": "string",
- "description": "CodeCC任务是否运行成功,成功则未true,不然取不到"
+ "asyncTaskId": {
+ "rule": {
+ "asyncTaskRequired": true
+ },
+ "type": "task-select",
+ "label": "Task",
+ "required": true,
+ "tabName": "async",
+ "inline": true,
+ "list": {},
+ "default": "",
+ "rely": {},
+ "desc": "You can choose to create a task yourself in the CodeCC service, or you can directly enter the task ID. The task ID can be obtained from the CodeCC link (in /codecc/myproj/task/25324/, 25324 is the task ID). Support pipeline variables."
+ },
+ "goPath": {
+ "rule": {},
+ "type": "vuex-input",
+ "label": "GOPATH",
+ "default": "",
+ "required": false,
+ "desc": "Help find the code path of the dependent library to get a more useful result",
+ "placeholder": "Relative paths under {WORKSPACE}, please use comma to separate multiple paths, support pipeline variables",
+ "tabName": "basic",
+ "inline": true,
+ "rely": {
+ "operation": "AND",
+ "expression": [
+ {
+ "key": "tools",
+ "value": "GOML"
+ }
+ ]
+ }
+ },
+ "pyVersion": {
+ "rule": {},
+ "type": "enum-input",
+ "label": "Python Version",
+ "required": true,
+ "list": [
+ {
+ "label": "Python2",
+ "value": "py2"
+ },
+ {
+ "label": "Python3",
+ "value": "py3"
+ }
+ ],
+ "default": "py3",
+ "tabName": "basic",
+ "inline": true,
+ "rely": {
+ "operation": "AND",
+ "expression": [
+ {
+ "key": "tools",
+ "value": "PYLINT"
+ }
+ ]
+ }
+ },
+ "scriptType": {
+ "rule": {},
+ "type": "enum-input",
+ "label": "Script Type",
+ "required": true,
+ "hidden": false,
+ "list": [
+ {
+ "id": "sh",
+ "value": "SHELL",
+ "label": "Shell"
+ }
+ ],
+ "default": "SHELL",
+ "tabName": "basic",
+ "lang": "sh",
+ "inline": true
+ },
+ "script": {
+ "rule": {
+ "scriptRequired": true
+ },
+ "label": "Script",
+ "hidden": false,
+ "default": "#Coverity/Klocwork will compile your code by calling the compilation script to identify defects\n# Please use build tools such as maven/cmake to write a compilation script build.sh\n# Make sure build.sh can compile the code\n# cd path/to/build.sh\n# sh build.sh",
+ "required": true,
+ "type": "atom-ace-editor",
+ "desc": "The corresponding tool will use this script to compile the code in order to track the compilation process and find code defects",
+ "tabName": "basic"
+ },
+ "languageRuleSetMap": {
+ "hidden": true,
+ "default": {}
+ },
+ "C_CPP_RULE": {
+ "rule": {
+ "ruleSetRequired": true
+ },
+ "type": "rule-set-select",
+ "label": "C/C++",
+ "required": true,
+ "tabName": "basic",
+ "inline": true,
+ "list": {},
+ "default": [],
+ "rely": {
+ "operation": "AND",
+ "expression": [
+ {
+ "key": "languages",
+ "value": "C_CPP"
+ }
+ ]
+ }
+ },
+ "multiPipelineMark": {
+ "rule": {},
+ "label": "label",
+ "placeholder": "Optional. Only numbers, letters, and underscores are supported.",
+ "type": "vuex-input",
+ "default": "",
+ "tabName": "basic",
+ "desc": "If the pipeline has multiple code analysis plugins, a label can be used to distinguish them.",
+ "inline": true
+ },
+ "toolScanType": {
+ "rule": {},
+ "type": "radio-group",
+ "label": "Scan Method",
+ "required": true,
+ "list": [
+ {
+ "label": "Incremental Scan(recommended)",
+ "value": "1"
+ },
+ {
+ "label": "MR/PR Scan",
+ "value": "2"
+ },
+ {
+ "label": "Full Scan",
+ "value": "0"
}
+ ],
+ "default": "1",
+ "desc": "Incremental scan: Scan the difference code between current build and previous build. Full scan will be used in the first time.\nMR/PR Scan: Scan the difference code between the source branch and the target branch of MR/PR. The source branch code needs to be pulled to the workspace\nFull Scan: Scan all codes. Klocwork, Pinpoint, Gometalinter, and repetition rate only support this scanning method."
+ },
+ "mrCommentEnable": {
+ "label": "",
+ "default": true,
+ "type": "atom-checkbox",
+ "text": "Sync the defect info to Tencent internal Git viewing page"
+ },
+ "newDefectJudgeFromDate": {
+ "default": "",
+ "label": "New Alerts Threshold",
+ "desc": "Alerts sent after the selected date are New Alerts"
+ },
+ "transferAuthorList": {
+ "default": [],
+ "type": "author-transfer",
+ "label": "change owner",
+ "desc": "Alerts will sent to the new owner when the tools's ownership changed "
+ },
+ "path": {
+ "default": [],
+ "type": "item-edit"
+ },
+ "customPath": {
+ "default": [],
+ "type": "item-edit"
+ },
+ "openScanPrj": {
+ "label": "",
+ "default": false,
+ "placeholder": "",
+ "type": "atom-checkbox",
+ "text": "use open sourced tool to scan project",
+ "desc": "Use open sourced scanning tool when selected",
+ "required": false,
+ "disabled": false,
+ "hidden": true
+ }
+ },
+ "output": {
+ "BK_CI_CODECC_TASK_ID": {
+ "type": "string",
+ "description": "CodeCC task id"
+ },
+ "BK_CI_CODECC_TASK_STATUS": {
+ "type": "string",
+ "description": "Whether the CodeCC task runs successfully"
}
+ }
}
\ No newline at end of file
diff --git a/src/frontend/src/i18n/index.js b/src/frontend/src/i18n/index.js
new file mode 100644
index 0000000..4d30398
--- /dev/null
+++ b/src/frontend/src/i18n/index.js
@@ -0,0 +1,46 @@
+import Vue from 'vue';
+import VueI18n from 'vue-i18n';
+import Cookies from 'js-cookie';
+import langMessages from './lang/messages';
+import { locale, lang } from 'bk-magic-vue';
+
+Vue.use(VueI18n);
+
+const languageMaps = {
+ zh_cn: 'zh-CN',
+ 'zh-cn': 'zh-CN',
+ zh: 'zh-CN',
+};
+
+const messages = {
+ 'zh-CN': Object.assign(lang.zhCN, langMessages['zh-CN']),
+ en: Object.assign(lang.enUS, langMessages.en),
+};
+
+let curLocale = Cookies.get('blueking_language') || 'zh-CN';
+curLocale = Object.prototype.hasOwnProperty.call(languageMaps, curLocale) ? languageMaps[curLocale] : curLocale;
+
+// console.log(locale, messages)
+
+const i18n = new VueI18n({
+ locale: curLocale,
+ fallbackLocale: 'zh-CN',
+ messages,
+ silentTranslationWarn: true, // 取消本地化失败时输出的警告
+ missing(locale, path) {
+ const parsedPath = i18n._path.parsePath(path) // eslint-disable-line
+ return parsedPath[parsedPath.length - 1];
+ },
+});
+
+locale.i18n((key, value) => i18n.t(key, value));
+
+export const toggleLang = () => {
+ i18n.locale = i18n.locale === 'zh-CN' ? 'en' : 'zh-CN';
+
+ Cookies.set('blueking_language', i18n.locale);
+};
+
+export const language = i18n.locale;
+
+export default i18n;
diff --git a/src/frontend/src/i18n/lang/cn.json b/src/frontend/src/i18n/lang/cn.json
new file mode 100644
index 0000000..d2f0842
--- /dev/null
+++ b/src/frontend/src/i18n/lang/cn.json
@@ -0,0 +1,9 @@
+{
+ "共x条规则": "共{sum}条规则",
+ "由x发布": "由{name}发布",
+ "字段不符合(x)正则表达式规则": "字段不符合({regex})正则表达式规则",
+ "字段长度不能超过x个字符": "字段长度不能超过{num}个字符",
+ "字段长度不能少于x个字符": "字段长度不能少于{num}个字符",
+ "最大不能超过x": "最大不能超过{num}",
+ "最小不能少于x": "最小不能少于{num}"
+}
diff --git a/src/frontend/src/i18n/lang/en.json b/src/frontend/src/i18n/lang/en.json
new file mode 100644
index 0000000..c5b14db
--- /dev/null
+++ b/src/frontend/src/i18n/lang/en.json
@@ -0,0 +1,71 @@
+{
+ "前往CodeCC": "Go to CodeCC",
+ "基础设置": "Basic",
+ "扫描配置": "Scan",
+ "路径屏蔽": "Filter",
+ "一": "Mon",
+ "二": "Tues",
+ "三": "Wed",
+ "四": "Thur",
+ "五": "Fri",
+ "六": "Sat",
+ "日": "Sun",
+ "收起": "Fold",
+ "展开": "Unfold",
+ "路径白名单": "Whitelist path",
+ "路径黑名单": "Blacklist path",
+ "Linux私有构建机/Mac/Win10需安装docker,Win7仅支持Coverity。": "Linux private build machine/Mac/Win10 needs to install docker, and Win7 only supports Coverity.",
+ "具体请见": "For details, please see",
+ "在此处关闭规则集弹框": "Close the rule set pop-up here",
+ "该规则集不适用于当前插件": "The rule set is not applicable to the current plugin",
+ "该规则集不适用于当前插件已选择的语言": "The rule set is not applicable to the language selected by the current plugin",
+ "我知道了": "I got it!",
+ "快速搜索": "Quick search",
+ "暂无描述": "No description",
+ "暂无数据": "Empty",
+ "创建规则集": "New rule set",
+ "由x发布": "Published by {name}",
+ "共x条规则": "{sum} rules in total",
+ "规则集": "Rule set",
+ "获取规则集失败": "Failed to get rule set",
+ "编译脚本": "Compile script",
+ "涉及工具": "Tools involved",
+ "所有": "All",
+ "安装": "Install",
+ "安装成功": "Install succeeded",
+ "安装失败": "Install failed",
+ "取消选中": "Uncheck",
+ "已选中": "Selected",
+ "选择": "Select",
+ "请选择": "Please select",
+ "研发商店": "R&D store",
+ "精选": "Picked",
+ "推荐": "Recommend",
+ "正在加载中": "Loading",
+ "无匹配数据": "No matching data",
+ "新增任务": "New task",
+ "新增路径": "New path",
+ "原处理人": "Original handler",
+ "目标处理人": "Target handler",
+ "添加处理人转换": "Configure handler conversion",
+ "选择规则集": "Please select rule set",
+ "请选择语言": "Please select languages",
+ "字段只能包含字母": "Field can only contain letters",
+ "字段不能为空": " Field cannot be empty",
+ "字段不能重复": "Field cannot be duplicate",
+ "字段不能包含英文逗号": "Field cannot contain English comma",
+ "字段只能包含数字,字母和下划线": "Field can only contain numbers, letters and underscores",
+ "只能以字母和下划线开头,同时只包含字母,数字以及下划线": "It can only start with letters and underscores, and only contain letters, numbers and underscores",
+ "字段只能包含数字": "Field can only contain numbers",
+ "字段不符合(x)正则表达式规则": "The field does not conform to the ({regex}) regular expression rule",
+ "字段长度不能超过x个字符": "Field length cannot exceed {num} characters",
+ "字段长度不能少于x个字符": "Field length cannot be less than {num} characters",
+ "最大不能超过x": "Maximum cannot exceed {num}",
+ "最小不能少于x": "Minimum cannot be less than {num}",
+ "规则集字段不能为空": "Rule set field cannot be empty",
+ "如流水线配置了质量红线请谨慎使用异步功能,可能会由于结果异步输出导致红线拦截": "If the pipeline is configured with a quality red line, please use the asynchronous function carefully. The red line may be blocked due to the asynchronous output of the result",
+ "以绝对路径/data/landun/workspace/CodeCCTest/cpp/为例:\n扫描相对路径可输入/CodeCCTest/cpp/,只输入/cpp/不会生效\n扫描某类文件如protobuffer生成的*.pb.cc,可以输入.*/.*\\.pb\\.cc\n扫描工作空间中某个文件夹如P2PLive,可以输入.*/P2PLive/.* \n只扫描某个文件夹下某类文件如P2PLive下*.c,可以输入.*/P2PLive/.*\\.c\n若一行中输入多个路径或路径匹配式可用英文逗号分隔\n支持流水线变量": "Take the absolute path /data/landun/workspace/CodeCCTest/cpp/\nas an example: The scan relative path can be entered /CodeCCTest/cpp/\nBut only /cpp/ will not take effect. Scan a certain type of file,\nSuch as *.pb.cc generated by protobuffer, and you can enter .*/.*\\.Pb\\.cc\nScan a folder in the workspace, such as P2PLive, you can enter. */P2PLive/*\nOnly scan a certain type of file under a folder, such as *.c under P2PLive,\nyou can enter .*/P2PLive/.*\\.c\nIf multiple paths are entered in a line or path matching can be separated by\nEnglish commas, and pipeline variables are supported",
+ "屏蔽某类文件如protobuffer生成的*.pb.cc,可以输入.*/.*\\.pb\\.cc\n屏蔽所有分支中某个文件夹如P2PLive,可以输入.*/P2PLive/.* \n屏蔽某个文件夹下某类文件如P2PLive下*.c,可以输入.*/P2PLive/.*\\.c\n若一行中输入多个路径匹配式可用英文逗号分隔\n支持流水线变量": "Exclude a certain type of file, such as *.pb.cc generated by protobuffer,\nand you can enter .*/.*\\.pb\\.cc\nMask a folder in all branches, such as P2PLive, you can enter .*/P2PLive/*\nExclude a certain type of file under a folder, such as *.c under P2PLive,\nyou can enter .*/P2PLive/.*\\.c\nIf multiple path matching types are entered in a line, they can be separated\nby English commas, and pipeline variables are supported",
+ "# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.bat\n# 确保build.bat能够编译代码\n# cd path/to/build.bat\n# call build.bat": "#Coverage/Klocwork will compile your code by calling the compilation script to track the deep-seated defects\n#Please use a dependent build tool such as maven/make to write a build script build.bat\n#Ensure that build.bat can compile code\n# cd path/to/build.bat\n# call build.bat",
+ "# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.sh\n# 确保build.sh能够编译代码\n# cd path/to/build.sh\n# sh build.sh": "#Coverage/Klocwork will compile your code by calling the compilation script to track the deep-seated defects.\n# Please write a compilation script build.sh using a dependent build tool such as maven/make\n# Ensure that build.sh can compile the code\n# cd path/to/build.sh\n# sh build.sh"
+}
diff --git a/src/frontend/src/i18n/lang/messages.js b/src/frontend/src/i18n/lang/messages.js
new file mode 100644
index 0000000..faf83a2
--- /dev/null
+++ b/src/frontend/src/i18n/lang/messages.js
@@ -0,0 +1,6 @@
+import en from './en.json'
+import cn from './cn.json'
+export default {
+ en,
+ 'zh-CN': cn,
+}
diff --git a/src/frontend/src/main.js b/src/frontend/src/main.js
index ea01187..95da479 100644
--- a/src/frontend/src/main.js
+++ b/src/frontend/src/main.js
@@ -12,6 +12,7 @@ import request from '@/utils/request'
import validDictionary from './utils/validDictionary'
import ExtendsCustomRules from './utils/customRules'
import store from './store/index'
+import i18n from './i18n';
// 全量引入 bk-magic-vue 样式
require('bk-magic-vue/dist/bk-magic-vue.min.css')
@@ -35,6 +36,7 @@ ExtendsCustomRules(VeeValidate.Validator.extend)
global.atomVue = new Vue({
el: '#pipeline-atom',
+ i18n,
components: {
PublicAtom,
LocalAtom
diff --git a/src/frontend/src/utils/customRules.js b/src/frontend/src/utils/customRules.js
index 2e86527..0bf4251 100644
--- a/src/frontend/src/utils/customRules.js
+++ b/src/frontend/src/utils/customRules.js
@@ -47,8 +47,8 @@ const customeRules = {
},
scriptRequired: {
validate: function (value, args) {
- const defValue1 = '# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.sh\n# 确保build.sh能够编译代码\n# cd path/to/build.sh\n# sh build.sh'
- const defValue2 = '# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.bat\n# 确保build.bat能够编译代码\n# cd path/to/build.bat\n# call build.bat'
+ const defValue1 = this.$t('# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.sh\n# 确保build.sh能够编译代码\n# cd path/to/build.sh\n# sh build.sh')
+ const defValue2 = this.$t('# Coverity/Klocwork将通过调用编译脚本来编译您的代码,以追踪深层次的缺陷\n# 请使用依赖的构建工具如maven/cmake等写一个编译脚本build.bat\n# 确保build.bat能够编译代码\n# cd path/to/build.bat\n# call build.bat')
return value !== defValue1 && value !== defValue2
}
}
diff --git a/src/frontend/src/utils/validDictionary.js b/src/frontend/src/utils/validDictionary.js
index 2b2a41b..272e9b9 100644
--- a/src/frontend/src/utils/validDictionary.js
+++ b/src/frontend/src/utils/validDictionary.js
@@ -1,31 +1,33 @@
+import i18n from "../i18n"
+
const dictionary = {
cn: {
messages: {
- alpha: field => '字段只能包含字母',
- required: field => '字段不能为空',
- unique: field => '字段不能重复',
- excludeComma: field => '字段不能包含英文逗号',
- string: field => '字段只能包含数字,字母和下划线',
- varRule: field => `只能以字母和下划线开头,同时只包含字母,数字以及下划线`,
- numeric: field => '字段只能包含数字',
+ alpha: field => i18n.t('字段只能包含字母'),
+ required: field => i18n.t('字段不能为空'),
+ unique: field => i18n.t('字段不能重复'),
+ excludeComma: field => i18n.t('字段不能包含英文逗号'),
+ string: field => i18n.t('字段只能包含数字,字母和下划线'),
+ varRule: field => i18n.t(`只能以字母和下划线开头,同时只包含字母,数字以及下划线`),
+ numeric: field => i18n.t('字段只能包含数字'),
regex: (field, regex) => {
- return `字段不符合(${regex})正则表达式规则`
+ return i18n.t('字段不符合(x)正则表达式规则', { regex: regex })
},
max: (field, args) => {
- return `字段长度不能超过${args}个字符`
+ return i18n.t('字段长度不能超过x个字符', { num: args })
},
min: (field, args) => {
- return `字段长度不能少于${args}个字符`
+ return i18n.t('字段长度不能少于x个字符', { num: args })
},
max_value: (field, args) => {
- return `最大不能超过${args}`
+ return i18n.t('最大不能超过x', { num: args })
},
min_value: (field, args) => {
- return `最小不能少于${args}`
+ return i18n.t('最小不能少于x', { num: args })
},
- ruleSetRequired: field => '规则集字段不能为空',
- scriptRequired: field => '字段不能为空',
- asyncTaskRequired: field => '字段不能为空'
+ ruleSetRequired: field => i18n.t('规则集字段不能为空'),
+ scriptRequired: field => i18n.t('字段不能为空'),
+ asyncTaskRequired: field => i18n.t('字段不能为空')
// customPath: field => '路径请以 .* 开头'
}
}