i18n

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 4 Imported by: 0

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", ...}

Jump to

Keyboard shortcuts

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