locale

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithLocalizer

func ContextWithLocalizer(parent context.Context, l *i18n.Localizer) context.Context

ContextWithLocalizer adds localizer into context as a value. Use LocalizerFromContext to recover it later.

func EncodeDuration added in v0.2.1

func EncodeDuration(d time.Duration) string

EncodeDuration returns a string representing the duration in the form "1w4d2h3m5s". Units with 0 values aren't returned, for example: 1d1ms is 1 day 1 milliseconds

func IsValidLanguageTag added in v0.2.1

func IsValidLanguageTag(t language.Tag) bool

func LocalizeError

func LocalizeError(err error, lc *i18n.Localizer) string

func LocalizerFromContext

func LocalizerFromContext(ctx context.Context) (l *i18n.Localizer, ok bool)

LocalizerFromContext raises request-scoped localizer from context. Returns `<nil>, false` if there is no localizer in context.

func ParseDuration added in v0.2.1

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

Types

type Localizable

type Localizable interface {
	Localize(*i18n.Localizer) (string, error)
}

Jump to

Keyboard shortcuts

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