Skip to content

Commit

Permalink
feat: 支持国际化 TencentBlueKing#26
Browse files Browse the repository at this point in the history
  • Loading branch information
eazence committed Jan 17, 2023
1 parent 4ff072f commit 37aad04
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 74 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/components/TaskSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</bk-input>
<div class="bk-options-wrapper" v-show="optionsVisible">
<ul class="bk-options">
<li class="bk-select-empty" v-if="optionsLoading">正在加载中...</li>
<li class="bk-select-empty" v-else-if="!filterTaskList || !filterTaskList.length">无匹配数据</li>
<li class="bk-select-empty" v-if="optionsLoading">{{$t('正在加载中')}}...</li>
<li class="bk-select-empty" v-else-if="!filterTaskList || !filterTaskList.length">{{$t('无匹配数据')}}</li>
<li
class="bk-option custom-option"
v-show="!optionsLoading && filterTaskList && filterTaskList.length"
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/src/i18n/lang/cn.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"共x条规则": "共{sum}条规则",
"由x发布": "由{name}发布"
"由x发布": "由{name}发布",
"字段不符合(x)正则表达式规则": "字段不符合({regex})正则表达式规则",
"字段长度不能超过x个字符": "字段长度不能超过{num}个字符",
"字段长度不能少于x个字符": "字段长度不能少于{num}个字符",
"最大不能超过x": "最大不能超过{num}",
"最小不能少于x": "最小不能少于{num}"
}
123 changes: 69 additions & 54 deletions src/frontend/src/i18n/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,56 +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",
"新增任务": "New task",
"新增路径": "New path",
"原处理人": "original handler",
"目标处理人": "Target handler",
"添加处理人转换": "Configure handler conversion",
"选择规则集": "Please select rule set",
"请选择语言": "Please select languages",
"如流水线配置了质量红线请谨慎使用异步功能,可能会由于结果异步输出导致红线拦截": "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"
"前往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"
}
4 changes: 2 additions & 2 deletions src/frontend/src/utils/customRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
32 changes: 17 additions & 15 deletions src/frontend/src/utils/validDictionary.js
Original file line number Diff line number Diff line change
@@ -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 => '路径请以 .* 开头'
}
}
Expand Down

0 comments on commit 37aad04

Please sign in to comment.