Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMessage ¶
GetMessage get the i18n message with error handling 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 // DefaultLanguage specifies the default language for the bundle. FormatBundleFile string // FormatBundleFile specifies the file format for the bundle. AcceptLanguage []language.Tag // AcceptLanguage specifies the accepted languages for the bundle. RootPath string // RootPath specifies the root path for the bundle. UnmarshalFunc i18n.UnmarshalFunc // UnmarshalFunc specifies the function used for unmarshaling bundle files. Loader Loader // Loader specifies the loader for loading bundle files. }
BundleCfg represents the configuration options for an i18n bundle.
type EmbedLoader ¶
func (*EmbedLoader) LoadMessage ¶
func (c *EmbedLoader) LoadMessage(path string) ([]byte, error)
type GetLngHandler ¶
GetLngHandler ...
type LoaderFunc ¶
func (LoaderFunc) LoadMessage ¶
func (f LoaderFunc) LoadMessage(path string) ([]byte, error)
type Option ¶
type Option func(GinI18n)
Option ...
func WithBundle ¶
WithBundle returns an Option that sets the bundle configuration for GinI18n. If the loader is not provided in the BundleCfg, the defaultLoader will be used.
func WithGetLngHandle ¶
func WithGetLngHandle(handler GetLngHandler) Option
WithGetLngHandle sets the handler function for retrieving the current language. The provided handler function should accept a GinI18n instance and return the current language as a string. This option allows you to customize how the current language is determined.