1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-24 12:25:57 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-01-09 05:41:20 +02:00
parent 72c2dafd2e
commit 8aedf6bc32
36 changed files with 99 additions and 130 deletions

View File

@@ -115,12 +115,10 @@ func (loc *Locale) setString(c *Catalog, key string, value string, vars []Var, f
if err != nil {
return fmt.Errorf("<%s = %s>: %w", key, value, err)
}
} else {
} else if err = c.Set(loc.tag, key, msgs...); err != nil {
// let's make normal keys direct fire:
// renderer = &simpleRenderer{key, loc.Printer}
if err = c.Set(loc.tag, key, msgs...); err != nil {
return fmt.Errorf("<%s = %s>: %w", key, value, err)
}
return fmt.Errorf("<%s = %s>: %w", key, value, err)
}
}

View File

@@ -1,11 +1,8 @@
package internal
import (
"reflect"
"regexp"
"sort"
"golang.org/x/text/message/catalog"
)
// Var represents a message variable.
@@ -84,7 +81,7 @@ func getVars(loc *Locale, key string, src map[string]interface{}) []Var {
return vars
}
var unescapeVariableRegex = regexp.MustCompile("\\$\\{(.*?)}")
var unescapeVariableRegex = regexp.MustCompile(`\$\{(.*?)}`)
func sortVars(text string, vars []Var) (newVars []Var) {
argth := 1
@@ -122,6 +119,7 @@ func removeVarsDuplicates(elements []Var) (result []Var) {
return result
}
/*
func removeMsgVarsDuplicates(elements []catalog.Message) (result []catalog.Message) {
seen := make(map[string]struct{})
@@ -141,6 +139,7 @@ func removeMsgVarsDuplicates(elements []catalog.Message) (result []catalog.Messa
return
}
*/
func getCases(loc *Locale, src map[string]interface{}) []interface{} {
type PluralCase struct {