3
0

Remove fallback to base language in case of missing translation

This commit is contained in:
Denis Arh
2021-10-21 16:10:15 +02:00
parent 20757e58fa
commit 4cd54a58f8
2 changed files with 15 additions and 4 deletions

View File

@@ -74,10 +74,14 @@ func (l *Language) t(ns, key string, rr ...string) string {
return strings.NewReplacer(rr...).Replace(msg)
}
// If translation is not found, try with language
// this language extends
if l.extends != nil {
return l.extends.t(ns, key, rr...)
}
// In case of untranslated string / missing translations,
// translation key is returned
return key
}
@@ -95,10 +99,12 @@ func (l *Language) tResource(ns, key string, rr ...string) string {
return strings.NewReplacer(rr...).Replace(rt.Msg)
}
if l.extends != nil {
return l.extends.tResource(ns, key, rr...)
}
// When translating resources we do not utilize
// language extensions like with static translations
// In case of untranslated string / missing translations,
// only empty string is returned (in contrast to static translations
// where a string with key is returned
return ""
}

View File

@@ -438,6 +438,8 @@ func (svc *service) t(tag language.Tag, ns, key string, rr ...string) string {
}
}
// In case of a missing language, translation
// key is returned
return key
}
@@ -449,7 +451,10 @@ func (svc *service) tResource(tag language.Tag, ns, key string, rr ...string) st
}
}
return key
// In case of a missing language, only empty string is
// returned (in contrast to static translations
// where a string with key is returned)
return ""
}
func hasTag(t language.Tag, tt []language.Tag) bool {