Skip to content

Commit

Permalink
Merge pull request #769 from Skyenought/i18n/bug
Browse files Browse the repository at this point in the history
fix: Increase the judgment of type strong rotation
  • Loading branch information
ReneWerner87 committed Sep 18, 2023
2 parents fb703be + a475bf3 commit 066901f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fiberi18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,19 @@ Localize get the i18n message
})
*/
func Localize(ctx *fiber.Ctx, params interface{}) (string, error) {
appCfg := ctx.Locals(localsKey).(*Config)
lang := appCfg.LangHandler(ctx, appCfg.DefaultLanguage.String())
local := ctx.Locals(localsKey)
if local == nil {
return "", fmt.Errorf("i18n.Localize error: %v", "Config is nil")
}

appCfg, ok := local.(*Config)
if !ok {
return "", fmt.Errorf("i18n.Localize error: %v", "Config is not *Config type")
}

lang := appCfg.LangHandler(ctx, appCfg.DefaultLanguage.String())
localizer, _ := appCfg.localizerMap.Load(lang)

if localizer == nil {
defaultLang := appCfg.DefaultLanguage.String()
localizer, _ = appCfg.localizerMap.Load(defaultLang)
Expand Down

0 comments on commit 066901f

Please sign in to comment.