Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator is used as a mechanism for message translations. It is based on the golang.org/x/text package.
func NewTranslator ¶
func NewTranslator(options ...TranslatorOption) (*Translator, error)
NewTranslator creates an instance of the Translator for violation messages.
type TranslatorOption ¶
type TranslatorOption func(translator *Translator) error
func DefaultLanguage ¶
func DefaultLanguage(tag language.Tag) TranslatorOption
DefaultLanguage option is used to set up the default language for translation of violation messages.
func SetTranslations ¶
SetTranslations option is used to load translation messages into the translator.
By default, all violation messages are generated in the English language with pluralization capabilities. To use a custom language you have to load translations on translator initialization. Built-in translations are available in the sub-packages of the package github.com/muonsoft/message/translations. The translation mechanism is provided by the golang.org/x/text package (be aware, it has no stable version yet).
Directories ¶
Path | Synopsis |
---|---|
Package english contains violation message texts translated into English language.
|
Package english contains violation message texts translated into English language. |
Package russian contains violation message texts translated into Russian language.
|
Package russian contains violation message texts translated into Russian language. |