panel/shared/i18n.go
2024-11-03 15:33:08 -05:00

36 lines
730 B
Go

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
}