Documentation ¶
Index ¶
- func ParseAcceptLanguage(s string) []string
- func WithContext(ctx context.Context, locale *Locale) context.Context
- type Dictionary
- type DictionaryItemAttrs
- type DictionaryMap
- type Locale
- func (l *Locale) HasErrorCode(code string) bool
- func (l *Locale) LangCode() string
- func (l *Locale) LangID() uint16
- func (l *Locale) TranslateError(code, defaultMessage string, args ...mrmsg.NamedArg) mrmsg.ErrorMessage
- func (l *Locale) TranslateMessage(code, defaultMessage string, args ...mrmsg.NamedArg) string
- func (l *Locale) WithContext(ctx context.Context) context.Context
- type MultiLangDictionary
- type Translator
- func (t *Translator) DefaultLocale() *Locale
- func (t *Translator) Dictionary(name string) (*MultiLangDictionary, error)
- func (t *Translator) FindFirstLocale(langs ...string) *Locale
- func (t *Translator) LocaleByCode(lang string) (*Locale, error)
- func (t *Translator) LocaleByID(langID uint16) (*Locale, error)
- func (t *Translator) RegisteredDictionaries() []string
- func (t *Translator) RegisteredLocales() []string
- type TranslatorOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAcceptLanguage ¶
ParseAcceptLanguage Sample Accept-Language: ru;q=0.9, fr-CH, fr;q=0.8, en;q=0.7, *;q=0.5
Types ¶
type Dictionary ¶ added in v0.6.0
type Dictionary struct {
// contains filtered or unexported fields
}
func (*Dictionary) ItemByID ¶ added in v0.6.0
func (d *Dictionary) ItemByID(id int) DictionaryItemAttrs
func (*Dictionary) ItemByKey ¶ added in v0.6.0
func (d *Dictionary) ItemByKey(key string) DictionaryItemAttrs
func (*Dictionary) RegisteredItems ¶ added in v0.6.0
func (d *Dictionary) RegisteredItems() []string
type DictionaryItemAttrs ¶ added in v0.6.0
func (DictionaryItemAttrs) Attr ¶ added in v0.6.0
func (a DictionaryItemAttrs) Attr(name, defaultText string) string
func (DictionaryItemAttrs) RegisteredAttrs ¶ added in v0.6.0
func (a DictionaryItemAttrs) RegisteredAttrs() []string
type DictionaryMap ¶ added in v0.6.0
type DictionaryMap map[string]DictionaryItemAttrs // dictionary-name -> [id -> [attr1 -> text1, attr2 -> text2, ...], ...]
type Locale ¶
type Locale struct {
// contains filtered or unexported fields
}
func (*Locale) HasErrorCode ¶ added in v0.7.1
func (*Locale) TranslateError ¶
func (*Locale) TranslateMessage ¶
type MultiLangDictionary ¶ added in v0.6.0
type MultiLangDictionary struct {
// contains filtered or unexported fields
}
func (*MultiLangDictionary) ByLangCode ¶ added in v0.6.0
func (d *MultiLangDictionary) ByLangCode(code string) (*Dictionary, error)
func (*MultiLangDictionary) ByLangID ¶ added in v0.6.0
func (d *MultiLangDictionary) ByLangID(id uint16) (*Dictionary, error)
func (*MultiLangDictionary) Name ¶ added in v0.6.0
func (d *MultiLangDictionary) Name() string
func (*MultiLangDictionary) RegisteredLangs ¶ added in v0.6.0
func (d *MultiLangDictionary) RegisteredLangs() []string
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
func NewTranslator ¶
func NewTranslator(opts TranslatorOptions) (*Translator, error)
func (*Translator) DefaultLocale ¶ added in v0.3.0
func (t *Translator) DefaultLocale() *Locale
func (*Translator) Dictionary ¶ added in v0.6.0
func (t *Translator) Dictionary(name string) (*MultiLangDictionary, error)
func (*Translator) FindFirstLocale ¶ added in v0.1.1
func (t *Translator) FindFirstLocale(langs ...string) *Locale
FindFirstLocale - if not exists get default locale
func (*Translator) LocaleByCode ¶ added in v0.6.0
func (t *Translator) LocaleByCode(lang string) (*Locale, error)
func (*Translator) LocaleByID ¶ added in v0.6.0
func (t *Translator) LocaleByID(langID uint16) (*Locale, error)
func (*Translator) RegisteredDictionaries ¶ added in v0.6.0
func (t *Translator) RegisteredDictionaries() []string
func (*Translator) RegisteredLocales ¶
func (t *Translator) RegisteredLocales() []string
Click to show internal directories.
Click to hide internal directories.