mrlang

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 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 struct {
	// contains filtered or unexported fields
}

func DefaultLocale added in v0.1.1

func DefaultLocale() *Locale

func (*Locale) LangCode

func (l *Locale) LangCode() string

func (*Locale) TranslateError

func (l *Locale) TranslateError(id, defaultMessage string, args ...mrmsg.NamedArg) ErrorMessage

func (*Locale) TranslateMessage

func (l *Locale) TranslateMessage(id, defaultMessage string, args ...mrmsg.NamedArg) string

type Translator

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

func NewTranslator

func NewTranslator(opt TranslatorOptions) (*Translator, error)

func (*Translator) DefaultLocale added in v0.3.0

func (t *Translator) DefaultLocale() *Locale

func (*Translator) FindFirstLocale added in v0.1.1

func (t *Translator) FindFirstLocale(langs ...string) *Locale

func (*Translator) RegisteredLocales

func (t *Translator) RegisteredLocales() []*Locale

type TranslatorOptions

type TranslatorOptions struct {
	DirPath     string
	FileType    string
	LangCodes   []string
	DefaultLang string // optional
}

Jump to

Keyboard shortcuts

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