Documentation
¶
Index ¶
- func GetMessage(context *gin.Context, param interface{}) (string, error)
- func Localize(opts ...Option) gin.HandlerFunc
- func MustGetMessage(context *gin.Context, param interface{}) string
- type BundleCfg
- type EmbedLoader
- type GetLngHandler
- type GinI18n
- type GinI18nImpl
- func (i *GinI18nImpl) GetMessage(param interface{}) (string, error)
- func (i *GinI18nImpl) MustGetMessage(param interface{}) string
- func (i *GinI18nImpl) SetBundle(cfg *BundleCfg)
- func (i *GinI18nImpl) SetCurrentContext(ctx context.Context)
- func (i *GinI18nImpl) SetGetLngHandler(handler GetLngHandler)
- type Loader
- type LoaderFunc
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMessage ¶
GetMessage get the i18n message
param is one of these type: messageID, *i18n.LocalizeConfig Example: GetMessage(context, "hello") // messageID is hello GetMessage(context, &i18n.LocalizeConfig{ MessageID: "welcomeWithName", TemplateData: map[string]string{ "name": context.Param("name"), }, })
func MustGetMessage ¶
MustGetMessage get the i18n message without error handling
param is one of these type: messageID, *i18n.LocalizeConfig Example: MustGetMessage(context, "hello") // messageID is hello MustGetMessage(context, &i18n.LocalizeConfig{ MessageID: "welcomeWithName", TemplateData: map[string]string{ "name": context.Param("name"), }, })
Types ¶
type BundleCfg ¶
type BundleCfg struct { DefaultLanguage language.Tag FormatBundleFile string AcceptLanguage []language.Tag RootPath string UnmarshalFunc i18n.UnmarshalFunc Loader Loader }
BundleCfg ...
type EmbedLoader ¶
func (*EmbedLoader) LoadMessage ¶
func (c *EmbedLoader) LoadMessage(path string) ([]byte, error)
type GetLngHandler ¶
GetLngHandler ...
type GinI18n ¶
type GinI18n interface { GetMessage(param interface{}) (string, error) MustGetMessage(param interface{}) string SetCurrentContext(ctx context.Context) SetBundle(cfg *BundleCfg) SetGetLngHandler(handler GetLngHandler) }
GinI18n ...
type GinI18nImpl ¶ added in v0.0.7
type GinI18nImpl struct {
// contains filtered or unexported fields
}
func (*GinI18nImpl) GetMessage ¶ added in v0.0.9
func (i *GinI18nImpl) GetMessage(param interface{}) (string, error)
getMessage get localize message by lng and messageID
func (*GinI18nImpl) MustGetMessage ¶ added in v0.0.9
func (i *GinI18nImpl) MustGetMessage(param interface{}) string
mustGetMessage ...
func (*GinI18nImpl) SetBundle ¶ added in v0.0.9
func (i *GinI18nImpl) SetBundle(cfg *BundleCfg)
func (*GinI18nImpl) SetCurrentContext ¶ added in v0.0.9
func (i *GinI18nImpl) SetCurrentContext(ctx context.Context)
func (*GinI18nImpl) SetGetLngHandler ¶ added in v0.0.9
func (i *GinI18nImpl) SetGetLngHandler(handler GetLngHandler)
type LoaderFunc ¶
func (LoaderFunc) LoadMessage ¶
func (f LoaderFunc) LoadMessage(path string) ([]byte, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.