translation

package
v0.0.0-...-85b91c5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLocales

func InitLocales(optionsDir OptionsDir, optionsLocale OptionsLocale)

InitLocales loads the locales

func Match

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

Match matches accept languages

func TryTr

func TryTr(lang, format string, args ...interface{}) (string, bool)

TryTr tries to do the translation, if no translation, it returns (format, false)

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, ...interface{}) string
	TrN(cnt interface{}, key1, keyN string, args ...interface{}) string
}

Locale represents an interface to translation

func NewLocale

func NewLocale(lang string) Locale

NewLocale return a locale

type OptionsDir

type OptionsDir func(name string) ([]string, error)

type OptionsLocale

type OptionsLocale func(name string) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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