Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
func NewTranslator ¶
func NewTranslator(defaultLang string) (*Translator, error)
NewTranslator creates a new Translator using the embedded locales.
func NewTranslatorFromFS ¶
func NewTranslatorFromFS(localesFS fs.FS, defaultLang string) (*Translator, error)
NewTranslatorFromFS creates a new Translator from a given filesystem. This is useful for testing or loading locales from a custom location.
func (*Translator) Get ¶
func (t *Translator) Get(lang, key string, args ...interface{}) string
func (*Translator) GetTemplate ¶ added in v0.5.0
func (t *Translator) GetTemplate(lang, key string, data any) (string, error)
GetTemplate returns a localized string with named placeholders filled from data. Uses text/template syntax: {{.FieldName}} This is preferred over Get() with positional args for complex prompts.
Click to show internal directories.
Click to hide internal directories.