i18n

package
v0.0.0-...-ffea4ed Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TagName string = "translate"

Variables

View Source
var (
	LANG           string
	ErrNotPointer  = errors.New("Output is not a pointer.")
	ErrNotStruct   = errors.New("Data is not a struct")
	ErrTranslating = NewErrTranslating("Error while translating")
	ErrWrongType   = errors.New("Tag \"translate\" used on a field which is not of type I18nString")
)

Functions

func NewErrTranslating

func NewErrTranslating(s string) errTranslating

func SetStructLanguage

func SetStructLanguage(data interface{}, lang string) error

Types

type I18nField

type I18nField struct {
	Default string
	L       string
	M       Translations
}

func NewI18nField

func NewI18nField(s string, t Translations) I18nField

func (*I18nField) GetBSON

func (s *I18nField) GetBSON() (interface{}, error)

func (*I18nField) GetTranslation

func (s *I18nField) GetTranslation(lang string) (string, error)

func (*I18nField) MarshalJSON

func (s *I18nField) MarshalJSON() ([]byte, error)

func (*I18nField) SetBSON

func (s *I18nField) SetBSON(raw bson.Raw) error

func (*I18nField) SetTranslation

func (s *I18nField) SetTranslation(lang, txt string)

func (*I18nField) String

func (s *I18nField) String() string

func (*I18nField) UnmarshallJSON

func (s *I18nField) UnmarshallJSON(b []byte) error

type Translations

type Translations map[string]string

Jump to

Keyboard shortcuts

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