mrlang

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAcceptLanguage

func ParseAcceptLanguage(s string) []string

ParseAcceptLanguage Sample Accept-Language: ru;q=0.9, fr-CH, fr;q=0.8, en;q=0.7, *;q=0.5

Types

type ErrorMessage

type ErrorMessage struct {
	Reason  string   `yaml:"reason"`
	Details []string `yaml:"details"`
}

func (*ErrorMessage) DetailsToString

func (em *ErrorMessage) DetailsToString() string

type Locale

type Locale interface {
	LangCode() string
	TranslateMessage(id string, defaultMessage string, args ...mrmsg.NamedArg) Message
	TranslateError(id string, defaultMessage string, args ...mrmsg.NamedArg) ErrorMessage
}

type LocaleConfig

type LocaleConfig struct {
	Messages map[string]Message      `yaml:"messages"`
	Errors   map[string]ErrorMessage `yaml:"errors"`
}

type Message

type Message string

type Translator

type Translator interface {
	LocaleFirstFound(langs ...string) Locale
	RegisteredLocales() []Locale
}

func NewTranslator

func NewTranslator(opt TranslatorOptions) (Translator, error)

type TranslatorOptions

type TranslatorOptions struct {
	LangByDefault string
	DirPath       string
	FileType      string
	LangCodes     []string
}

Jump to

Keyboard shortcuts

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