i18n

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 8 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL