i18n

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 16 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type I18n

type I18n interface {
	Get(namespace string, lang LanguageCodes, key, def string) string
	Text(namespace string, lang LanguageCodes, key string) string
	Sprintf(namespace string, lang LanguageCodes, key string, args ...interface{}) string
	Translator(namespace string) Translator
	RegisterFilesFromFS(fsPrefix string, rootFS embed.FS) error
}

I18n .

type Internationalizable

type Internationalizable interface {
	Translate(t Translator, langs LanguageCodes) string
}

Internationalizable .

type LanguageCode

type LanguageCode struct {
	Code    string  `json:"code"`
	Quality float32 `json:"quality"`
}

LanguageCode .

func (*LanguageCode) Codes

func (lc *LanguageCode) Codes() (string, string)

Codes .

func (*LanguageCode) ElaboratedCode

func (lc *LanguageCode) ElaboratedCode() string

ElaboratedCode .

func (*LanguageCode) RestrictedCode

func (lc *LanguageCode) RestrictedCode() string

RestrictedCode .

func (*LanguageCode) String

func (lc *LanguageCode) String() string

String .

type LanguageCodes

type LanguageCodes []*LanguageCode

LanguageCodes .

func ParseLanguageCode

func ParseLanguageCode(text string) (list LanguageCodes, err error)

ParseLanguageCode .

func (LanguageCodes) Len

func (ls LanguageCodes) Len() int

Len 返回slice长度

func (LanguageCodes) Less

func (ls LanguageCodes) Less(i, j int) bool

Less 比较两个位置上的数据

func (LanguageCodes) Swap

func (ls LanguageCodes) Swap(i, j int)

Swap 交换两个位置上的数据

type NopTranslator

type NopTranslator struct{}

NopTranslator .

func (*NopTranslator) Get

func (t *NopTranslator) Get(lang LanguageCodes, key, def string) string

Get .

func (*NopTranslator) Sprintf

func (t *NopTranslator) Sprintf(lang LanguageCodes, key string, args ...interface{}) string

Sprintf .

func (*NopTranslator) Text

func (t *NopTranslator) Text(lang LanguageCodes, key string) string

Text .

type Translator

type Translator interface {
	Get(lang LanguageCodes, key, def string) string
	Text(lang LanguageCodes, key string) string
	Sprintf(lang LanguageCodes, key string, args ...interface{}) string
}

Translator .

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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