log.Error on missing translation
This commit is contained in:
parent
e43c6cd9df
commit
ca209a04b1
|
@ -114,16 +114,22 @@ func (l *locale) TrString(trKey string, trArgs ...any) string {
|
||||||
format := trKey
|
format := trKey
|
||||||
|
|
||||||
idx, ok := l.store.trKeyToIdxMap[trKey]
|
idx, ok := l.store.trKeyToIdxMap[trKey]
|
||||||
|
found := false
|
||||||
if ok {
|
if ok {
|
||||||
if msg, ok := l.idxToMsgMap[idx]; ok {
|
if msg, ok := l.idxToMsgMap[idx]; ok {
|
||||||
format = msg // use the found translation
|
format = msg // use the found translation
|
||||||
|
found = true
|
||||||
} else if def, ok := l.store.localeMap[l.store.defaultLang]; ok {
|
} else if def, ok := l.store.localeMap[l.store.defaultLang]; ok {
|
||||||
// try to use default locale's translation
|
// try to use default locale's translation
|
||||||
if msg, ok := def.idxToMsgMap[idx]; ok {
|
if msg, ok := def.idxToMsgMap[idx]; ok {
|
||||||
format = msg
|
format = msg
|
||||||
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !found {
|
||||||
|
log.Error("Missing translation %q", trKey)
|
||||||
|
}
|
||||||
|
|
||||||
msg, err := Format(format, trArgs...)
|
msg, err := Format(format, trArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue