Skip to content

Commit

Permalink
docs(i18n): update style
Browse files Browse the repository at this point in the history
  • Loading branch information
appleboy committed Jul 27, 2023
1 parent b8f7fd2 commit 0c04a11
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0c04a11

Please sign in to comment.