Documentation
¶
Index ¶
Constants ¶
View Source
const (
PluralCount = "i18n.PluralCount"
)
Variables ¶
View Source
var Options options
Functions ¶
Types ¶
type I18n ¶
type I18n interface {
// Localize 指定使用语言
// lang: 语言 zh | en | jp ...
// err: 切换语言错误,如不支持该语言等
Localize(lang string) (err error)
// GetLocalizer 获得Localizer
// lang: 语言 zh | en | jp ...
// localizer Localizer
// err: 切换语言错误,如不支持该语言等
GetLocalizer(lang string) (localizer Localizer, err error)
Stringer
}
type Stringer ¶
type Stringer interface {
// GetString 获得i18n字符串
// id: i18n message ID
// kvs: 增加参数,格式为key value对,key为string,value为interface
// 注意:
// 1、必须为偶数;
// 2、同时参数如果key为i18n.PluralCount,则value作为判定plural选择i18n message的依据
// message: 返回i18n字符串
GetString(id string, kvs ...interface{}) (message string)
// GetStringEx 通过制定数据及pluralCount获得i18n字符串
// id: i18n message ID
// data: 参数数据,用于向message填充参数,用法同go template
// pluralCount: 用于选择复数匹配字符串,值为参数替换的对象
// message: 返回i18n字符串
GetStringEx(id string, data interface{}, pluralCount interface{}) (message string)
}
Click to show internal directories.
Click to hide internal directories.