Documentation ¶
Index ¶
- Constants
- func ContentID(cID uint64, i int) uint64
- func DetectLanguage(ll *service) func(next http.Handler) http.Handler
- func GetAcceptLanguageFromContext(ctx context.Context) language.Tag
- func GetContentLanguageFromContext(ctx context.Context) language.Tag
- func Global() *service
- func LoadEmbedded() fs.FS
- func SanitizeMessage(in string) string
- func Service(log *zap.Logger, opt options.LocaleOpt) (*service, error)
- func SetAcceptLanguageToContext(ctx context.Context, code language.Tag) context.Context
- func SetContentLanguageToContext(ctx context.Context, code language.Tag) context.Context
- func SetGlobal(ll *service)
- func Static(ll ...*Language) (svc *service)
- type ErrorMetaKey
- type ErrorMetaNamespace
- type Language
- type Locale
- type Resource
- type ResourceTranslation
- type ResourceTranslationIndex
- type ResourceTranslationSet
Constants ¶
View Source
const AcceptLanguageHeader = "Accept-Language"
View Source
const ContentLanguageHeader = "Content-Language"
Variables ¶
This section is empty.
Functions ¶
func GetAcceptLanguageFromContext ¶
GetAcceptLanguageFromContext always returns language, either valid or default
func GetContentLanguageFromContext ¶
GetContentLanguageFromContext always returns language, either valid or default
func LoadEmbedded ¶
LoadEmbedded returns embedded translation files as a virtual filesystem
func SanitizeMessage ¶
Types ¶
type ErrorMetaKey ¶
type ErrorMetaKey struct{}
type ErrorMetaNamespace ¶
type ErrorMetaNamespace struct{}
type Resource ¶
type Resource interface { TResource(ctx context.Context, ns, key string, rr ...string) string TResourceFor(tag language.Tag, ns, key string, rr ...string) string Tags() []language.Tag SupportedLang(language.Tag) bool ResourceTranslations(code language.Tag, resource string) ResourceTranslationIndex Default() *Language }
type ResourceTranslation ¶
type ResourceTranslationIndex ¶
type ResourceTranslationIndex map[string]*ResourceTranslation
func (ResourceTranslationIndex) FindByKey ¶
func (rx ResourceTranslationIndex) FindByKey(k string) *ResourceTranslation
type ResourceTranslationSet ¶
type ResourceTranslationSet []*ResourceTranslation
func (ResourceTranslationSet) ContainsForeign ¶
func (rr ResourceTranslationSet) ContainsForeign(native language.Tag) bool
Returns true if resource translation set contains foreign (non-native) languages
func (ResourceTranslationSet) SetLanguage ¶
func (rr ResourceTranslationSet) SetLanguage(tag language.Tag)
Click to show internal directories.
Click to hide internal directories.