Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Translations ¶
type Translations struct {
// contains filtered or unexported fields
}
Translations holds all loaded translations keyed by language code.
func NewTranslations ¶
func NewTranslations() *Translations
NewTranslations creates a new Translations instance.
func (*Translations) Load ¶
func (a *Translations) Load(efs embed.FS, lang, path string) error
Load parses a YAML file from the embedded FS and registers it under the given language code.
func (*Translations) T ¶
func (a *Translations) T(lang, key string) string
T returns the translation for a dot-separated key in the given language. Falls back to the key itself if not found. Example: T("de", "nav.dashboard") -> "Dashboard"
func (*Translations) TMap ¶
func (a *Translations) TMap(lang string, keys ...string) map[string]string
TMap returns a map of translations for a given language and list of keys. This is useful for passing a pre-resolved translation map to templates. Example: TMap("de", "nav.dashboard", "nav.availability", "action.logout") Returns: map[string]string{"nav.dashboard": "Dashboard", "nav.availability": "Verfügbarkeit", ...}