panel/shared/i18n.go

37 lines
730 B
Go
Raw Normal View History

2024-11-03 21:33:08 +01:00
package shared
import "github.com/nicksnyder/go-i18n/v2/i18n"
var I18nLocalizer *i18n.Localizer
type TranslateOptions struct {
TemplateData interface{}
PluralCount interface{}
Zero string
One string
Two string
Few string
Many string
Other string
}
func T(id string, options *TranslateOptions) string {
localizedStr := I18nLocalizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: id,
Zero: options.Zero,
One: options.One,
Two: options.Two,
Few: options.Few,
Many: options.Many,
Other: options.Other,
},
TemplateData: options.TemplateData,
PluralCount: options.PluralCount,
})
return localizedStr
}