mrlang

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 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 string, defaultMessage string, args ...mrmsg.NamedArg) ErrorMessage

func (*Locale) TranslateMessage

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

type Message

type Message string

type Translator

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

func NewTranslator

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

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 {
	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