Add translation strings (#269)

This commit is contained in:
Thomas Miceli
2024-05-05 00:24:25 +02:00
committed by GitHub
parent 1aa94292db
commit e439d96e43
11 changed files with 194 additions and 107 deletions

View File

@ -112,6 +112,20 @@ func (store *LocaleStore) MatchTag(langs []language.Tag) string {
return "en-US"
}
func (l *Locale) String(key string, args ...any) string {
message := l.Messages[key]
if message == "" {
return Locales.Locales["en-US"].String(key, args...)
}
if len(args) == 0 {
return message
}
return fmt.Sprintf(message, args...)
}
func (l *Locale) Tr(key string, args ...any) template.HTML {
message := l.Messages[key]