languagex

package module
v0.0.0-...-2e3374b Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLanguages

func GetLanguages() []language.Tag

GetLanguages 获取所有语言

func MatchLanguage

func MatchLanguage(s string) (tag language.Tag, err error)

MatchLanguage 匹配最可能的语言

func MatchLocalLanguage

func MatchLocalLanguage(s string) (tag language.Tag, err error)

MatchLocalLanguage 匹配最可能的语言

Types

type Translator

type Translator struct {
	sync.RWMutex
	//Dictionary map[language.Tag]map[int32]string
	Dictionary map[int32]map[language.Tag]string
}

Translator 翻译器

func GetTranslator

func GetTranslator() *Translator

GetTranslator 获取翻译器

func NewTranslator

func NewTranslator() *Translator

NewTranslator 创建新的翻译器

func (*Translator) Register

func (t *Translator) Register(lan language.Tag, code int32, msg string)

Register 注册翻译

func (*Translator) Registers

func (t *Translator) Registers(code int32, msgs map[language.Tag]string)

Registers 批量注册 会覆盖注册一次code的所有语言

func (*Translator) Translate

func (t *Translator) Translate(lan language.Tag, code int32) string

Translate 翻译

Jump to

Keyboard shortcuts

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