translation

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2019 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

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 RandomStr added in v0.1.1

func RandomStr() string

func SetTranslationHeaders added in v0.1.5

func SetTranslationHeaders(req *http.Request, ctx Context)

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 (o *Conf) CheckDefault() Context

func (*Conf) GetDisplay

func (o *Conf) GetDisplay() string

func (*Conf) GetFallback

func (o *Conf) GetFallback() string

func (*Conf) GetSecond

func (o *Conf) GetSecond() string

func (*Conf) GetTranslationList

func (o *Conf) GetTranslationList() bool

func (*Conf) Validate

func (o *Conf) Validate() (errList []error)

type Context

type Context interface {
	GetDisplay() string
	GetFallback() string
	GetSecond() string
	GetTranslationList() bool
	CheckDefault() Context
	Validate() []error
}

func NewContext

func NewContext(base Context, req *http.Request) 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 GenerateString(languages []string) String

func NewString

func NewString(lang, str string) String

func (*String) Add

func (o *String) Add(r String)

func (*String) AddTranslate added in v0.1.3

func (o *String) AddTranslate(lang, str string) *String

func (*String) ApplyTranslationCtx

func (o *String) ApplyTranslationCtx(ctx Context) *String

func (*String) ClearContext

func (o *String) ClearContext() *String

func (*String) Clone

func (o *String) Clone() *String

func (*String) Empty

func (o *String) Empty() bool

Checking an empty in a source of translation

func (*String) GetTranslate

func (o *String) GetTranslate(lang string) string

func (*String) HasTranslation added in v0.1.6

func (o *String) HasTranslation() bool

Checking a whole state of a string - a source of translation and a result of it

func (*String) Init

func (o *String) Init() *String

func (*String) Join

func (o *String) Join(r String, s string) String

func (*String) Len

func (o *String) Len() int

func (*String) Map

func (o *String) Map(f func(string) string) String

func (*String) Reset added in v0.1.3

func (o *String) Reset()

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.

func (*String) String

func (o *String) String() string

func (*String) Trim

func (o *String) Trim() int

func (*String) Update

func (o *String) Update(r String)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL