Skip to content

Commit c668142

Browse files
committed
Using comment with i18n-check: to match dynamic translation keys
1 parent 0421568 commit c668142

File tree

17 files changed

+77
-42
lines changed

17 files changed

+77
-42
lines changed

models/actions/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func (r *ActionRunner) StatusName() string {
114114
}
115115

116116
func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string {
117+
// i18n-check: actions.runners.status.*
117118
return lang.TrString("actions.runners.status." + r.StatusName())
118119
}
119120

models/actions/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (s Status) String() string {
4343

4444
// LocaleString returns the locale string name of the Status
4545
func (s Status) LocaleString(lang translation.Locale) string {
46+
// i18n-check: actions.status.*
4647
return lang.TrString("actions.status." + s.String())
4748
}
4849

models/git/commit_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {
206206

207207
// LocaleString returns the locale string name of the Status
208208
func (status *CommitStatus) LocaleString(lang translation.Locale) string {
209+
// i18n-check: repo.commitstatus.*
209210
return lang.TrString("repo.commitstatus." + status.State.String())
210211
}
211212

models/issues/comment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,13 @@ const (
225225

226226
// LocaleString returns the locale string name of the role
227227
func (r RoleInRepo) LocaleString(lang translation.Locale) string {
228+
// i18n-check: repo.issues.role.*
228229
return lang.TrString("repo.issues.role." + string(r))
229230
}
230231

231232
// LocaleHelper returns the locale tooltip of the role
232233
func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
234+
// i18n-check: repo.issues.role.*_helper
233235
return lang.TrString("repo.issues.role." + string(r) + "_helper")
234236
}
235237

modules/auth/password/password.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func BuildComplexityError(locale translation.Locale) template.HTML {
128128
buffer.WriteString("<ul>")
129129
for _, c := range requiredList {
130130
buffer.WriteString("<li>")
131+
// i18n-check: form.password_*
131132
buffer.WriteString(locale.TrString(c.TrNameOne))
132133
buffer.WriteString("</li>")
133134
}

modules/translation/i18n/localestore.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func (l *locale) TrHTML(trKey string, trArgs ...any) template.HTML {
144144
args[i] = template.HTMLEscapeString(fmt.Sprint(v))
145145
}
146146
}
147+
// i18n-check: ignore
147148
return template.HTML(l.TrString(trKey, args...))
148149
}
149150

modules/translation/translation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ func (l *locale) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
238238
} else if t, ok := cnt.(int64); ok {
239239
c = t
240240
} else {
241+
// i18n-check: ignore
241242
return l.Tr(keyN, args...)
242243
}
243244

modules/web/middleware/binding.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ func Validate(errs binding.Errors, data map[string]any, f Form, l translation.Lo
104104

105105
trName := field.Tag.Get("locale")
106106
if len(trName) == 0 {
107+
// i18n-check: form.*
107108
trName = l.TrString("form." + field.Name)
108109
} else {
110+
// i18n-check: ignore
109111
trName = l.TrString(trName)
110112
}
111113

routers/web/admin/admin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ func DashboardPost(ctx *context.Context) {
180180
task := cron.GetTask(form.Op)
181181
if task != nil {
182182
go task.RunWithUser(ctx.Doer, nil)
183+
// i18n-check: admin.dashboard.*
183184
ctx.Flash.Success(ctx.Tr("admin.dashboard.task.started", ctx.Tr("admin.dashboard."+form.Op)))
184185
} else {
185186
ctx.Flash.Error(ctx.Tr("admin.dashboard.task.unknown", form.Op))

routers/web/repo/actions/view.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ func Run(ctx *context_module.Context) {
847847
})
848848
if err != nil {
849849
if errLocale := util.ErrorAsLocale(err); errLocale != nil {
850+
// i18n-check: ignore
850851
ctx.Flash.Error(ctx.Tr(errLocale.TrKey, errLocale.TrArgs...))
851852
ctx.Redirect(redirectURL)
852853
} else {

0 commit comments

Comments
 (0)