translation

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocaleFromContext

func LocaleFromContext(ctx context.Context) (string, bool)

func LocaleToContext

func LocaleToContext(ctx context.Context, locale string) context.Context

func RegistryToContext

func RegistryToContext(ctx context.Context, registry Registry) context.Context

RegistryToContext ...

func SetGlobalRegistry

func SetGlobalRegistry(registry Registry)

Types

type Registry

type Registry interface {
	// MustGetErrorTemplate return error template by code. Panic if not found template by code or locale
	MustGetErrorTemplate(code string, locale string) *template.Template
	// GetErrorTemplate return error template by code
	GetErrorTemplate(code string, locale string) (*template.Template, error)
	// DefaultLocale return default locale
	DefaultLocale() string
	// SetDefaultLocale set default locale
	SetDefaultLocale(locale string)
	RegisterTemplate(code string, locale string, template *template.Template)
	RegisterLocale(locale locale)
}

Registry ...

func GlobalRegistry

func GlobalRegistry() Registry

func NewDefaultRegistry

func NewDefaultRegistry() Registry

func RegistryFromContext

func RegistryFromContext(ctx context.Context) (Registry, bool)

RegistryFromContext ...

Directories

Path Synopsis
locales
en
ru

Jump to

Keyboard shortcuts

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