From 0c04a11d838d79c62250fe3c6b4488735770002d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 27 Jul 2023 22:20:36 +0800 Subject: [PATCH] docs(i18n): update style --- i18n.go | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/i18n.go b/i18n.go index a2c85d9..2418386 100644 --- a/i18n.go +++ b/i18n.go @@ -35,37 +35,33 @@ func Localize(opts ...Option) gin.HandlerFunc { } } -/* -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"), - }, - }) -*/ +// 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 GetMessage(context *gin.Context, param interface{}) (string, error) { atI18n := context.Value("i18n").(GinI18n) return atI18n.getMessage(context, param) } -/* -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"), - }, - }) -*/ +// 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"), +// }, +// }) func MustGetMessage(context *gin.Context, param interface{}) string { atI18n := context.MustGet("i18n").(GinI18n) return atI18n.mustGetMessage(context, param)