l10n and bot command auto generation; v0.6.0

This commit is contained in:
2026-02-18 11:39:20 +03:00
parent bb51a0ecb1
commit b2bda02c0f
11 changed files with 182 additions and 102 deletions

27
l10n.go Normal file
View File

@@ -0,0 +1,27 @@
package laniakea
// DictEntry {key:{ru:123,en:123}}
type DictEntry map[string]string
type L10n struct {
entries map[string]DictEntry
fallbackLang string
}
func NewL10n(fallbackLanguage string) *L10n {
return &L10n{make(map[string]DictEntry), fallbackLanguage}
}
func (l *L10n) AddDictEntry(key string, value DictEntry) *L10n {
l.entries[key] = value
return l
}
func (l *L10n) GetFallbackLanguage() string {
return l.fallbackLang
}
func (l *L10n) Translate(lang, key string) string {
s, ok := l.entries[key]
if !ok {
return key
}
return s[lang]
}