Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTranslation ¶
func GetTranslation(w Multilingual, tags ...language.Tag) (interface{}, bool)
Types ¶
type Embed ¶
type Embed struct {
LanguageCode string
}
Embed translation table should embed this struct
func (*Embed) GetLanguageCode ¶
type HasLanguageCode ¶
type HasLanguageCode interface {
GetLanguageCode() string
}
type Language ¶
type Language struct { Code string `gorm:"type:char(36);primaryKey;"` Name string Trans []*LanguageTrans }
func (*Language) GetTranslations ¶
func (l *Language) GetTranslations() []interface{}
type LanguageTrans ¶
type Multilingual ¶
type Multilingual interface {
GetTranslations() []interface{}
}
Multilingual entity should implement this interface:
type Language struct { Code string `gorm:"type:char(36);primaryKey;"` Name string Trans []*LanguageTrans } func (l *Language) GetTranslations() []interface{} { return lo.Map(l.Trans, func(item *LanguageTrans, _ int) interface{} { return item }) }
Click to show internal directories.
Click to hide internal directories.