Documentation ¶
Index ¶
- Variables
- func Init(multipleTrans ...TranslationLanguage)
- func Struct(obj any) error
- func StructCtx(ctx context.Context, obj any) error
- func TransErr(err error) error
- func TransErrCtx(ctx context.Context, err error) error
- func TransErrLocale(locale string, err error) error
- func TransErrZh(err error) error
- type GetRequestLanguageFunc
- type TranslationLanguage
Constants ¶
This section is empty.
Variables ¶
View Source
var Default *validator.Validate
View Source
var LanguageCtxKey = "language"
Functions ¶
func Init ¶
func Init(multipleTrans ...TranslationLanguage)
Init 初始化翻译器 默认支持 en-英文和 zh-中文、zh_Hant_TW-繁体 multipleTrans 支持其他国家或地区翻译器
func TransErrLocale ¶
func TransErrZh ¶
Types ¶
type GetRequestLanguageFunc ¶
var DefaultGetLanguage GetRequestLanguageFunc = func(ctx context.Context) string { lang, _ := ctx.Value(LanguageCtxKey).(string) if lang == "" { lang = "en" } return lang }
type TranslationLanguage ¶
type TranslationLanguage struct { Lt locales.Translator RegisterFunc func(*validator.Validate, ut.Translator) error }
Click to show internal directories.
Click to hide internal directories.