i18n

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMap = template.FuncMap{
	"quote": func(v any) string { return strconv.Quote(fmt.Sprint(v)) },
}

FuncMap contains the custom template functions used for rendering i18n templates.

Functions

This section is empty.

Types

type Bundle

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

func (Bundle) RenderEcode

func (b Bundle) RenderEcode(ecode string, data any) (*EcodeDetail, error)

func (Bundle) RenderMessage

func (b Bundle) RenderMessage(key string, data any) (string, error)

type EcodeDetail

type EcodeDetail struct {
	Desc   string       `yaml:"desc"`
	Text   string       `yaml:"text"`
	Help   string       `yaml:"help"`
	Fields []EcodeField `yaml:"fields"`
}

See https://rustc-dev-guide.rust-lang.org/diagnostics.html

type EcodeField added in v0.15.0

type EcodeField map[string]string

EcodeField maps field name -> field type

func (EcodeField) ImportPath added in v0.15.0

func (f EcodeField) ImportPath() string

ImportPath returns the import path.

func (EcodeField) Name added in v0.15.0

func (f EcodeField) Name() string

Name returns the field name.

func (EcodeField) Type added in v0.15.0

func (f EcodeField) Type() string

Type returns the field type.

func (EcodeField) Validate added in v0.15.0

func (f EcodeField) Validate() bool

type I18N added in v0.15.0

type I18N struct {
	// contains filtered or unexported fields
}
var Default *I18N

func (*I18N) Get added in v0.15.0

func (i *I18N) Get(lang language.Tag) *Bundle

func (*I18N) GetDefault added in v0.15.0

func (i *I18N) GetDefault() *Bundle

func (*I18N) RenderEcode added in v0.15.0

func (i *I18N) RenderEcode(lang language.Tag, ecode string, data any) *EcodeDetail

func (I18N) RenderMessage added in v0.15.0

func (i I18N) RenderMessage(lang language.Tag, key string, data any) string

Jump to

Keyboard shortcuts

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