diff --git a/core/localizer.go b/core/localizer.go index 278c0cc..b00c92c 100644 --- a/core/localizer.go +++ b/core/localizer.go @@ -137,6 +137,23 @@ func (l *Localizer) LocalizationMiddleware() gin.HandlerFunc { func (l *Localizer) LocalizationFuncMap() template.FuncMap { return template.FuncMap{ "trans": l.GetLocalizedMessage, + "transTpl": func(messageID string, parts ...string) string { + if len(parts) == 0 { + return l.GetLocalizedMessage(messageID) + } + + if len(parts)%2 != 0 { + parts = append(parts, "") + } + + partsMap := make(map[string]interface{}, len(parts)/2) + + for i := 0; i < len(parts)-1; i += 2 { + partsMap[parts[i]] = parts[i+1] + } + + return l.GetLocalizedTemplateMessage(messageID, partsMap) + }, } } diff --git a/core/validator_test.go b/core/validator_test.go index 9b8df61..9ec3978 100644 --- a/core/validator_test.go +++ b/core/validator_test.go @@ -73,7 +73,6 @@ func (s *ValidatorSuite) Test_ValidationSuccess() { "https://raisa.retailcrm.es", "https://blabla.simla.com", "https://blabla.simlachat.com", - "https://blabla.simlachat.ru", "https://blabla.ecomlogic.com", "https://crm.baucenter.ru", "https://crm.holodilnik.ru",