translations

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 6 Imported by: 0

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.

func (*Translator) Translate

func (translator *Translator) Translate(tag language.Tag, message string, pluralCount int) string

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

func SetTranslations(messages map[language.Tag]map[string]catalog.Message) TranslatorOption

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.

Jump to

Keyboard shortcuts

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