Documentation
¶
Overview ¶
Package lang provides i18n registries, translators, and message loading.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Provider ¶
func Provider(options ...Option) runaprovider.Provider
Provider registers the language registry.
func WithTranslator ¶
func WithTranslator(ctx context.Context, translator *Translator) context.Context
WithTranslator stores a translator in a context.
Types ¶
type Option ¶
type Option func(*optionConfig)
Option configures the language registry.
func DefaultLocale ¶
DefaultLocale sets the fallback locale.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores translations and creates request-scoped translators.
func (*Registry) Translator ¶
func (registry *Registry) Translator(values ...string) *Translator
Translator creates a translator for locale preferences.
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator translates message keys.
func From ¶
func From(ctx context.Context) *Translator
From reads a translator from context or returns the default translator.
func NewTranslator ¶
func NewTranslator(locales ...string) *Translator
NewTranslator creates a fallback translator without a registry.
func (*Translator) Locale ¶
func (translator *Translator) Locale() string
Locale returns the translator locale hint.
Click to show internal directories.
Click to hide internal directories.