translator

package
v0.0.0-...-e064244 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EN = "en"
	FA = "fa"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Translator

type Translator interface {
	Translate(language string, messageID string) string
	TranslateEN(messageID string) string
	TranslateFA(messageID string) string
}

func New

func New(address string, defaultLanguage language.Tag, languages ...language.Tag) (Translator, error)

Initialization of the translation.

You can get your language Tag with using "golang.org/x/text/language" library like: language.English

If `address` == "", on linux we will set address to "build/translations" and on windows address is "build\translations\"

type TranslatorPack

type TranslatorPack struct {
	// contains filtered or unexported fields
}

func (*TranslatorPack) Translate

func (translator *TranslatorPack) Translate(language string, messageID string) string

Translates to requested language and if only the language is not added before with `loadLanguages` or `Setup` functions, `localizer not found` error returns.

You can get your language string code with using "golang.org/x/text/language" library like: language.English.String()

func (*TranslatorPack) TranslateEN

func (translator *TranslatorPack) TranslateEN(messageID string) string

Translates to English and if only the language is not added before with `loadLanguages` or `Setup` functions, `localizer not found` error returns.

You can get your language string code with using "golang.org/x/text/language" library like: language.English.String()

func (*TranslatorPack) TranslateFA

func (translator *TranslatorPack) TranslateFA(messageID string) string

Translates to English and if only the language is not added before with `loadLanguages` or `Setup` functions, `localizer not found` error returns.

You can get your language string code with using "golang.org/x/text/language" library like: language.English.String()

Jump to

Keyboard shortcuts

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