Default resource translation to key value if missing

This commit is contained in:
Tomaž Jerman
2021-09-22 11:26:14 +02:00
parent 04c6b7f1ac
commit 10d4152ad6
3 changed files with 17 additions and 1 deletions
@@ -88,6 +88,8 @@ func (r *{{ .Resource }}) DecodeTranslations(tt locale.ResourceTranslationIndex)
{{- if not .Custom }}
if aux = tt.FindByKey(LocaleKey{{ $Resource }}{{coalesce (export .Name) (export .Path) }}.Path); aux != nil {
r.{{ .Field }} = aux.Msg
} else {
r.{{ .Field }} = LocaleKey{{ $Resource }}{{coalesce (export .Name) (export .Path) }}.Path
}
{{- end}}
{{- end}}
+1 -1
View File
@@ -99,7 +99,7 @@ func (l *Language) tResource(ns, key string, rr ...string) string {
return l.extends.tResource(ns, key, rr...)
}
return ""
return key
}
// resourceTranslations returns all resource translations for the specified resource