i18n

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocaleAlreadyExist = errors.New("lang already exists")

	DefaultLocales = NewLocaleStore()
)

Functions

func ResetDefaultLocales

func ResetDefaultLocales()

func Tr

func Tr(lang, trKey string, trArgs ...interface{}) string

Tr use default locales to translate content to target language.

Types

type LocaleStore

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

func NewLocaleStore

func NewLocaleStore() *LocaleStore

func (*LocaleStore) AddLocaleByIni

func (ls *LocaleStore) AddLocaleByIni(langName, langDesc string, localeFile interface{}, otherLocaleFiles ...interface{}) error

AddLocaleByIni adds locale by ini into the store

func (*LocaleStore) HasLang

func (ls *LocaleStore) HasLang(langName string) bool

func (*LocaleStore) ListLangNameDesc

func (ls *LocaleStore) ListLangNameDesc() (names, desc []string)

func (*LocaleStore) SetDefaultLang

func (ls *LocaleStore) SetDefaultLang(lang string)

SetDefaultLang sets default language as a fallback

func (*LocaleStore) Tr

func (ls *LocaleStore) Tr(lang, trKey string, trArgs ...interface{}) string

Tr translates content to target language. fall back to default language.

Jump to

Keyboard shortcuts

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