translation

package
v0.0.0-...-495e01f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextKey any = &contextKey{}

Functions

func InitLocales

func InitLocales(ctx context.Context)

InitLocales loads the locales

func Match

func Match(tags ...language.Tag) language.Tag

Match matches accept languages

Types

type LangType

type LangType struct {
	Lang, Name string // these fields are used directly in templates: {{range .AllLangs}}{{.Lang}}{{.Name}}{{end}}
}

LangType represents a lang type

func AllLangs

func AllLangs() []*LangType

AllLangs returns all supported languages sorted by name

type Locale

type Locale interface {
	Language() string
	Tr(string, ...any) string
	TrN(cnt any, key1, keyN string, args ...any) string
	PrettyNumber(v any) string
}

Locale represents an interface to translation

func NewLocale

func NewLocale(lang string) Locale

NewLocale return a locale

type MockLocale

type MockLocale struct{}

MockLocale provides a mocked locale without any translations

func (MockLocale) Language

func (l MockLocale) Language() string

func (MockLocale) PrettyNumber

func (l MockLocale) PrettyNumber(v any) string

func (MockLocale) Tr

func (l MockLocale) Tr(s string, _ ...any) string

func (MockLocale) TrN

func (l MockLocale) TrN(_cnt any, key1, _keyN string, _args ...any) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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