i18n

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLang

func GetLang(ctx context.Context) string

func GinHandler

func GinHandler() gin.HandlerFunc

Types

type II18nParser

type II18nParser interface {
	Bundle() *i18n.Bundle
	Load(file, path string) //加解析文件,file=文件路径,path=i18n内path

	Lang(name string) II18nParser //返回对应language的解析器

	CacheLanguages()                   //缓存languages
	Languages() map[string]II18nParser //设置本地化语言

	SetLanguage(lang language.Tag) //设置本地化语言
	SetLocalize(lang string)
	Localize() *i18n.Localizer //获取本地化语言类

	ParseMsg(messageId string, data ...map[string]string) string      //获取i18n解析后的消息
	ParseMsgPanic(messageId string, data ...map[string]string) string //获取i18n解析后的消息(失败会panic)
}

II18nParser i18n解析器

func NewParser

func NewParser() II18nParser

type Parser

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

func (*Parser) Bundle

func (i *Parser) Bundle() *i18n.Bundle

func (*Parser) CacheLanguages

func (i *Parser) CacheLanguages()

func (*Parser) Lang

func (i *Parser) Lang(lang string) II18nParser

Lang 获取对应的i18n语言parser

func (*Parser) Languages

func (i *Parser) Languages() map[string]II18nParser

func (*Parser) Load

func (i *Parser) Load(file, path string)

func (*Parser) Localize

func (i *Parser) Localize() *i18n.Localizer

func (*Parser) ParseMsg

func (i *Parser) ParseMsg(messageId string, data ...map[string]string) (s string)

func (*Parser) ParseMsgPanic

func (i *Parser) ParseMsgPanic(messageId string, data ...map[string]string) string

func (*Parser) SetLanguage

func (i *Parser) SetLanguage(lang language.Tag)

SetLanguage 设置本地化语言

func (*Parser) SetLocalize

func (i *Parser) SetLocalize(lang string)

Jump to

Keyboard shortcuts

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