Documentation ¶
Index ¶
- func GetLang(ctx context.Context) string
- func GinHandler() gin.HandlerFunc
- type II18nParser
- type Parser
- func (i *Parser) Bundle() *i18n.Bundle
- func (i *Parser) CacheLanguages()
- func (i *Parser) Lang(lang string) II18nParser
- func (i *Parser) Languages() map[string]II18nParser
- func (i *Parser) Load(file, path string)
- func (i *Parser) Localize() *i18n.Localizer
- func (i *Parser) ParseMsg(messageId string, data ...map[string]string) (s string)
- func (i *Parser) ParseMsgPanic(messageId string, data ...map[string]string) string
- func (i *Parser) SetLanguage(lang language.Tag)
- func (i *Parser) SetLocalize(lang string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) CacheLanguages ¶
func (i *Parser) CacheLanguages()
func (*Parser) Languages ¶
func (i *Parser) Languages() map[string]II18nParser
func (*Parser) ParseMsgPanic ¶
func (*Parser) SetLocalize ¶
Click to show internal directories.
Click to hide internal directories.