Documentation
¶
Overview ¶
Package localization provides experimental locale helpers for templates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Default is the fallback Localizer used when no localizer is configured. Default = Localizer(defaultLocalizer{locale: "en_US"}) )
Functions ¶
func Funcs ¶ added in v0.15.0
Funcs returns the locale and localizer helpers bound to l, for templates go-partial does not execute, such as the text part of an e-mail written with text/template: they give those templates what the Stage gives the templates go-partial renders.
text := texttemplate.New("mail").Funcs(texttemplate.FuncMap(localization.Funcs(localization.New("nl"))))
func Locale ¶
func Locale(ctx ...*partial.RenderContext) string
Locale returns the configured locale for a render context.
go-doc:sig func() string
func Stage ¶
func Stage() partial.RenderStage
Stage gives templates the locale and localizer helpers. They are made only for the templates that call them.
Types ¶
type Localizer ¶
type Localizer interface {
GetLocale() string
}
Localizer provides the active locale for a render.
func FromContext ¶
FromContext returns the configured Localizer or Default.
func LocalizerValue ¶
func LocalizerValue(ctx ...*partial.RenderContext) Localizer
LocalizerValue returns the configured localizer for a render context.
go-doc:sig func() github.com/donseba/go-partial/exp/localization.Localizer