Documentation
¶
Index ¶
- Constants
- func FromContext(ctx context.Context) *i18n.Localizer
- func LangFromContext(ctx context.Context) string
- func LangMiddleware(bundle *i18n.Bundle) func(http.Handler) http.Handler
- func NewBundle() (*i18n.Bundle, error)
- func SetLocalizer(ctx context.Context, l *i18n.Localizer, lang string) context.Context
- func T(ctx context.Context, messageID string, tplData ...map[string]any) string
- func TN(ctx context.Context, messageID string, count int, tplData ...map[string]any) string
Constants ¶
View Source
const ( LangNB = "nb" LangNN = "nn" LangEN = "en" DefaultLang = LangNB CookieName = "vigil_lang" )
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext returns the Localizer stored in ctx, or nil if not set.
func LangFromContext ¶
LangFromContext returns the resolved language tag string, or DefaultLang if not set.
func LangMiddleware ¶
LangMiddleware detects the preferred language via cookie → Accept-Language → default, then injects a *i18n.Localizer into the request context.
func NewBundle ¶
NewBundle loads all embedded locale files and returns a bundle safe for concurrent use.
func SetLocalizer ¶
SetLocalizer stores both the localizer and the resolved language string in ctx.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.