translator

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLangOption = "Default"

DefaultLangOption default language option. If user config the language is default, the language option is admin choose.

Variables

View Source
var GlobalTrans i18n.Translator
View Source
var (
	// LanguageOptions language
	LanguageOptions []*LangOption
)
View Source
var ProviderSet = wire.NewSet(NewTranslator)

ProviderSet is providers.

Functions

func CheckLanguageIsValid added in v0.3.0

func CheckLanguageIsValid(lang string) bool

CheckLanguageIsValid check user input language is valid

func NewTranslator

func NewTranslator(c *I18n) (tr i18n.Translator, err error)

NewTranslator new a translator

func Tr added in v1.0.3

func Tr(lang i18n.Language, data string) string

Tr use language to translate data. If this language translation is not available, return default english translation.

Types

type I18n

type I18n struct {
	BundleDir string `json:"bundle_dir" mapstructure:"bundle_dir" yaml:"bundle_dir"`
}

I18n i18n config

type LangOption added in v0.3.0

type LangOption struct {
	Label string `json:"label"`
	Value string `json:"value"`
	// Translation completion percentage
	Progress int `json:"progress"`
}

LangOption language option

Jump to

Keyboard shortcuts

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