Documentation ¶
Index ¶
- Constants
- func RandomStr() string
- func SetTranslationHeaders(req *http.Request, ctx Context)
- type ApplyTranslationCtx
- type Conf
- type Context
- type ErrTranslation
- type String
- func (o *String) Add(r String)
- func (o *String) AddTranslate(lang, str string) *String
- func (o *String) ApplyTranslationCtx(ctx Context) *String
- func (o *String) ClearContext() *String
- func (o *String) Clone() *String
- func (o *String) Empty() bool
- func (o *String) GetTranslate(lang string) string
- func (o *String) HasTranslation() bool
- func (o *String) Init() *String
- func (o *String) Join(r String, s string) String
- func (o *String) Len() int
- func (o *String) Map(f func(string) string) String
- func (o *String) Reset()
- func (o *String) ResetCtxApplied()
- func (o *String) String() string
- func (o *String) Trim() int
- func (o *String) Update(r String)
Constants ¶
View Source
const ( ErrConfFallbackEmpty = ErrTranslation("lang/fallback - empty, using '" + defaultLang + "'") ErrConfSecondEmpty = ErrTranslation("lang/second - empty, using '" + defaultLang + "'") )
Variables ¶
This section is empty.
Functions ¶
func SetTranslationHeaders ¶ added in v0.1.5
Types ¶
type ApplyTranslationCtx ¶
type ApplyTranslationCtx interface {
ApplyTranslationCtx(Context)
}
type Conf ¶
type Conf struct { Display string `json:"display" yaml:"display"` Fallback string `json:"fallback" yaml:"fallback"` Second string `json:"second" yaml:"second"` TranslationList bool `json:"translate_list" yaml:"translate_list"` }
func DefaultConf ¶
func DefaultConf() *Conf
func (*Conf) CheckDefault ¶
func (*Conf) GetDisplay ¶
func (*Conf) GetFallback ¶
func (*Conf) GetTranslationList ¶
type Context ¶
type ErrTranslation ¶ added in v0.1.3
type ErrTranslation string
func (ErrTranslation) Error ¶ added in v0.1.3
func (o ErrTranslation) Error() string
type String ¶
type String struct { Display string `json:"display" yaml:"display"` Second string `json:"second" yaml:"second"` Translate map[string]string `json:"translate" yaml:"translate"` // contains filtered or unexported fields }
func GenerateString ¶ added in v0.1.1
func (*String) AddTranslate ¶ added in v0.1.3
func (*String) ApplyTranslationCtx ¶
func (*String) ClearContext ¶
func (*String) GetTranslate ¶
func (*String) HasTranslation ¶ added in v0.1.6
Checking a whole state of a string - a source of translation and a result of it
func (*String) ResetCtxApplied ¶ added in v0.1.7
func (o *String) ResetCtxApplied()
A response with translation string contains ctxApplied as false. Reset the ctxApplied will be useful in test to compare a response and an expected value.
Click to show internal directories.
Click to hide internal directories.