lang

package
v0.0.0-...-929c2b4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocaleEn      = Locale("en")
	LocaleRu      = Locale("ru")
	LocaleLv      = Locale("lv")
	LocaleDefault = LocaleEn
)
View Source
const (
	PhraseEmpty = PhraseID(iota)

	PhraseUnknownCommand
	PhraseCancelled
	PhraseHelpText
	PhraseHelpVideoCaption
	PhraseHelpVideoURL

	PhraseCancelButton
	PhraseAddSocketIntro
	PhraseCannotSkipThisStep
	PhraseNoLocationAttached
	PhraseWaitingForPlaceName
	PhraseNoPlaceName
	PhraseWaitingForPlaceDescription
	PhraseNoPlaceDescription
	PhraseWaitingForSocketPhoto
	PhraseSkipThisStep
	PhraseNoSocketPhotoAttached
	PhraseWaitingForOverviewPhoto
	PhraseNoOverviewPhotoAttached
	PhraseInternalErrorAddingSocket
)

Variables

This section is empty.

Functions

func FormatDistance

func FormatDistance(locale Locale, meters int64) string

func GetPhrase

func GetPhrase(id PhraseID, locale Locale) string

func Init

func Init() error

Types

type DataFoundSocket

type DataFoundSocket struct {
	Distance    string
	Name        string
	Description string
}

type DataHelp

type DataHelp struct {
	DonationEnabled bool
	DonationURL     string
}
type DataMapLink struct {
	URL string
}

type DataSocketAdded

type DataSocketAdded struct {
	URL string
}

type DataSocketsTooFar

type DataSocketsTooFar struct {
	Distance string
}

type Locale

type Locale string

func LocaleFromString

func LocaleFromString(locale string) Locale

type Message

type Message interface {
	String() string
}

type MsgSimple

type MsgSimple string

func (MsgSimple) String

func (m MsgSimple) String() string

type MsgTemplate

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

func NewMsgTemplate

func NewMsgTemplate(templateText string, example Templater) MsgTemplate

func (MsgTemplate) String

func (m MsgTemplate) String() string

type Phrase

type Phrase map[Locale]Message

func (Phrase) String

func (p Phrase) String(locale Locale) string

type PhraseID

type PhraseID int

type Template

type Template[T any] struct {
	// contains filtered or unexported fields
}

func TemplateFoundSocket

func TemplateFoundSocket() Template[DataFoundSocket]

func TemplateHelp

func TemplateHelp() Template[DataHelp]
func TemplateMapLink() Template[DataMapLink]

func TemplateSocketAdded

func TemplateSocketAdded() Template[DataSocketAdded]

func TemplateSocketsTooFar

func TemplateSocketsTooFar() Template[DataSocketsTooFar]

func (Template[T]) Execute

func (t Template[T]) Execute(locale Locale, data T) string

func (Template[T]) Init

func (t Template[T]) Init(locale Locale, templateText string) error

func (Template[T]) Name

func (t Template[T]) Name() string

type TemplateKey

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

type Templater

type Templater interface {
	// Name имя шаблона, будет светиться в логах в случае ошибки
	Name() string

	// Init шаблон компилируется, тестируется и сохраняется в templateRegistry
	Init(locale Locale, templateText string) error
}

Jump to

Keyboard shortcuts

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