i18n

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Embedded

func Embedded() fs.FS

Embedded returns the embedded file system containing translation TOML files, rooted at the translations/ directory so callers can read "en.toml" directly.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog holds UI translation messages for all configured languages.

func NewCatalog

func NewCatalog(fsys fs.FS, languages []string) (*Catalog, error)

NewCatalog loads TOML translation files from fsys for each configured language. The primary language is the first entry in languages. Files are expected as <lang>.toml (e.g. "en.toml", "fr.toml"). Missing files are silently skipped as long as at least the primary language file exists.

func (*Catalog) T

func (c *Catalog) T(lang, key string) string

T returns the translation for key in the given language.

Fallback chain:

  1. lang → key
  2. primary language (first in languages config) → key
  3. "en" → key
  4. return key itself

Jump to

Keyboard shortcuts

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