Skip to content

Commit edad9a1

Browse files
authored
code coverage i18n (#2848)
1 parent fba8c94 commit edad9a1

File tree

21 files changed

+281
-83
lines changed

21 files changed

+281
-83
lines changed

conf/dop/dop.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ component-protocol.components.code-coverage.configForm:
7979
component-protocol.components.code-coverage.envFilter:
8080
component-protocol.components.code-coverage.configModal:
8181
component-protocol.components.code-coverage.configTip:
82+
component-protocol.components.code-coverage.executeHistory:
8283

8384
component-protocol.components.scenes-import-record.filter:
8485
component-protocol.components.scenes-import-record.table:

conf/dop/i18n/component-protocol.yaml

+86
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,49 @@ zh:
161161
quality_score_tip--coco_score_formula: 计算公式:最近一次代码覆盖率(不区分环境) * 100
162162
quality_score_tip--total: 总分
163163
quality_score_tip--total_score_formula: 计算公式:(手动测试计划 + 自动化测试计划 + 缺陷 DI + 缺陷重开率 + 代码覆盖率) / 5
164+
forced-cancel: 强制取消
165+
cancel-confirm: 强制取消将会导致明细和报告都不会生成!
166+
project-code-coverage-trend: 项目代码覆盖率趋势
167+
line-coverage: 行覆盖率
168+
statistics-object-configuration: 统计对象配置
169+
contain: 包含
170+
enter-contain-expression: 请输入包含表达式
171+
enter-not-contain-expression: 请输入不包含表达式
172+
enter-maven-expression: 请输入maven设置表达式
173+
code-coverage-statistics-range: 代码覆盖率统计范围设置
174+
download-report: 下载报告
175+
end: 结束
176+
dev-env: 开发环境
177+
test-env: 测试环境
178+
feature-env: 预发环境
179+
prod-env: 生产环境
180+
coverage-plugin-not-enable-tip: 当前环境未启用覆盖率插件,请参考
181+
coverage-processing-tip: 代码覆盖率统计进行中,开始和结束按钮不可用, 请等待(耗时取决于应用多少和大小),手动刷新后查看结果
182+
coverage-generating-tip: 代码覆盖率统计明细生成中,开始和结束按钮不可用, 请等待(耗时取决于应用多少和大小),手动刷新后查看结果
183+
enable-coverage-docs: 如何启用集成测试代码覆盖率统计
184+
report-generating: 报告生成中
185+
stop-by-user: 用户取消
186+
coverage-processing: 进行中
187+
coverage-ready: 进行中
188+
coverage-ending: 明细生成中
189+
coverage-success: 成功
190+
coverage-fail: 失败
191+
coverage-cancel: 用户取消
192+
current-line-coverage: 当前行覆盖率
193+
log: 日志
194+
statistics-starter: 统计开始者
195+
start-time: 开始时间
196+
statistics-finisher: 统计结束者
197+
statistics-end-time: 统计结束时间
198+
operate: 操作
199+
statistics-start: 开始
200+
within-a-week: 一周内
201+
within-a-month: 一个月内
202+
report-details: 报告详情
203+
coverage-statistics-record: 项目代码覆盖率统计执行记录
204+
execute-record: 执行记录
205+
tip-message: '说明: 代码覆盖率趋势主要反映测试用例覆盖项目(非单个或部分应用)的代码行数'
206+
config-tip-message: '说明:可以通过在包括和不包括中输入表达式来确定统计范围;多个表达式可以使用冒号 ( : ) 分隔, 且支持 * 通配符。\n 例子:org/apache* 将匹配所有以 org/apache 开头的源码目录, */model 将匹配所有以 model 结尾的目录, foo/*:bar/* 匹配所有以 foo 或者 bar 开头的目录'
164207
en:
165208
issue-manage: issue manage
166209
issue: issue
@@ -321,3 +364,46 @@ en:
321364
quality_score_tip--bug_reopen_score_formula: Formula:100 - Bug-Reopen-Rate * 100
322365
quality_score_tip--total: Total Score
323366
quality_score_tip--total_score_formula: Formula:(Score(Manual Test Plan) + Score(Auto Test Plan) + Score(Bug) + Score(Bug Reopen Rate) + Score(Code Coverage)) / 5
367+
forced-cancel: Force Cancel
368+
cancel-confirm: Forced cancellation will result in neither the details nor the report being generated!
369+
project-code-coverage-trend: Project code coverage trends
370+
line-coverage: Line coverage
371+
statistics-object-configuration: Statistics object configuration
372+
contain: Contain
373+
enter-contain-expression: Please enter an expression containing
374+
enter-not-contain-expression: Please enter an expression non-containing
375+
enter-maven-expression: Please enter maven setting expression
376+
code-coverage-statistics-range: Code coverage statistics range setting
377+
download-report: Download Report
378+
end: End
379+
dev-env: Development Environment
380+
test-env: Test Environment
381+
feature-env: Pre-release Environment
382+
prod-env: Production Environment
383+
coverage-plugin-not-enable-tip: The coverage plugin is not enabled in the current environment, please refer to
384+
coverage-processing-tip: Code coverage statistics are in progress, start and end buttons are unavailable, please wait (time-consuming depends on the number and size of the application), and check the results after manual refresh
385+
coverage-generating-tip: During code coverage statistics generation, the start and end buttons are unavailable, please wait (time-consuming depends on the number and size of the application), and check the results after manual refresh
386+
enable-coverage-docs: How to enable integration test code coverage statistics
387+
report-generating: Report generating
388+
stop-by-user: Stop By User
389+
coverage-processing: Processing
390+
coverage-ready: Processing
391+
coverage-ending: Detail generation
392+
coverage-success: Successfully
393+
coverage-fail: Failed
394+
coverage-cancel: User canceled
395+
current-line-coverage: Current line coverage
396+
log: Log
397+
statistics-starter: Statistics Starter
398+
start-time: Start Time
399+
statistics-finisher: Statistics Finisher
400+
statistics-end-time: Statistics End Time
401+
operate: Operate
402+
statistics-start: Start
403+
within-a-week: Within a week
404+
within-a-month: Within a month
405+
report-details: Report details
406+
coverage-statistics-record: Project code coverage statistics execution record
407+
execute-record: Execution record
408+
tip-message: 'Note: The trend of code coverage mainly reflects the number of lines of code of a project (not a single or partial application) covered by test cases'
409+
config-tip-message: 'Note: The statistical range can be determined by entering expressions in include and exclude; multiple expressions can be separated by colons (: ), and * wildcards are supported. \n Example: org/apache* will match all source directories starting with org/apache, */model will match all directories ending with model, and foo/*:bar/* will match all directories starting with foo or bar'

modules/dop/component-protocol/components/code-coverage/cancelButton/render.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
7474

7575
c.Type = "Button"
7676
c.Props = map[string]interface{}{
77-
"text": "强制取消",
77+
"text": cputil.I18n(ctx, "forced-cancel"),
7878
"type": "primary",
7979
}
8080
c.Operations = map[string]interface{}{
8181
"click": map[string]interface{}{
8282
"key": "click",
8383
"reload": true,
84-
"confirm": "强制取消将会导致明细和报告都不会生成!",
84+
"confirm": cputil.I18n(ctx, "cancel-confirm"),
8585
"disabled": disable,
8686
},
8787
}

modules/dop/component-protocol/components/code-coverage/codeCoverChart/render.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ type Operation struct {
8080
Meta map[string]interface{} `json:"meta"`
8181
}
8282

83-
func (ca *ComponentAction) setProps(data apistructs.CodeCoverageExecRecordData) {
83+
func (ca *ComponentAction) setProps(ctx context.Context, data apistructs.CodeCoverageExecRecordData) {
8484
ca.Type = "Chart"
8585
ca.Props = make(map[string]interface{})
86-
ca.Props["title"] = "项目代码覆盖率趋势"
86+
ca.Props["title"] = cputil.I18n(ctx, "project-code-coverage-trend")
8787
ca.Props["chartType"] = "line"
8888
var timeList []string
8989
var valueLst []PointValue
@@ -120,7 +120,7 @@ func (ca *ComponentAction) setProps(data apistructs.CodeCoverageExecRecordData)
120120
},
121121
"series": []interface{}{
122122
map[string]interface{}{
123-
"name": "行覆盖率",
123+
"name": cputil.I18n(ctx, "line-coverage"),
124124
"data": valueLst,
125125
"label": map[string]interface{}{
126126
"normal": map[string]interface{}{
@@ -218,7 +218,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
218218
if err != nil {
219219
return err
220220
}
221-
ca.setProps(recordRsp)
221+
ca.setProps(ctx, recordRsp)
222222
case cptype.InitializeOperation, cptype.DefaultRenderingKey:
223223
if len(ca.State.Value) < 2 {
224224
ca.setDefaultTimeRange()
@@ -240,7 +240,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
240240
if len(recordRsp.List) > 0 {
241241
ca.State.RecordID = recordRsp.List[len(recordRsp.List)-1].ID
242242
}
243-
ca.setProps(recordRsp)
243+
ca.setProps(ctx, recordRsp)
244244
ca.Operations = getOperations()
245245
case cptype.RenderingOperation:
246246
if len(ca.State.Value) < 2 {
@@ -263,7 +263,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
263263
if len(recordRsp.List) > 0 {
264264
ca.State.RecordID = recordRsp.List[len(recordRsp.List)-1].ID
265265
}
266-
ca.setProps(recordRsp)
266+
ca.setProps(ctx, recordRsp)
267267
}
268268
return nil
269269
}

modules/dop/component-protocol/components/code-coverage/configButton/render.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
9797

9898
c.Type = "Button"
9999
c.Props = map[string]interface{}{
100-
"text": "统计对象配置",
100+
"text": cputil.I18n(ctx, "statistics-object-configuration"),
101101
"type": "primary",
102102
}
103103
c.Operations = map[string]interface{}{

modules/dop/component-protocol/components/code-coverage/configForm/render.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,27 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
9999
c.Props = map[string]interface{}{
100100
"fields": []map[string]interface{}{
101101
{
102-
"label": "包含",
102+
"label": cputil.I18n(ctx, "contain"),
103103
"component": "input",
104104
"key": "include",
105105
"componentProps": map[string]interface{}{
106-
"placeholder": "请输入包含表达式",
106+
"placeholder": cputil.I18n(ctx, "enter-contain-expression"),
107107
},
108108
},
109109
{
110110
"label": "不包含",
111111
"component": "input",
112112
"key": "exclude",
113113
"componentProps": map[string]interface{}{
114-
"placeholder": "请输入不包含表达式",
114+
"placeholder": cputil.I18n(ctx, "enter-not-contain-expression"),
115115
},
116116
},
117117
{
118118
"label": "maven 设置",
119119
"component": "textarea",
120120
"key": "maven",
121121
"componentProps": map[string]interface{}{
122-
"placeholder": "请输入maven 设置表达式",
122+
"placeholder": cputil.I18n(ctx, "enter-maven-expression"),
123123
},
124124
},
125125
},

modules/dop/component-protocol/components/code-coverage/configModal/render.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
"github.com/erda-project/erda-infra/base/servicehub"
2121
"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
22+
"github.com/erda-project/erda-infra/providers/component-protocol/utils/cputil"
2223
"github.com/erda-project/erda/modules/openapi/component-protocol/components/base"
2324
)
2425

@@ -29,7 +30,7 @@ type ComponentAction struct {
2930
func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scenario cptype.Scenario, event cptype.ComponentEvent, gs *cptype.GlobalStateData) error {
3031
c.Type = "Modal"
3132
c.Props = map[string]interface{}{
32-
"title": "代码覆盖率统计范围设置",
33+
"title": cputil.I18n(ctx, "code-coverage-statistics-range"),
3334
"size": "big",
3435
"footer": nil,
3536
}

modules/dop/component-protocol/components/code-coverage/configTip/render.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,32 @@
1414

1515
package configTip
1616

17-
import "github.com/erda-project/erda/modules/openapi/component-protocol/components/base"
17+
import (
18+
"context"
19+
20+
"github.com/erda-project/erda-infra/base/servicehub"
21+
"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
22+
"github.com/erda-project/erda-infra/providers/component-protocol/utils/cputil"
23+
"github.com/erda-project/erda/modules/openapi/component-protocol/components/base"
24+
)
25+
26+
type ComponentAction struct {
27+
base.DefaultProvider
28+
}
29+
30+
func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scenario cptype.Scenario, event cptype.ComponentEvent, gs *cptype.GlobalStateData) error {
31+
c.Type = "Alert"
32+
c.Name = "tip"
33+
c.Props = map[string]interface{}{
34+
"type": "warning",
35+
"showIcon": false,
36+
"message": cputil.I18n(ctx, "config-tip-message"),
37+
}
38+
return nil
39+
}
1840

1941
func init() {
20-
base.InitProvider("code-coverage", "configTip")
42+
base.InitProviderWithCreator("code-coverage", "configTip", func() servicehub.Provider {
43+
return &ComponentAction{}
44+
})
2145
}

modules/dop/component-protocol/components/code-coverage/downloadButton/render.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import (
2121

2222
"github.com/sirupsen/logrus"
2323

24-
"github.com/erda-project/erda/apistructs"
25-
26-
"github.com/erda-project/erda/modules/dop/component-protocol/types"
27-
2824
"github.com/erda-project/erda-infra/base/servicehub"
2925
"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
26+
"github.com/erda-project/erda-infra/providers/component-protocol/utils/cputil"
27+
"github.com/erda-project/erda/apistructs"
28+
"github.com/erda-project/erda/modules/dop/component-protocol/types"
3029
"github.com/erda-project/erda/modules/dop/services/code_coverage"
3130
"github.com/erda-project/erda/modules/openapi/component-protocol/components/base"
3231
)
@@ -98,7 +97,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
9897
},
9998
}
10099
ca.Props = map[string]interface{}{
101-
"text": "下载报告",
100+
"text": cputil.I18n(ctx, "download-report"),
102101
"type": "link",
103102
"size": "small",
104103
"visible": visible,

modules/dop/component-protocol/components/code-coverage/endButton/render.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
102102

103103
c.Type = "Button"
104104
c.Props = map[string]interface{}{
105-
"text": "结束",
105+
"text": cputil.I18n(ctx, "end"),
106106
"type": "primary",
107107
}
108108

modules/dop/component-protocol/components/code-coverage/envFilter/render.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
6464
"options": []map[string]interface{}{
6565
{
6666
"key": apistructs.DevEnv,
67-
"text": "开发环境",
67+
"text": cputil.I18n(ctx, "dev-env"),
6868
},
6969
{
7070
"key": apistructs.TestEnv,
71-
"text": "测试环境",
71+
"text": cputil.I18n(ctx, "test-env"),
7272
},
7373
{
7474
"key": apistructs.StagingEnv,
75-
"text": "预发环境",
75+
"text": cputil.I18n(ctx, "feature-env"),
7676
},
7777
{
7878
"key": apistructs.ProdEnv,
79-
"text": "生产环境",
79+
"text": cputil.I18n(ctx, "prod-env"),
8080
},
8181
},
8282
}

modules/dop/component-protocol/components/code-coverage/errText/render.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
7676
}
7777
if !hasAddon {
7878

79-
disableTip = append(disableTip, "当前环境未启用覆盖率插件,请参考 ")
79+
disableTip = append(disableTip, cputil.I18n(ctx, "coverage-plugin-not-enable-tip"))
8080
disableTip = append(disableTip, "__change_cover_docs__")
8181

8282
jacocoDisable = true
@@ -109,11 +109,11 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
109109
if len(list.List) > 0 {
110110
record := list.List[0]
111111
if record.Status == apistructs.RunningStatus.String() {
112-
disableTip = append(disableTip, "代码覆盖率统计进行中,开始和结束按钮不可用, 请等待(耗时取决于应用多少和大小),手动刷新后查看结果")
112+
disableTip = append(disableTip, cputil.I18n(ctx, "coverage-processing-tip"))
113113
}
114114

115115
if record.Status == apistructs.EndingStatus.String() {
116-
disableTip = append(disableTip, "代码覆盖率统计明细生成中,开始和结束按钮不可用, 请等待(耗时取决于应用多少和大小),手动刷新后查看结果")
116+
disableTip = append(disableTip, cputil.I18n(ctx, "coverage-generating-tip"))
117117
}
118118
}
119119
}
@@ -126,7 +126,7 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
126126
"color": "rgba(0, 0, 0, 0.4)",
127127
},
128128
"value": map[string]interface{}{
129-
"text": getToolTip(disableTip),
129+
"text": getToolTip(ctx, disableTip),
130130
},
131131
}
132132
c.Operations = map[string]interface{}{
@@ -143,13 +143,13 @@ func (ca *ComponentAction) Render(ctx context.Context, c *cptype.Component, scen
143143
return nil
144144
}
145145

146-
func getToolTip(tips []string) []interface{} {
146+
func getToolTip(ctx context.Context, tips []string) []interface{} {
147147
var results = []interface{}{}
148148
for _, ti := range tips {
149149
if ti == "__change_cover_docs__" {
150150
results = append(results, map[string]interface{}{
151151
"operationKey": "gotoDoc",
152-
"text": "如何启用集成测试代码覆盖率统计",
152+
"text": cputil.I18n(ctx, "enable-coverage-docs"),
153153
"styleConfig": map[string]interface{}{
154154
"color": "#6a549e",
155155
},

0 commit comments

Comments
 (0)