multilingual

package
v0.0.5-0...-8e55a6f Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

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

func (e *Embed) GetLanguageCode() string

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 LanguageTrans struct {
	Embed
	Name string
}

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
	})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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