123456789101112131415161718192021 |
- package helpers
- import (
- "github.com/go-playground/locales/ru"
- "github.com/go-playground/universal-translator"
- "github.com/go-playground/validator/v10"
- ruTranslations "github.com/go-playground/validator/v10/translations/ru"
- )
- func GetDefaultTranslator(v *validator.Validate) (ut.Translator, error) {
- var err error
- localeRu := ru.New()
- uniTrans := ut.New(localeRu, localeRu)
- trans, _ := uniTrans.GetTranslator(localeRu.Locale())
- if err = ruTranslations.RegisterDefaultTranslations(v, trans); err != nil {
- return nil, err
- }
- return trans, nil
- }
|