diff --git a/cmd/resources/generate_resources.go b/cmd/resources/generate_resources.go index c583f6f..2700ba1 100644 --- a/cmd/resources/generate_resources.go +++ b/cmd/resources/generate_resources.go @@ -5,8 +5,11 @@ import ( "log" "os" "os/exec" + "sort" "strings" + "github.com/go-playground/universal-translator/resources/locales" + "golang.org/x/text/unicode/cldr" "text/template" @@ -48,47 +51,42 @@ const ( var ( prVarFuncs = map[string]string{ - "n": `n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue:num, InnerError: err} - } - - `, - "i": `i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue:num, InnerError: err} - } - - `, - "v": "v := locales.V(num)\n\n", - "w": `w, err := locales.W(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue:num, InnerError: err} - } - - `, - "f": `f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue:num, InnerError: err} - } - - `, - "t": `t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue:num, InnerError: err} - } - - `, + "n": "n := math.Abs(num)\n", + "i": "i := int64(n)\n", + // "v": "v := ...", // inherently available as argument + "w": "w := locales.W(n, v)\n", + "f": "f := locales.F(n, v)\n", + "t": "t := locales.T(n, v)\n", } + + translators = make(map[string]*translator) + baseTranslators = make(map[string]*translator) + tmpl *template.Template ) type translator struct { Locale string + BaseLocale string + Plurals string CardinalFunc string + Decimal string + Group string + Minus string + Percent string + PerMille string + Symbol string + // Currency string + // CurrencyAbbrev string + // decimal string + // group string + // minus string + // percent string + // perMille string + // currency string + // currencyName string + // currencyAbbrev string } -var tmpl *template.Template - func main() { var err error @@ -101,98 +99,393 @@ func main() { // load CLDR recourses var decoder cldr.Decoder + cldr, err := decoder.DecodePath("data/core") if err != nil { panic(err) } - // cardinalPlurals := map[string] + preProcess(cldr) + postProcess(cldr) - // for _, p := range ldr.Supplemental().Plurals { + for _, trans := range translators { - // for _, pr := range p.PluralRules { + fmt.Println("Writing Data:", trans.Locale) - // fmt.Println(pr.Locales) + if err = os.MkdirAll(fmt.Sprintf(locDir, trans.Locale), 0777); err != nil { + log.Fatal(err) + } - // for _, rule := range pr.PluralRule { - // fmt.Println(rule.Count, rule.Common.Data()) - // } - // } - // } + filename := fmt.Sprintf(locFilename, trans.Locale, trans.Locale) - for _, l := range cldr.Locales() { + output, err := os.Create(filename) + if err != nil { + log.Fatal(err) + } + defer output.Close() - // // work on uk for the moment - // if l != "uk" && l != "fil" && l != "gd" { - // if l != "gd" { - // continue - // } - fmt.Println(l) + if err := tmpl.ExecuteTemplate(output, "translator", trans); err != nil { + log.Fatal(err) + } - baseLocale := strings.SplitN(l, "_", 2)[0] + output.Close() - trans := &translator{ - Locale: l, - CardinalFunc: parseCardinalPluralRuleFunc(cldr, baseLocale), + // after file written run gofmt on file to ensure best formatting + cmd := exec.Command("goimports", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) } + } +} - // cardinalRules := getLocaleCardinalPluralRules(cldr, baseLocale) - // fmt.Println("CardinalRules:", l, cardinalRules) - // Start Plural Rules +func postProcess(cldr *cldr.CLDR) { - // for _, p := range cldr.Supplemental().Plurals { + var base *translator + var found bool - // for _, pr := range p.PluralRules { + for _, trans := range translators { - // locales := strings.Split(pr.Locales, " ") + fmt.Println("Post Processing:", trans.Locale) - // for _, loc := range locales { + // plural rules + trans.CardinalFunc, trans.Plurals = parseCardinalPluralRuleFunc(cldr, trans.BaseLocale) - // if loc == baseLocale { + // ignore base locales + if trans.BaseLocale == trans.Locale { + found = false + } else { - // // plural rule found - // fmt.Println("Locale Plural Rules Found:", loc, baseLocale, l) - // } - // } - // // fmt.Println(pr.Locales) + base, found = baseTranslators[trans.BaseLocale] + } + + // Numbers + + if len(trans.Decimal) == 0 { + + if found { + trans.Decimal = fmt.Sprintf("%#v", []byte(base.Decimal)) + } + + if len(trans.Decimal) == 0 { + trans.Decimal = "[]byte{}" + } + } + + if len(trans.Group) == 0 { - // // for _, rule := range pr.PluralRule { - // // fmt.Println(rule.Count, rule.Common.Data()) - // // } + if found { + trans.Group = fmt.Sprintf("%#v", []byte(base.Group)) + } + + if len(trans.Group) == 0 { + trans.Group = "[]byte{}" + } + } + + if len(trans.Minus) == 0 { + + if found { + trans.Minus = fmt.Sprintf("%#v", []byte(base.Minus)) + } + + if len(trans.Minus) == 0 { + trans.Minus = "[]byte{}" + } + } + + if len(trans.Percent) == 0 { + + if found { + trans.Percent = fmt.Sprintf("%#v", []byte(base.Percent)) + } + + if len(trans.Percent) == 0 { + trans.Percent = "[]byte{}" + } + } + + if len(trans.PerMille) == 0 { + + if found { + trans.PerMille = fmt.Sprintf("%#v", []byte(base.PerMille)) + } + + if len(trans.PerMille) == 0 { + trans.PerMille = "[]byte{}" + } + } + + // Currency + + if len(trans.Symbol) == 0 { + + if found { + trans.Symbol = fmt.Sprintf("%#v", []byte(base.Symbol)) + } + + if len(trans.Symbol) == 0 { + trans.Symbol = "[]byte{}" + } + } + + // if len(trans.Currency) == 0 { + + // if found { + // trans.Currency = fmt.Sprintf("%#v", []byte(base.Currency)) + // } + + // if len(trans.Currency) == 0 { + // trans.Currency = "[]byte{}" // } // } + } +} - // End Plural Rules +// preprocesses maps, array etc... just requires multiple passes no choice.... +func preProcess(cldr *cldr.CLDR) { - if err = os.MkdirAll(fmt.Sprintf(locDir, l), 0777); err != nil { - log.Fatal(err) - } + for _, l := range cldr.Locales() { - filename := fmt.Sprintf(locFilename, l, l) + fmt.Println("Pre Processing:", l) - output, err := os.Create(filename) - if err != nil { - log.Fatal(err) + split := strings.SplitN(l, "_", 2) + baseLocale := split[0] + + trans := &translator{ + Locale: l, + BaseLocale: baseLocale, } - defer output.Close() - if err := tmpl.ExecuteTemplate(output, "translator", trans); err != nil { - log.Fatal(err) + // if is a base locale + if len(split) == 1 { + baseTranslators[baseLocale] = trans } - output.Close() + translators[l] = trans - // after file written run gofmt on file to ensure best formatting - cmd := exec.Command("gofmt", "-s", "-w", filename) - if err = cmd.Run(); err != nil { - log.Panic(err) + // get number, currency and datetime symbols + + // number values + ldml := cldr.RawLDML(l) + + // some just have no data... + if ldml.Numbers != nil && len(ldml.Numbers.Symbols) > 0 { + + symbol := ldml.Numbers.Symbols[0] + + if len(symbol.Decimal) > 0 { + trans.Decimal = fmt.Sprintf("%#v", []byte(symbol.Decimal[0].Data())) + } + if len(symbol.Group) > 0 { + trans.Group = fmt.Sprintf("%#v", []byte(symbol.Group[0].Data())) + } + if len(symbol.MinusSign) > 0 { + trans.Minus = fmt.Sprintf("%#v", []byte(symbol.MinusSign[0].Data())) + } + if len(symbol.PercentSign) > 0 { + trans.Percent = fmt.Sprintf("%#v", []byte(symbol.PercentSign[0].Data())) + } + if len(symbol.PerMille) > 0 { + trans.PerMille = fmt.Sprintf("%#v", []byte(symbol.PerMille[0].Data())) + } + + // if ldml.Numbers.Currencies != nil { + + // for _, currency := range ldml.Numbers.Currencies.Currency { + + // if len(currency.Symbol) == 0 { + // continue + // } + + // trans.Symbol = currency.Symbol[0].Data() + + // if len(trans.Currency) == 0 { + // continue + // } + + // trans.Currency = fmt.Sprintf("%#v", []byte(currency.Type)) + + // // if len(currency.DisplayName) > 0 { + // // trans.CurrencyName = fmt.Sprintf("%#v", []byte(currency.DisplayName[0].Data())) + // // } else { + // // trans.CurrencyName = "[]byte{}" + // // } + + // // var c i18n.Currency + + // // c.Currency = currency.Type + + // // if len(currency.DisplayName) > 0 { + // // c.DisplayName = currency.DisplayName[0].Data() + // // } + + // // if len(currency.Symbol) > 0 { + // // c.Symbol = currency.Symbol[0].Data() + // // } + + // // number.Currencies[c.Currency] = c + // } + // } + + // var decimalFormat, currencyFormat, currencyAccountingFormat, percentageFormat string + + // if len(ldml.Numbers.DecimalFormats) > 0 && len(ldml.Numbers.DecimalFormats[0].DecimalFormatLength) > 0 { + // decimalFormat = ldml.Numbers.DecimalFormats[0].DecimalFormatLength[0].DecimalFormat[0].Pattern[0].Data() + // } + + // if len(ldml.Numbers.CurrencyFormats) > 0 && len(ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength) > 0 { + + // currencyFormat = ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat[0].Pattern[0].Data() + // currencyAccountingFormat = currencyFormat + + // if len(ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat) > 1 { + // currencyAccountingFormat = ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat[1].Pattern[0].Data() + // } + // } + + // if len(ldml.Numbers.PercentFormats) > 0 && len(ldml.Numbers.PercentFormats[0].PercentFormatLength) > 0 { + // percentageFormat = ldml.Numbers.PercentFormats[0].PercentFormatLength[0].PercentFormat[0].Pattern[0].Data() + // } + + // // parse Number values + // parseNumbers(decimal, group, minus, percent, permille, decimalFormat, currencyFormat, currencyAccountingFormat, percentageFormat) + + // end number values } } } +// func parseNumbers(decimal, group, minus, percent, permille, decimalFormat, currencyFormat, currencyAccountingFormat, percentageFormat string) { + +// if includeDecimalDigits { + +// nfMutex.RLock() + +// if format, exists := numberFormats[pattern]; exists { +// nfMutex.RUnlock() +// return format +// } + +// nfMutex.RUnlock() + +// } else { + +// nfndMutex.RLock() + +// if format, exists := numberFormatsNoDecimals[pattern]; exists { +// nfndMutex.RUnlock() +// return format +// } + +// nfndMutex.RUnlock() +// } + +// format := new(numberFormat) +// patterns := strings.Split(pattern, ";") + +// matches := prefixSuffixRegex.FindAllStringSubmatch(patterns[0], -1) +// if len(matches) > 0 { +// if len(matches[0]) > 1 { +// format.positivePrefix = matches[0][1] +// } +// if len(matches[0]) > 2 { +// format.positiveSuffix = matches[0][2] +// } +// } + +// // default values for negative prefix & suffix +// format.negativePrefix = string(n.Symbols.Negative) + string(format.positivePrefix) +// format.negativeSuffix = format.positiveSuffix + +// // see if they are in the pattern +// if len(patterns) > 1 { +// matches = prefixSuffixRegex.FindAllStringSubmatch(patterns[1], -1) + +// if len(matches) > 0 { +// if len(matches[0]) > 1 { +// format.negativePrefix = matches[0][1] +// } +// if len(matches[0]) > 2 { +// format.negativeSuffix = matches[0][2] +// } +// } +// } + +// pat := patterns[0] + +// if strings.Index(pat, "%") != -1 { +// format.multiplier = 100 +// } else if strings.Index(pat, "‰") != -1 { +// format.multiplier = 1000 +// } else { +// format.multiplier = 1 +// } + +// pos := strings.Index(pat, ".") + +// if pos != -1 { +// pos2 := strings.LastIndex(pat, "0") +// if pos2 > pos { +// format.minDecimalDigits = pos2 - pos +// } + +// pos3 := strings.LastIndex(pat, "#") +// if pos3 >= pos2 { +// format.maxDecimalDigits = pos3 - pos +// } else { +// format.maxDecimalDigits = format.minDecimalDigits +// } + +// pat = pat[0:pos] +// } + +// p := strings.Replace(pat, ",", "", -1) +// pos = strings.Index(p, "0") +// if pos != -1 { +// format.minIntegerDigits = strings.LastIndex(p, "0") - pos + 1 +// } + +// p = strings.Replace(pat, "#", "0", -1) +// pos = strings.LastIndex(pat, ",") +// if pos != -1 { +// format.groupSizeFinal = strings.LastIndex(p, "0") - pos +// pos2 := strings.LastIndex(p[0:pos], ",") +// if pos2 != -1 { +// format.groupSizeMain = pos - pos2 - 1 +// } else { +// format.groupSizeMain = format.groupSizeFinal +// } +// } + +// if includeDecimalDigits { +// nfMutex.Lock() +// numberFormats[pattern] = format +// nfMutex.Unlock() +// return format +// } + +// format.maxDecimalDigits = 0 +// format.minDecimalDigits = 0 +// nfndMutex.Lock() +// numberFormatsNoDecimals[pattern] = format +// nfndMutex.Unlock() +// return format +// } + +type sortRank struct { + Rank uint8 + Value string +} + +type ByRank []sortRank + +func (a ByRank) Len() int { return len(a) } +func (a ByRank) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByRank) Less(i, j int) bool { return a[i].Rank < a[j].Rank } + // TODO: cleanup function logic perhaps write a lexer... but it's working right now, and // I'm already farther down the rabbit hole than I'd like and so pulling the chute here. -func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results string) { +func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results string, plurals string) { var prCardinal *struct { cldr.Common @@ -203,6 +496,8 @@ func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results } "xml:\"pluralRule\"" } + var pluralArr []locales.PluralRule + for _, p := range current.Supplemental().Plurals { for _, pr := range p.PluralRules { @@ -220,6 +515,8 @@ func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results // no plural rules for locale if prCardinal == nil { + plurals = "nil" + results = "return locales.PluralRuleUnknown" return } @@ -229,33 +526,39 @@ func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results // pre parse for variables for _, rule := range prCardinal.PluralRule { + ps1 := pluralStringToString(rule.Count) + psI := pluralStringToInt(rule.Count) + pluralArr = append(pluralArr, psI) + data := strings.Replace(strings.Replace(strings.Replace(strings.TrimSpace(strings.SplitN(rule.Common.Data(), "@", 2)[0]), " = ", " == ", -1), " or ", " || ", -1), " and ", " && ", -1) if len(data) == 0 { if len(prCardinal.PluralRule) == 1 { - results = "return locales." + pluralStringToString(rule.Count) + ", nil" + results = "return locales." + ps1 } else { - results += "\n\nreturn locales." + pluralStringToString(rule.Count) + ", nil" + results += "\n\nreturn locales." + ps1 // results += "else {\nreturn locales." + locales.PluralStringToString(rule.Count) + ", nil\n}" } continue } - if strings.Contains(data, "n") { - vals[prVarFuncs["n"]] = struct{}{} - } + // // All need n, so always add + // if strings.Contains(data, "n") { + // vals[prVarFuncs["n"]] = struct{}{} + // } if strings.Contains(data, "i") { vals[prVarFuncs["i"]] = struct{}{} } - if strings.Contains(data, "v") { - vals[prVarFuncs["v"]] = struct{}{} - } + // v is inherently avaialable as an argument + // if strings.Contains(data, "v") { + // vals[prVarFuncs["v"]] = struct{}{} + // } if strings.Contains(data, "w") { vals[prVarFuncs["w"]] = struct{}{} @@ -269,8 +572,6 @@ func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results vals[prVarFuncs["t"]] = struct{}{} } - // fmt.Println(rule.Count, data) - if first { results += "if " first = false @@ -393,28 +694,95 @@ func parseCardinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results results += " {\n" // return plural rule here - results += "return locales." + pluralStringToString(rule.Count) + ", nil\n" + results += "return locales." + ps1 + "\n" results += "}" } pre := "\n" + // always needed + vals[prVarFuncs["n"]] = struct{}{} + + sorted := make([]sortRank, 0, len(vals)) + for k := range vals { - pre += k + switch k[:1] { + case "n": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["n"], + Rank: 1, + }) + case "i": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["i"], + Rank: 2, + }) + case "w": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["w"], + Rank: 3, + }) + case "f": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["f"], + Rank: 4, + }) + case "t": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["t"], + Rank: 5, + }) + } + } + + sort.Sort(ByRank(sorted)) + + for _, k := range sorted { + pre += k.Value } pre += "\n" if len(results) == 0 { - results = "return locales.PluralRuleUnknown,nil" + results = "return locales.PluralRuleUnknown" + } else { + + if !strings.HasPrefix(results, "return") { + results = pre + results + } } - results = pre + results + if len(pluralArr) == 0 { + plurals = "nil" + } else { + plurals = fmt.Sprintf("%#v", pluralArr) + } return } +// pluralStringToInt returns the enum value of 'plural' provided +func pluralStringToInt(plural string) locales.PluralRule { + + switch plural { + case "zero": + return locales.PluralRuleZero + case "one": + return locales.PluralRuleOne + case "two": + return locales.PluralRuleTwo + case "few": + return locales.PluralRuleFew + case "many": + return locales.PluralRuleMany + case "other": + return locales.PluralRuleOther + default: + return locales.PluralRuleUnknown + } +} + func pluralStringToString(pr string) string { pr = strings.TrimSpace(pr) diff --git a/cmd/resources/translator.tmpl b/cmd/resources/translator.tmpl index 936cd76..bfdb638 100644 --- a/cmd/resources/translator.tmpl +++ b/cmd/resources/translator.tmpl @@ -2,27 +2,48 @@ package {{ .Locale }} import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type {{ .Locale }} struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the '{{ .Locale }}' locale func New() locales.Translator { return &{{ .Locale }}{ - locale: "{{ .Locale }}", + locale: "{{ .Locale }}", + plurals: {{ .Plurals }}, + decimal: {{ .Decimal }}, + group: {{ .Group }}, + minus: {{ .Minus }}, + percent: {{ .Percent }}, + perMille: {{ .PerMille }}, + symbol: {{ .Symbol }}, } } // Locale returns the current translators string locale -func(l *{{ .Locale }}) Locale() string { - return l.locale +func(t *{{ .Locale }}) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with '{{ .Locale }}' +func(t *{{ .Locale }}) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func(l *{{ .Locale }}) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}' +func(t *{{ .Locale }}) cardinalPluralRule(num float64, v uint64) locales.PluralRule { {{ .CardinalFunc }} } diff --git a/resources/locales/af/af.go b/resources/locales/af/af.go index a0006f6..0611efd 100644 --- a/resources/locales/af/af.go +++ b/resources/locales/af/af.go @@ -1,36 +1,54 @@ package af import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type af struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'af' locale func New() locales.Translator { return &af{ - locale: "af", + locale: "af", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *af) Locale() string { - return l.locale +func (t *af) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'af' +func (t *af) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *af) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'af' +func (t *af) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/af_NA/af_NA.go b/resources/locales/af_NA/af_NA.go index 6e96562..de69911 100644 --- a/resources/locales/af_NA/af_NA.go +++ b/resources/locales/af_NA/af_NA.go @@ -1,36 +1,54 @@ package af_NA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type af_NA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'af_NA' locale func New() locales.Translator { return &af_NA{ - locale: "af_NA", + locale: "af_NA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *af_NA) Locale() string { - return l.locale +func (t *af_NA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'af_NA' +func (t *af_NA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *af_NA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'af_NA' +func (t *af_NA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/af_ZA/af_ZA.go b/resources/locales/af_ZA/af_ZA.go index ba4de27..9e7f9db 100644 --- a/resources/locales/af_ZA/af_ZA.go +++ b/resources/locales/af_ZA/af_ZA.go @@ -1,36 +1,54 @@ package af_ZA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type af_ZA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'af_ZA' locale func New() locales.Translator { return &af_ZA{ - locale: "af_ZA", + locale: "af_ZA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *af_ZA) Locale() string { - return l.locale +func (t *af_ZA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'af_ZA' +func (t *af_ZA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *af_ZA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'af_ZA' +func (t *af_ZA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/agq/agq.go b/resources/locales/agq/agq.go index f7a2346..415f82c 100644 --- a/resources/locales/agq/agq.go +++ b/resources/locales/agq/agq.go @@ -1,26 +1,43 @@ package agq -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type agq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'agq' locale func New() locales.Translator { return &agq{ - locale: "agq", + locale: "agq", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *agq) Locale() string { - return l.locale +func (t *agq) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *agq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'agq' +func (t *agq) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'agq' +func (t *agq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/agq_CM/agq_CM.go b/resources/locales/agq_CM/agq_CM.go index 8389310..5e735f5 100644 --- a/resources/locales/agq_CM/agq_CM.go +++ b/resources/locales/agq_CM/agq_CM.go @@ -1,26 +1,43 @@ package agq_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type agq_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'agq_CM' locale func New() locales.Translator { return &agq_CM{ - locale: "agq_CM", + locale: "agq_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *agq_CM) Locale() string { - return l.locale +func (t *agq_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *agq_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'agq_CM' +func (t *agq_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'agq_CM' +func (t *agq_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ak/ak.go b/resources/locales/ak/ak.go index c1b4138..cca84f1 100644 --- a/resources/locales/ak/ak.go +++ b/resources/locales/ak/ak.go @@ -1,36 +1,54 @@ package ak import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ak struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ak' locale func New() locales.Translator { return &ak{ - locale: "ak", + locale: "ak", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ak) Locale() string { - return l.locale +func (t *ak) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ak' +func (t *ak) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ak) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ak' +func (t *ak) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ak_GH/ak_GH.go b/resources/locales/ak_GH/ak_GH.go index 458c02b..7977d7c 100644 --- a/resources/locales/ak_GH/ak_GH.go +++ b/resources/locales/ak_GH/ak_GH.go @@ -1,36 +1,54 @@ package ak_GH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ak_GH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ak_GH' locale func New() locales.Translator { return &ak_GH{ - locale: "ak_GH", + locale: "ak_GH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ak_GH) Locale() string { - return l.locale +func (t *ak_GH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ak_GH' +func (t *ak_GH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ak_GH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ak_GH' +func (t *ak_GH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/am/am.go b/resources/locales/am/am.go index 811c47d..45abbea 100644 --- a/resources/locales/am/am.go +++ b/resources/locales/am/am.go @@ -1,41 +1,55 @@ package am import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type am struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'am' locale func New() locales.Translator { return &am{ - locale: "am", + locale: "am", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *am) Locale() string { - return l.locale +func (t *am) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *am) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'am' +func (t *am) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'am' +func (t *am) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/am_ET/am_ET.go b/resources/locales/am_ET/am_ET.go index 4dbe0a7..3a9e5a4 100644 --- a/resources/locales/am_ET/am_ET.go +++ b/resources/locales/am_ET/am_ET.go @@ -1,41 +1,55 @@ package am_ET import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type am_ET struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'am_ET' locale func New() locales.Translator { return &am_ET{ - locale: "am_ET", + locale: "am_ET", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *am_ET) Locale() string { - return l.locale +func (t *am_ET) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *am_ET) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'am_ET' +func (t *am_ET) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'am_ET' +func (t *am_ET) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar/ar.go b/resources/locales/ar/ar.go index 345b265..e502fbf 100644 --- a/resources/locales/ar/ar.go +++ b/resources/locales/ar/ar.go @@ -1,44 +1,62 @@ package ar import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar' locale func New() locales.Translator { return &ar{ - locale: "ar", + locale: "ar", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0xe2, 0x80, 0x8f, 0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar) Locale() string { - return l.locale +func (t *ar) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar' +func (t *ar) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar' +func (t *ar) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_001/ar_001.go b/resources/locales/ar_001/ar_001.go index 23318a7..e8eee6c 100644 --- a/resources/locales/ar_001/ar_001.go +++ b/resources/locales/ar_001/ar_001.go @@ -1,44 +1,62 @@ package ar_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_001' locale func New() locales.Translator { return &ar_001{ - locale: "ar_001", + locale: "ar_001", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_001) Locale() string { - return l.locale +func (t *ar_001) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_001' +func (t *ar_001) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_001) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_001' +func (t *ar_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_AE/ar_AE.go b/resources/locales/ar_AE/ar_AE.go index c786b11..047ffa8 100644 --- a/resources/locales/ar_AE/ar_AE.go +++ b/resources/locales/ar_AE/ar_AE.go @@ -1,44 +1,62 @@ package ar_AE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_AE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_AE' locale func New() locales.Translator { return &ar_AE{ - locale: "ar_AE", + locale: "ar_AE", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_AE) Locale() string { - return l.locale +func (t *ar_AE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_AE' +func (t *ar_AE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_AE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_AE' +func (t *ar_AE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_BH/ar_BH.go b/resources/locales/ar_BH/ar_BH.go index 290d011..9655e8f 100644 --- a/resources/locales/ar_BH/ar_BH.go +++ b/resources/locales/ar_BH/ar_BH.go @@ -1,44 +1,62 @@ package ar_BH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_BH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_BH' locale func New() locales.Translator { return &ar_BH{ - locale: "ar_BH", + locale: "ar_BH", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_BH) Locale() string { - return l.locale +func (t *ar_BH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_BH' +func (t *ar_BH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_BH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_BH' +func (t *ar_BH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_DJ/ar_DJ.go b/resources/locales/ar_DJ/ar_DJ.go index c76e631..5ad444f 100644 --- a/resources/locales/ar_DJ/ar_DJ.go +++ b/resources/locales/ar_DJ/ar_DJ.go @@ -1,44 +1,62 @@ package ar_DJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_DJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_DJ' locale func New() locales.Translator { return &ar_DJ{ - locale: "ar_DJ", + locale: "ar_DJ", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_DJ) Locale() string { - return l.locale +func (t *ar_DJ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_DJ' +func (t *ar_DJ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_DJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_DJ' +func (t *ar_DJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_DZ/ar_DZ.go b/resources/locales/ar_DZ/ar_DZ.go index 9440142..2fc7678 100644 --- a/resources/locales/ar_DZ/ar_DZ.go +++ b/resources/locales/ar_DZ/ar_DZ.go @@ -1,44 +1,62 @@ package ar_DZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_DZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_DZ' locale func New() locales.Translator { return &ar_DZ{ - locale: "ar_DZ", + locale: "ar_DZ", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_DZ) Locale() string { - return l.locale +func (t *ar_DZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_DZ' +func (t *ar_DZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_DZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_DZ' +func (t *ar_DZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_EG/ar_EG.go b/resources/locales/ar_EG/ar_EG.go index b97f68c..2e6b2c0 100644 --- a/resources/locales/ar_EG/ar_EG.go +++ b/resources/locales/ar_EG/ar_EG.go @@ -1,44 +1,62 @@ package ar_EG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_EG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_EG' locale func New() locales.Translator { return &ar_EG{ - locale: "ar_EG", + locale: "ar_EG", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_EG) Locale() string { - return l.locale +func (t *ar_EG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_EG' +func (t *ar_EG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_EG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_EG' +func (t *ar_EG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_EH/ar_EH.go b/resources/locales/ar_EH/ar_EH.go index d2454b1..ce99ce8 100644 --- a/resources/locales/ar_EH/ar_EH.go +++ b/resources/locales/ar_EH/ar_EH.go @@ -1,44 +1,62 @@ package ar_EH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_EH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_EH' locale func New() locales.Translator { return &ar_EH{ - locale: "ar_EH", + locale: "ar_EH", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_EH) Locale() string { - return l.locale +func (t *ar_EH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_EH' +func (t *ar_EH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_EH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_EH' +func (t *ar_EH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_ER/ar_ER.go b/resources/locales/ar_ER/ar_ER.go index 09f09a2..a6ce04f 100644 --- a/resources/locales/ar_ER/ar_ER.go +++ b/resources/locales/ar_ER/ar_ER.go @@ -1,44 +1,62 @@ package ar_ER import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_ER struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_ER' locale func New() locales.Translator { return &ar_ER{ - locale: "ar_ER", + locale: "ar_ER", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_ER) Locale() string { - return l.locale +func (t *ar_ER) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_ER' +func (t *ar_ER) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_ER) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_ER' +func (t *ar_ER) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_IL/ar_IL.go b/resources/locales/ar_IL/ar_IL.go index a6fd007..a96427e 100644 --- a/resources/locales/ar_IL/ar_IL.go +++ b/resources/locales/ar_IL/ar_IL.go @@ -1,44 +1,62 @@ package ar_IL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_IL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_IL' locale func New() locales.Translator { return &ar_IL{ - locale: "ar_IL", + locale: "ar_IL", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_IL) Locale() string { - return l.locale +func (t *ar_IL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_IL' +func (t *ar_IL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_IL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_IL' +func (t *ar_IL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_IQ/ar_IQ.go b/resources/locales/ar_IQ/ar_IQ.go index 18f610f..d10d4ce 100644 --- a/resources/locales/ar_IQ/ar_IQ.go +++ b/resources/locales/ar_IQ/ar_IQ.go @@ -1,44 +1,62 @@ package ar_IQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_IQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_IQ' locale func New() locales.Translator { return &ar_IQ{ - locale: "ar_IQ", + locale: "ar_IQ", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_IQ) Locale() string { - return l.locale +func (t *ar_IQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_IQ' +func (t *ar_IQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_IQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_IQ' +func (t *ar_IQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_JO/ar_JO.go b/resources/locales/ar_JO/ar_JO.go index 2fb674f..b2aa37e 100644 --- a/resources/locales/ar_JO/ar_JO.go +++ b/resources/locales/ar_JO/ar_JO.go @@ -1,44 +1,62 @@ package ar_JO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_JO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_JO' locale func New() locales.Translator { return &ar_JO{ - locale: "ar_JO", + locale: "ar_JO", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_JO) Locale() string { - return l.locale +func (t *ar_JO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_JO' +func (t *ar_JO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_JO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_JO' +func (t *ar_JO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_KM/ar_KM.go b/resources/locales/ar_KM/ar_KM.go index 0e88da5..bfcd426 100644 --- a/resources/locales/ar_KM/ar_KM.go +++ b/resources/locales/ar_KM/ar_KM.go @@ -1,44 +1,62 @@ package ar_KM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_KM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_KM' locale func New() locales.Translator { return &ar_KM{ - locale: "ar_KM", + locale: "ar_KM", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_KM) Locale() string { - return l.locale +func (t *ar_KM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_KM' +func (t *ar_KM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_KM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_KM' +func (t *ar_KM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_KW/ar_KW.go b/resources/locales/ar_KW/ar_KW.go index b3f2ca3..0e744fe 100644 --- a/resources/locales/ar_KW/ar_KW.go +++ b/resources/locales/ar_KW/ar_KW.go @@ -1,44 +1,62 @@ package ar_KW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_KW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_KW' locale func New() locales.Translator { return &ar_KW{ - locale: "ar_KW", + locale: "ar_KW", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_KW) Locale() string { - return l.locale +func (t *ar_KW) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_KW' +func (t *ar_KW) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_KW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_KW' +func (t *ar_KW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_LB/ar_LB.go b/resources/locales/ar_LB/ar_LB.go index b63769d..6c2ce1d 100644 --- a/resources/locales/ar_LB/ar_LB.go +++ b/resources/locales/ar_LB/ar_LB.go @@ -1,44 +1,62 @@ package ar_LB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_LB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_LB' locale func New() locales.Translator { return &ar_LB{ - locale: "ar_LB", + locale: "ar_LB", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_LB) Locale() string { - return l.locale +func (t *ar_LB) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_LB' +func (t *ar_LB) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_LB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_LB' +func (t *ar_LB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_LY/ar_LY.go b/resources/locales/ar_LY/ar_LY.go index 8d19c61..b56b54c 100644 --- a/resources/locales/ar_LY/ar_LY.go +++ b/resources/locales/ar_LY/ar_LY.go @@ -1,44 +1,62 @@ package ar_LY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_LY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_LY' locale func New() locales.Translator { return &ar_LY{ - locale: "ar_LY", + locale: "ar_LY", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_LY) Locale() string { - return l.locale +func (t *ar_LY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_LY' +func (t *ar_LY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_LY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_LY' +func (t *ar_LY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_MA/ar_MA.go b/resources/locales/ar_MA/ar_MA.go index 3e16870..7d81eda 100644 --- a/resources/locales/ar_MA/ar_MA.go +++ b/resources/locales/ar_MA/ar_MA.go @@ -1,44 +1,62 @@ package ar_MA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_MA' locale func New() locales.Translator { return &ar_MA{ - locale: "ar_MA", + locale: "ar_MA", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_MA) Locale() string { - return l.locale +func (t *ar_MA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_MA' +func (t *ar_MA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_MA' +func (t *ar_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_MR/ar_MR.go b/resources/locales/ar_MR/ar_MR.go index 1e09a3c..d4ba1a7 100644 --- a/resources/locales/ar_MR/ar_MR.go +++ b/resources/locales/ar_MR/ar_MR.go @@ -1,44 +1,62 @@ package ar_MR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_MR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_MR' locale func New() locales.Translator { return &ar_MR{ - locale: "ar_MR", + locale: "ar_MR", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_MR) Locale() string { - return l.locale +func (t *ar_MR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_MR' +func (t *ar_MR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_MR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_MR' +func (t *ar_MR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_OM/ar_OM.go b/resources/locales/ar_OM/ar_OM.go index 20c1999..c7b0f93 100644 --- a/resources/locales/ar_OM/ar_OM.go +++ b/resources/locales/ar_OM/ar_OM.go @@ -1,44 +1,62 @@ package ar_OM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_OM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_OM' locale func New() locales.Translator { return &ar_OM{ - locale: "ar_OM", + locale: "ar_OM", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_OM) Locale() string { - return l.locale +func (t *ar_OM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_OM' +func (t *ar_OM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_OM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_OM' +func (t *ar_OM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_PS/ar_PS.go b/resources/locales/ar_PS/ar_PS.go index 1636aaa..189f55b 100644 --- a/resources/locales/ar_PS/ar_PS.go +++ b/resources/locales/ar_PS/ar_PS.go @@ -1,44 +1,62 @@ package ar_PS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_PS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_PS' locale func New() locales.Translator { return &ar_PS{ - locale: "ar_PS", + locale: "ar_PS", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_PS) Locale() string { - return l.locale +func (t *ar_PS) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_PS' +func (t *ar_PS) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_PS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_PS' +func (t *ar_PS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_QA/ar_QA.go b/resources/locales/ar_QA/ar_QA.go index fd7560b..fb749c7 100644 --- a/resources/locales/ar_QA/ar_QA.go +++ b/resources/locales/ar_QA/ar_QA.go @@ -1,44 +1,62 @@ package ar_QA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_QA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_QA' locale func New() locales.Translator { return &ar_QA{ - locale: "ar_QA", + locale: "ar_QA", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_QA) Locale() string { - return l.locale +func (t *ar_QA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_QA' +func (t *ar_QA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_QA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_QA' +func (t *ar_QA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_SA/ar_SA.go b/resources/locales/ar_SA/ar_SA.go index 3ebadea..e7a530f 100644 --- a/resources/locales/ar_SA/ar_SA.go +++ b/resources/locales/ar_SA/ar_SA.go @@ -1,44 +1,62 @@ package ar_SA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_SA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_SA' locale func New() locales.Translator { return &ar_SA{ - locale: "ar_SA", + locale: "ar_SA", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_SA) Locale() string { - return l.locale +func (t *ar_SA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_SA' +func (t *ar_SA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_SA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_SA' +func (t *ar_SA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_SD/ar_SD.go b/resources/locales/ar_SD/ar_SD.go index b191eb3..288e716 100644 --- a/resources/locales/ar_SD/ar_SD.go +++ b/resources/locales/ar_SD/ar_SD.go @@ -1,44 +1,62 @@ package ar_SD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_SD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_SD' locale func New() locales.Translator { return &ar_SD{ - locale: "ar_SD", + locale: "ar_SD", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_SD) Locale() string { - return l.locale +func (t *ar_SD) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_SD' +func (t *ar_SD) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_SD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_SD' +func (t *ar_SD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_SO/ar_SO.go b/resources/locales/ar_SO/ar_SO.go index 06468be..02167c3 100644 --- a/resources/locales/ar_SO/ar_SO.go +++ b/resources/locales/ar_SO/ar_SO.go @@ -1,44 +1,62 @@ package ar_SO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_SO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_SO' locale func New() locales.Translator { return &ar_SO{ - locale: "ar_SO", + locale: "ar_SO", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ar_SO) Locale() string { - return l.locale +func (t *ar_SO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_SO' +func (t *ar_SO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_SO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_SO' +func (t *ar_SO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_SS/ar_SS.go b/resources/locales/ar_SS/ar_SS.go index dfad159..ff56659 100644 --- a/resources/locales/ar_SS/ar_SS.go +++ b/resources/locales/ar_SS/ar_SS.go @@ -1,44 +1,62 @@ package ar_SS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_SS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_SS' locale func New() locales.Translator { return &ar_SS{ - locale: "ar_SS", + locale: "ar_SS", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_SS) Locale() string { - return l.locale +func (t *ar_SS) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_SS' +func (t *ar_SS) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_SS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_SS' +func (t *ar_SS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_SY/ar_SY.go b/resources/locales/ar_SY/ar_SY.go index 87f8105..193c8bf 100644 --- a/resources/locales/ar_SY/ar_SY.go +++ b/resources/locales/ar_SY/ar_SY.go @@ -1,44 +1,62 @@ package ar_SY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_SY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_SY' locale func New() locales.Translator { return &ar_SY{ - locale: "ar_SY", + locale: "ar_SY", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_SY) Locale() string { - return l.locale +func (t *ar_SY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_SY' +func (t *ar_SY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_SY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_SY' +func (t *ar_SY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_TD/ar_TD.go b/resources/locales/ar_TD/ar_TD.go index 39505af..ca46614 100644 --- a/resources/locales/ar_TD/ar_TD.go +++ b/resources/locales/ar_TD/ar_TD.go @@ -1,44 +1,62 @@ package ar_TD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_TD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_TD' locale func New() locales.Translator { return &ar_TD{ - locale: "ar_TD", + locale: "ar_TD", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_TD) Locale() string { - return l.locale +func (t *ar_TD) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_TD' +func (t *ar_TD) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_TD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_TD' +func (t *ar_TD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_TN/ar_TN.go b/resources/locales/ar_TN/ar_TN.go index e2443d5..6eb26fc 100644 --- a/resources/locales/ar_TN/ar_TN.go +++ b/resources/locales/ar_TN/ar_TN.go @@ -1,44 +1,62 @@ package ar_TN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_TN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_TN' locale func New() locales.Translator { return &ar_TN{ - locale: "ar_TN", + locale: "ar_TN", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_TN) Locale() string { - return l.locale +func (t *ar_TN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_TN' +func (t *ar_TN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_TN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_TN' +func (t *ar_TN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ar_YE/ar_YE.go b/resources/locales/ar_YE/ar_YE.go index f5728a3..4900236 100644 --- a/resources/locales/ar_YE/ar_YE.go +++ b/resources/locales/ar_YE/ar_YE.go @@ -1,44 +1,62 @@ package ar_YE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ar_YE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ar_YE' locale func New() locales.Translator { return &ar_YE{ - locale: "ar_YE", + locale: "ar_YE", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ar_YE) Locale() string { - return l.locale +func (t *ar_YE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ar_YE' +func (t *ar_YE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ar_YE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ar_YE' +func (t *ar_YE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%100 >= 3 && n%100 <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 99 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/as/as.go b/resources/locales/as/as.go index 2e173d5..0f33916 100644 --- a/resources/locales/as/as.go +++ b/resources/locales/as/as.go @@ -1,41 +1,55 @@ package as import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type as struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'as' locale func New() locales.Translator { return &as{ - locale: "as", + locale: "as", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *as) Locale() string { - return l.locale +func (t *as) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *as) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'as' +func (t *as) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'as' +func (t *as) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/as_IN/as_IN.go b/resources/locales/as_IN/as_IN.go index a9bc185..5da0dfc 100644 --- a/resources/locales/as_IN/as_IN.go +++ b/resources/locales/as_IN/as_IN.go @@ -1,41 +1,55 @@ package as_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type as_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'as_IN' locale func New() locales.Translator { return &as_IN{ - locale: "as_IN", + locale: "as_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *as_IN) Locale() string { - return l.locale +func (t *as_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *as_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'as_IN' +func (t *as_IN) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'as_IN' +func (t *as_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/asa/asa.go b/resources/locales/asa/asa.go index 72e657c..1dc73e6 100644 --- a/resources/locales/asa/asa.go +++ b/resources/locales/asa/asa.go @@ -1,36 +1,54 @@ package asa import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type asa struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'asa' locale func New() locales.Translator { return &asa{ - locale: "asa", + locale: "asa", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *asa) Locale() string { - return l.locale +func (t *asa) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'asa' +func (t *asa) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *asa) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'asa' +func (t *asa) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/asa_TZ/asa_TZ.go b/resources/locales/asa_TZ/asa_TZ.go index 5dd65b3..3c3354f 100644 --- a/resources/locales/asa_TZ/asa_TZ.go +++ b/resources/locales/asa_TZ/asa_TZ.go @@ -1,36 +1,54 @@ package asa_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type asa_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'asa_TZ' locale func New() locales.Translator { return &asa_TZ{ - locale: "asa_TZ", + locale: "asa_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *asa_TZ) Locale() string { - return l.locale +func (t *asa_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'asa_TZ' +func (t *asa_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *asa_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'asa_TZ' +func (t *asa_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ast/ast.go b/resources/locales/ast/ast.go index cf76b2d..be47d79 100644 --- a/resources/locales/ast/ast.go +++ b/resources/locales/ast/ast.go @@ -1,38 +1,55 @@ package ast import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ast struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ast' locale func New() locales.Translator { return &ast{ - locale: "ast", + locale: "ast", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0xe2, 0x80, 0x8f, 0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ast) Locale() string { - return l.locale +func (t *ast) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ast) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ast' +func (t *ast) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ast' +func (t *ast) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ast_ES/ast_ES.go b/resources/locales/ast_ES/ast_ES.go index 22c06a2..5f095b9 100644 --- a/resources/locales/ast_ES/ast_ES.go +++ b/resources/locales/ast_ES/ast_ES.go @@ -1,38 +1,55 @@ package ast_ES import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ast_ES struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ast_ES' locale func New() locales.Translator { return &ast_ES{ - locale: "ast_ES", + locale: "ast_ES", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ast_ES) Locale() string { - return l.locale +func (t *ast_ES) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ast_ES) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ast_ES' +func (t *ast_ES) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ast_ES' +func (t *ast_ES) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/az/az.go b/resources/locales/az/az.go index 4ace91f..72a2f72 100644 --- a/resources/locales/az/az.go +++ b/resources/locales/az/az.go @@ -1,36 +1,54 @@ package az import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type az struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'az' locale func New() locales.Translator { return &az{ - locale: "az", + locale: "az", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *az) Locale() string { - return l.locale +func (t *az) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'az' +func (t *az) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *az) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'az' +func (t *az) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/az_Cyrl/az_Cyrl.go b/resources/locales/az_Cyrl/az_Cyrl.go index 10f29ac..ae3e053 100644 --- a/resources/locales/az_Cyrl/az_Cyrl.go +++ b/resources/locales/az_Cyrl/az_Cyrl.go @@ -1,36 +1,54 @@ package az_Cyrl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type az_Cyrl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'az_Cyrl' locale func New() locales.Translator { return &az_Cyrl{ - locale: "az_Cyrl", + locale: "az_Cyrl", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *az_Cyrl) Locale() string { - return l.locale +func (t *az_Cyrl) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'az_Cyrl' +func (t *az_Cyrl) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *az_Cyrl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl' +func (t *az_Cyrl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/az_Cyrl_AZ/az_Cyrl_AZ.go b/resources/locales/az_Cyrl_AZ/az_Cyrl_AZ.go index b65a1d1..d57c6cc 100644 --- a/resources/locales/az_Cyrl_AZ/az_Cyrl_AZ.go +++ b/resources/locales/az_Cyrl_AZ/az_Cyrl_AZ.go @@ -1,36 +1,54 @@ package az_Cyrl_AZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type az_Cyrl_AZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'az_Cyrl_AZ' locale func New() locales.Translator { return &az_Cyrl_AZ{ - locale: "az_Cyrl_AZ", + locale: "az_Cyrl_AZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *az_Cyrl_AZ) Locale() string { - return l.locale +func (t *az_Cyrl_AZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'az_Cyrl_AZ' +func (t *az_Cyrl_AZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *az_Cyrl_AZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl_AZ' +func (t *az_Cyrl_AZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/az_Latn/az_Latn.go b/resources/locales/az_Latn/az_Latn.go index 1b85052..9eda150 100644 --- a/resources/locales/az_Latn/az_Latn.go +++ b/resources/locales/az_Latn/az_Latn.go @@ -1,36 +1,54 @@ package az_Latn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type az_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'az_Latn' locale func New() locales.Translator { return &az_Latn{ - locale: "az_Latn", + locale: "az_Latn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *az_Latn) Locale() string { - return l.locale +func (t *az_Latn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'az_Latn' +func (t *az_Latn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *az_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'az_Latn' +func (t *az_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/az_Latn_AZ/az_Latn_AZ.go b/resources/locales/az_Latn_AZ/az_Latn_AZ.go index b1a9702..23728ed 100644 --- a/resources/locales/az_Latn_AZ/az_Latn_AZ.go +++ b/resources/locales/az_Latn_AZ/az_Latn_AZ.go @@ -1,36 +1,54 @@ package az_Latn_AZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type az_Latn_AZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'az_Latn_AZ' locale func New() locales.Translator { return &az_Latn_AZ{ - locale: "az_Latn_AZ", + locale: "az_Latn_AZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *az_Latn_AZ) Locale() string { - return l.locale +func (t *az_Latn_AZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'az_Latn_AZ' +func (t *az_Latn_AZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *az_Latn_AZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'az_Latn_AZ' +func (t *az_Latn_AZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bas/bas.go b/resources/locales/bas/bas.go index 3e9ba43..8f76d72 100644 --- a/resources/locales/bas/bas.go +++ b/resources/locales/bas/bas.go @@ -1,26 +1,43 @@ package bas -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bas struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bas' locale func New() locales.Translator { return &bas{ - locale: "bas", + locale: "bas", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bas) Locale() string { - return l.locale +func (t *bas) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bas) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bas' +func (t *bas) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bas' +func (t *bas) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/bas_CM/bas_CM.go b/resources/locales/bas_CM/bas_CM.go index 3925521..67dab62 100644 --- a/resources/locales/bas_CM/bas_CM.go +++ b/resources/locales/bas_CM/bas_CM.go @@ -1,26 +1,43 @@ package bas_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bas_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bas_CM' locale func New() locales.Translator { return &bas_CM{ - locale: "bas_CM", + locale: "bas_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bas_CM) Locale() string { - return l.locale +func (t *bas_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bas_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bas_CM' +func (t *bas_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bas_CM' +func (t *bas_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/be/be.go b/resources/locales/be/be.go index bcc43ee..0559af9 100644 --- a/resources/locales/be/be.go +++ b/resources/locales/be/be.go @@ -1,40 +1,58 @@ package be import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type be struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'be' locale func New() locales.Translator { return &be{ - locale: "be", + locale: "be", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *be) Locale() string { - return l.locale +func (t *be) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'be' +func (t *be) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *be) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'be' +func (t *be) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n%10 == 1 && n%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 >= 2 && n%10 <= 4 && n%100 < 12 && n%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (n%10 == 0) || (n%10 >= 5 && n%10 <= 9) || (n%100 >= 11 && n%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/be_BY/be_BY.go b/resources/locales/be_BY/be_BY.go index f9fbed5..0d38e85 100644 --- a/resources/locales/be_BY/be_BY.go +++ b/resources/locales/be_BY/be_BY.go @@ -1,40 +1,58 @@ package be_BY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type be_BY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'be_BY' locale func New() locales.Translator { return &be_BY{ - locale: "be_BY", + locale: "be_BY", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *be_BY) Locale() string { - return l.locale +func (t *be_BY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'be_BY' +func (t *be_BY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *be_BY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'be_BY' +func (t *be_BY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n%10 == 1 && n%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 >= 2 && n%10 <= 4 && n%100 < 12 && n%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (n%10 == 0) || (n%10 >= 5 && n%10 <= 9) || (n%100 >= 11 && n%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bem/bem.go b/resources/locales/bem/bem.go index ce390bf..1a87b39 100644 --- a/resources/locales/bem/bem.go +++ b/resources/locales/bem/bem.go @@ -1,36 +1,54 @@ package bem import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bem struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bem' locale func New() locales.Translator { return &bem{ - locale: "bem", + locale: "bem", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bem) Locale() string { - return l.locale +func (t *bem) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bem' +func (t *bem) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bem) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bem' +func (t *bem) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bem_ZM/bem_ZM.go b/resources/locales/bem_ZM/bem_ZM.go index 75b8595..d679bbf 100644 --- a/resources/locales/bem_ZM/bem_ZM.go +++ b/resources/locales/bem_ZM/bem_ZM.go @@ -1,36 +1,54 @@ package bem_ZM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bem_ZM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bem_ZM' locale func New() locales.Translator { return &bem_ZM{ - locale: "bem_ZM", + locale: "bem_ZM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bem_ZM) Locale() string { - return l.locale +func (t *bem_ZM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bem_ZM' +func (t *bem_ZM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bem_ZM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bem_ZM' +func (t *bem_ZM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bez/bez.go b/resources/locales/bez/bez.go index 81ffcd5..ef4eb9d 100644 --- a/resources/locales/bez/bez.go +++ b/resources/locales/bez/bez.go @@ -1,36 +1,54 @@ package bez import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bez struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bez' locale func New() locales.Translator { return &bez{ - locale: "bez", + locale: "bez", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bez) Locale() string { - return l.locale +func (t *bez) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bez' +func (t *bez) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bez) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bez' +func (t *bez) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bez_TZ/bez_TZ.go b/resources/locales/bez_TZ/bez_TZ.go index 0423062..51a00f4 100644 --- a/resources/locales/bez_TZ/bez_TZ.go +++ b/resources/locales/bez_TZ/bez_TZ.go @@ -1,36 +1,54 @@ package bez_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bez_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bez_TZ' locale func New() locales.Translator { return &bez_TZ{ - locale: "bez_TZ", + locale: "bez_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bez_TZ) Locale() string { - return l.locale +func (t *bez_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bez_TZ' +func (t *bez_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bez_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bez_TZ' +func (t *bez_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bg/bg.go b/resources/locales/bg/bg.go index f1486aa..c2d317a 100644 --- a/resources/locales/bg/bg.go +++ b/resources/locales/bg/bg.go @@ -1,36 +1,54 @@ package bg import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bg' locale func New() locales.Translator { return &bg{ - locale: "bg", + locale: "bg", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bg) Locale() string { - return l.locale +func (t *bg) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bg' +func (t *bg) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bg' +func (t *bg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bg_BG/bg_BG.go b/resources/locales/bg_BG/bg_BG.go index 2bf6d01..0444f88 100644 --- a/resources/locales/bg_BG/bg_BG.go +++ b/resources/locales/bg_BG/bg_BG.go @@ -1,36 +1,54 @@ package bg_BG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bg_BG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bg_BG' locale func New() locales.Translator { return &bg_BG{ - locale: "bg_BG", + locale: "bg_BG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bg_BG) Locale() string { - return l.locale +func (t *bg_BG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'bg_BG' +func (t *bg_BG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bg_BG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bg_BG' +func (t *bg_BG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bm/bm.go b/resources/locales/bm/bm.go index f07b3d2..c5f2827 100644 --- a/resources/locales/bm/bm.go +++ b/resources/locales/bm/bm.go @@ -1,27 +1,43 @@ package bm -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bm struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bm' locale func New() locales.Translator { return &bm{ - locale: "bm", + locale: "bm", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bm) Locale() string { - return l.locale +func (t *bm) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bm) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bm' +func (t *bm) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bm' +func (t *bm) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/bm_ML/bm_ML.go b/resources/locales/bm_ML/bm_ML.go index 61a8919..cca69b4 100644 --- a/resources/locales/bm_ML/bm_ML.go +++ b/resources/locales/bm_ML/bm_ML.go @@ -1,27 +1,43 @@ package bm_ML -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bm_ML struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bm_ML' locale func New() locales.Translator { return &bm_ML{ - locale: "bm_ML", + locale: "bm_ML", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bm_ML) Locale() string { - return l.locale +func (t *bm_ML) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bm_ML) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bm_ML' +func (t *bm_ML) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bm_ML' +func (t *bm_ML) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/bn/bn.go b/resources/locales/bn/bn.go index bdb9768..824ce6a 100644 --- a/resources/locales/bn/bn.go +++ b/resources/locales/bn/bn.go @@ -1,41 +1,55 @@ package bn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bn' locale func New() locales.Translator { return &bn{ - locale: "bn", + locale: "bn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bn) Locale() string { - return l.locale +func (t *bn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bn' +func (t *bn) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bn' +func (t *bn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bn_BD/bn_BD.go b/resources/locales/bn_BD/bn_BD.go index bbdb068..0398320 100644 --- a/resources/locales/bn_BD/bn_BD.go +++ b/resources/locales/bn_BD/bn_BD.go @@ -1,41 +1,55 @@ package bn_BD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bn_BD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bn_BD' locale func New() locales.Translator { return &bn_BD{ - locale: "bn_BD", + locale: "bn_BD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bn_BD) Locale() string { - return l.locale +func (t *bn_BD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bn_BD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bn_BD' +func (t *bn_BD) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bn_BD' +func (t *bn_BD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bn_IN/bn_IN.go b/resources/locales/bn_IN/bn_IN.go index 2374995..9795720 100644 --- a/resources/locales/bn_IN/bn_IN.go +++ b/resources/locales/bn_IN/bn_IN.go @@ -1,41 +1,55 @@ package bn_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bn_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bn_IN' locale func New() locales.Translator { return &bn_IN{ - locale: "bn_IN", + locale: "bn_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bn_IN) Locale() string { - return l.locale +func (t *bn_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bn_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bn_IN' +func (t *bn_IN) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bn_IN' +func (t *bn_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bo/bo.go b/resources/locales/bo/bo.go index 75ce901..8d803f1 100644 --- a/resources/locales/bo/bo.go +++ b/resources/locales/bo/bo.go @@ -1,27 +1,43 @@ package bo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bo' locale func New() locales.Translator { return &bo{ - locale: "bo", + locale: "bo", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bo) Locale() string { - return l.locale +func (t *bo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bo' +func (t *bo) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bo' +func (t *bo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/bo_CN/bo_CN.go b/resources/locales/bo_CN/bo_CN.go index 27da956..b7caff4 100644 --- a/resources/locales/bo_CN/bo_CN.go +++ b/resources/locales/bo_CN/bo_CN.go @@ -1,27 +1,43 @@ package bo_CN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bo_CN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bo_CN' locale func New() locales.Translator { return &bo_CN{ - locale: "bo_CN", + locale: "bo_CN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bo_CN) Locale() string { - return l.locale +func (t *bo_CN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bo_CN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bo_CN' +func (t *bo_CN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bo_CN' +func (t *bo_CN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/bo_IN/bo_IN.go b/resources/locales/bo_IN/bo_IN.go index 7c0f76e..a5349ea 100644 --- a/resources/locales/bo_IN/bo_IN.go +++ b/resources/locales/bo_IN/bo_IN.go @@ -1,27 +1,43 @@ package bo_IN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type bo_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bo_IN' locale func New() locales.Translator { return &bo_IN{ - locale: "bo_IN", + locale: "bo_IN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bo_IN) Locale() string { - return l.locale +func (t *bo_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bo_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bo_IN' +func (t *bo_IN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bo_IN' +func (t *bo_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/br/br.go b/resources/locales/br/br.go index 6f884a8..881d6ca 100644 --- a/resources/locales/br/br.go +++ b/resources/locales/br/br.go @@ -1,42 +1,60 @@ package br import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type br struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'br' locale func New() locales.Translator { return &br{ - locale: "br", + locale: "br", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *br) Locale() string { - return l.locale +func (t *br) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'br' +func (t *br) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *br) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'br' +func (t *br) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n%10 == 1 && (n%100 != 11 && n%100 != 71 && n%100 != 91) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 == 2 && (n%100 != 12 && n%100 != 72 && n%100 != 92) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%10 >= 3 && n%10 <= 4 && (n%10 == 9) && (n%100 < 10 && n%100 > 19) || (n%100 < 70 && n%100 > 79) || (n%100 < 90 && n%100 > 99) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n != 0 && n%1000000 == 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/br_FR/br_FR.go b/resources/locales/br_FR/br_FR.go index 43fe3c0..3254cda 100644 --- a/resources/locales/br_FR/br_FR.go +++ b/resources/locales/br_FR/br_FR.go @@ -1,42 +1,60 @@ package br_FR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type br_FR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'br_FR' locale func New() locales.Translator { return &br_FR{ - locale: "br_FR", + locale: "br_FR", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *br_FR) Locale() string { - return l.locale +func (t *br_FR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'br_FR' +func (t *br_FR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *br_FR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'br_FR' +func (t *br_FR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n%10 == 1 && (n%100 != 11 && n%100 != 71 && n%100 != 91) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 == 2 && (n%100 != 12 && n%100 != 72 && n%100 != 92) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n%10 >= 3 && n%10 <= 4 && (n%10 == 9) && (n%100 < 10 && n%100 > 19) || (n%100 < 70 && n%100 > 79) || (n%100 < 90 && n%100 > 99) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n != 0 && n%1000000 == 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/brx/brx.go b/resources/locales/brx/brx.go index 3d46227..dedf05d 100644 --- a/resources/locales/brx/brx.go +++ b/resources/locales/brx/brx.go @@ -1,36 +1,54 @@ package brx import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type brx struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'brx' locale func New() locales.Translator { return &brx{ - locale: "brx", + locale: "brx", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *brx) Locale() string { - return l.locale +func (t *brx) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'brx' +func (t *brx) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *brx) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'brx' +func (t *brx) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/brx_IN/brx_IN.go b/resources/locales/brx_IN/brx_IN.go index 256418c..0723ae0 100644 --- a/resources/locales/brx_IN/brx_IN.go +++ b/resources/locales/brx_IN/brx_IN.go @@ -1,36 +1,54 @@ package brx_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type brx_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'brx_IN' locale func New() locales.Translator { return &brx_IN{ - locale: "brx_IN", + locale: "brx_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *brx_IN) Locale() string { - return l.locale +func (t *brx_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'brx_IN' +func (t *brx_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *brx_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'brx_IN' +func (t *brx_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bs/bs.go b/resources/locales/bs/bs.go index adc1813..53f62e6 100644 --- a/resources/locales/bs/bs.go +++ b/resources/locales/bs/bs.go @@ -1,45 +1,58 @@ package bs import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bs struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bs' locale func New() locales.Translator { return &bs{ - locale: "bs", + locale: "bs", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bs) Locale() string { - return l.locale +func (t *bs) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bs) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'bs' +func (t *bs) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bs' +func (t *bs) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bs_Cyrl/bs_Cyrl.go b/resources/locales/bs_Cyrl/bs_Cyrl.go index df6cfae..dfe9e2b 100644 --- a/resources/locales/bs_Cyrl/bs_Cyrl.go +++ b/resources/locales/bs_Cyrl/bs_Cyrl.go @@ -1,45 +1,58 @@ package bs_Cyrl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bs_Cyrl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bs_Cyrl' locale func New() locales.Translator { return &bs_Cyrl{ - locale: "bs_Cyrl", + locale: "bs_Cyrl", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bs_Cyrl) Locale() string { - return l.locale +func (t *bs_Cyrl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bs_Cyrl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'bs_Cyrl' +func (t *bs_Cyrl) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl' +func (t *bs_Cyrl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bs_Cyrl_BA/bs_Cyrl_BA.go b/resources/locales/bs_Cyrl_BA/bs_Cyrl_BA.go index 450614e..f74f308 100644 --- a/resources/locales/bs_Cyrl_BA/bs_Cyrl_BA.go +++ b/resources/locales/bs_Cyrl_BA/bs_Cyrl_BA.go @@ -1,45 +1,58 @@ package bs_Cyrl_BA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bs_Cyrl_BA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bs_Cyrl_BA' locale func New() locales.Translator { return &bs_Cyrl_BA{ - locale: "bs_Cyrl_BA", + locale: "bs_Cyrl_BA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bs_Cyrl_BA) Locale() string { - return l.locale +func (t *bs_Cyrl_BA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bs_Cyrl_BA) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'bs_Cyrl_BA' +func (t *bs_Cyrl_BA) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl_BA' +func (t *bs_Cyrl_BA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bs_Latn/bs_Latn.go b/resources/locales/bs_Latn/bs_Latn.go index c8444dd..03ee47d 100644 --- a/resources/locales/bs_Latn/bs_Latn.go +++ b/resources/locales/bs_Latn/bs_Latn.go @@ -1,45 +1,58 @@ package bs_Latn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bs_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bs_Latn' locale func New() locales.Translator { return &bs_Latn{ - locale: "bs_Latn", + locale: "bs_Latn", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *bs_Latn) Locale() string { - return l.locale +func (t *bs_Latn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bs_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'bs_Latn' +func (t *bs_Latn) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn' +func (t *bs_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/bs_Latn_BA/bs_Latn_BA.go b/resources/locales/bs_Latn_BA/bs_Latn_BA.go index 76e455e..56728e1 100644 --- a/resources/locales/bs_Latn_BA/bs_Latn_BA.go +++ b/resources/locales/bs_Latn_BA/bs_Latn_BA.go @@ -1,45 +1,58 @@ package bs_Latn_BA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type bs_Latn_BA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'bs_Latn_BA' locale func New() locales.Translator { return &bs_Latn_BA{ - locale: "bs_Latn_BA", + locale: "bs_Latn_BA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *bs_Latn_BA) Locale() string { - return l.locale +func (t *bs_Latn_BA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *bs_Latn_BA) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'bs_Latn_BA' +func (t *bs_Latn_BA) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn_BA' +func (t *bs_Latn_BA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca/ca.go b/resources/locales/ca/ca.go index 16f7050..9ea5b25 100644 --- a/resources/locales/ca/ca.go +++ b/resources/locales/ca/ca.go @@ -1,38 +1,55 @@ package ca import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca' locale func New() locales.Translator { return &ca{ - locale: "ca", + locale: "ca", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ca) Locale() string { - return l.locale +func (t *ca) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca' +func (t *ca) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca' +func (t *ca) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca_AD/ca_AD.go b/resources/locales/ca_AD/ca_AD.go index 6b9bdd1..60ec909 100644 --- a/resources/locales/ca_AD/ca_AD.go +++ b/resources/locales/ca_AD/ca_AD.go @@ -1,38 +1,55 @@ package ca_AD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca_AD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca_AD' locale func New() locales.Translator { return &ca_AD{ - locale: "ca_AD", + locale: "ca_AD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ca_AD) Locale() string { - return l.locale +func (t *ca_AD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca_AD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca_AD' +func (t *ca_AD) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca_AD' +func (t *ca_AD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca_ES/ca_ES.go b/resources/locales/ca_ES/ca_ES.go index 8e0d486..28fda82 100644 --- a/resources/locales/ca_ES/ca_ES.go +++ b/resources/locales/ca_ES/ca_ES.go @@ -1,38 +1,55 @@ package ca_ES import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca_ES struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca_ES' locale func New() locales.Translator { return &ca_ES{ - locale: "ca_ES", + locale: "ca_ES", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ca_ES) Locale() string { - return l.locale +func (t *ca_ES) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca_ES) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca_ES' +func (t *ca_ES) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca_ES' +func (t *ca_ES) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go b/resources/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go index 6d4a37c..39822db 100644 --- a/resources/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go +++ b/resources/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go @@ -1,38 +1,55 @@ package ca_ES_VALENCIA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca_ES_VALENCIA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca_ES_VALENCIA' locale func New() locales.Translator { return &ca_ES_VALENCIA{ - locale: "ca_ES_VALENCIA", + locale: "ca_ES_VALENCIA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ca_ES_VALENCIA) Locale() string { - return l.locale +func (t *ca_ES_VALENCIA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca_ES_VALENCIA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca_ES_VALENCIA' +func (t *ca_ES_VALENCIA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca_ES_VALENCIA' +func (t *ca_ES_VALENCIA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca_FR/ca_FR.go b/resources/locales/ca_FR/ca_FR.go index 8a76b45..ad80d0c 100644 --- a/resources/locales/ca_FR/ca_FR.go +++ b/resources/locales/ca_FR/ca_FR.go @@ -1,38 +1,55 @@ package ca_FR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca_FR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca_FR' locale func New() locales.Translator { return &ca_FR{ - locale: "ca_FR", + locale: "ca_FR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ca_FR) Locale() string { - return l.locale +func (t *ca_FR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca_FR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca_FR' +func (t *ca_FR) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca_FR' +func (t *ca_FR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ca_IT/ca_IT.go b/resources/locales/ca_IT/ca_IT.go index 7f05f5b..47c8ee7 100644 --- a/resources/locales/ca_IT/ca_IT.go +++ b/resources/locales/ca_IT/ca_IT.go @@ -1,38 +1,55 @@ package ca_IT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ca_IT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ca_IT' locale func New() locales.Translator { return &ca_IT{ - locale: "ca_IT", + locale: "ca_IT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ca_IT) Locale() string { - return l.locale +func (t *ca_IT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ca_IT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ca_IT' +func (t *ca_IT) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ca_IT' +func (t *ca_IT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ce/ce.go b/resources/locales/ce/ce.go index 7ba6270..3dbba7a 100644 --- a/resources/locales/ce/ce.go +++ b/resources/locales/ce/ce.go @@ -1,36 +1,54 @@ package ce import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ce struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ce' locale func New() locales.Translator { return &ce{ - locale: "ce", + locale: "ce", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ce) Locale() string { - return l.locale +func (t *ce) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ce' +func (t *ce) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ce) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ce' +func (t *ce) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ce_RU/ce_RU.go b/resources/locales/ce_RU/ce_RU.go index 43c6fe2..8f268a9 100644 --- a/resources/locales/ce_RU/ce_RU.go +++ b/resources/locales/ce_RU/ce_RU.go @@ -1,36 +1,54 @@ package ce_RU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ce_RU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ce_RU' locale func New() locales.Translator { return &ce_RU{ - locale: "ce_RU", + locale: "ce_RU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ce_RU) Locale() string { - return l.locale +func (t *ce_RU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ce_RU' +func (t *ce_RU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ce_RU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ce_RU' +func (t *ce_RU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cgg/cgg.go b/resources/locales/cgg/cgg.go index 24b085d..62724d5 100644 --- a/resources/locales/cgg/cgg.go +++ b/resources/locales/cgg/cgg.go @@ -1,36 +1,54 @@ package cgg import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cgg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cgg' locale func New() locales.Translator { return &cgg{ - locale: "cgg", + locale: "cgg", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cgg) Locale() string { - return l.locale +func (t *cgg) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'cgg' +func (t *cgg) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cgg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cgg' +func (t *cgg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cgg_UG/cgg_UG.go b/resources/locales/cgg_UG/cgg_UG.go index 4fb7839..94b7803 100644 --- a/resources/locales/cgg_UG/cgg_UG.go +++ b/resources/locales/cgg_UG/cgg_UG.go @@ -1,36 +1,54 @@ package cgg_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cgg_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cgg_UG' locale func New() locales.Translator { return &cgg_UG{ - locale: "cgg_UG", + locale: "cgg_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cgg_UG) Locale() string { - return l.locale +func (t *cgg_UG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'cgg_UG' +func (t *cgg_UG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cgg_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cgg_UG' +func (t *cgg_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/chr/chr.go b/resources/locales/chr/chr.go index 48aa26c..f4d3083 100644 --- a/resources/locales/chr/chr.go +++ b/resources/locales/chr/chr.go @@ -1,36 +1,54 @@ package chr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type chr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'chr' locale func New() locales.Translator { return &chr{ - locale: "chr", + locale: "chr", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *chr) Locale() string { - return l.locale +func (t *chr) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'chr' +func (t *chr) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *chr) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'chr' +func (t *chr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/chr_US/chr_US.go b/resources/locales/chr_US/chr_US.go index 01fab60..20d7d82 100644 --- a/resources/locales/chr_US/chr_US.go +++ b/resources/locales/chr_US/chr_US.go @@ -1,36 +1,54 @@ package chr_US import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type chr_US struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'chr_US' locale func New() locales.Translator { return &chr_US{ - locale: "chr_US", + locale: "chr_US", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *chr_US) Locale() string { - return l.locale +func (t *chr_US) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'chr_US' +func (t *chr_US) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *chr_US) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'chr_US' +func (t *chr_US) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ckb/ckb.go b/resources/locales/ckb/ckb.go index 4565158..5975cee 100644 --- a/resources/locales/ckb/ckb.go +++ b/resources/locales/ckb/ckb.go @@ -1,36 +1,54 @@ package ckb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ckb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ckb' locale func New() locales.Translator { return &ckb{ - locale: "ckb", + locale: "ckb", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0xe2, 0x80, 0x8e, 0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ckb) Locale() string { - return l.locale +func (t *ckb) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ckb' +func (t *ckb) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ckb) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ckb' +func (t *ckb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ckb_IQ/ckb_IQ.go b/resources/locales/ckb_IQ/ckb_IQ.go index 63d05e5..e2538cb 100644 --- a/resources/locales/ckb_IQ/ckb_IQ.go +++ b/resources/locales/ckb_IQ/ckb_IQ.go @@ -1,36 +1,54 @@ package ckb_IQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ckb_IQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ckb_IQ' locale func New() locales.Translator { return &ckb_IQ{ - locale: "ckb_IQ", + locale: "ckb_IQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ckb_IQ) Locale() string { - return l.locale +func (t *ckb_IQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ckb_IQ' +func (t *ckb_IQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ckb_IQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ckb_IQ' +func (t *ckb_IQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ckb_IR/ckb_IR.go b/resources/locales/ckb_IR/ckb_IR.go index 990dca3..1ad33fc 100644 --- a/resources/locales/ckb_IR/ckb_IR.go +++ b/resources/locales/ckb_IR/ckb_IR.go @@ -1,36 +1,54 @@ package ckb_IR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ckb_IR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ckb_IR' locale func New() locales.Translator { return &ckb_IR{ - locale: "ckb_IR", + locale: "ckb_IR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ckb_IR) Locale() string { - return l.locale +func (t *ckb_IR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ckb_IR' +func (t *ckb_IR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ckb_IR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ckb_IR' +func (t *ckb_IR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cs/cs.go b/resources/locales/cs/cs.go index b923b92..0b49a2c 100644 --- a/resources/locales/cs/cs.go +++ b/resources/locales/cs/cs.go @@ -1,42 +1,59 @@ package cs import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cs struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cs' locale func New() locales.Translator { return &cs{ - locale: "cs", + locale: "cs", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cs) Locale() string { - return l.locale +func (t *cs) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cs) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'cs' +func (t *cs) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cs' +func (t *cs) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i >= 2 && i <= 4 && v == 0 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cs_CZ/cs_CZ.go b/resources/locales/cs_CZ/cs_CZ.go index 2e19e7c..a5744f8 100644 --- a/resources/locales/cs_CZ/cs_CZ.go +++ b/resources/locales/cs_CZ/cs_CZ.go @@ -1,42 +1,59 @@ package cs_CZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cs_CZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cs_CZ' locale func New() locales.Translator { return &cs_CZ{ - locale: "cs_CZ", + locale: "cs_CZ", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cs_CZ) Locale() string { - return l.locale +func (t *cs_CZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cs_CZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'cs_CZ' +func (t *cs_CZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cs_CZ' +func (t *cs_CZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i >= 2 && i <= 4 && v == 0 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cu/cu.go b/resources/locales/cu/cu.go index ae06998..0c23691 100644 --- a/resources/locales/cu/cu.go +++ b/resources/locales/cu/cu.go @@ -1,26 +1,43 @@ package cu -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type cu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cu' locale func New() locales.Translator { return &cu{ - locale: "cu", + locale: "cu", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cu) Locale() string { - return l.locale +func (t *cu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'cu' +func (t *cu) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cu' +func (t *cu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/cu_RU/cu_RU.go b/resources/locales/cu_RU/cu_RU.go index af99aa1..7820b14 100644 --- a/resources/locales/cu_RU/cu_RU.go +++ b/resources/locales/cu_RU/cu_RU.go @@ -1,26 +1,43 @@ package cu_RU -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type cu_RU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cu_RU' locale func New() locales.Translator { return &cu_RU{ - locale: "cu_RU", + locale: "cu_RU", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *cu_RU) Locale() string { - return l.locale +func (t *cu_RU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cu_RU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'cu_RU' +func (t *cu_RU) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cu_RU' +func (t *cu_RU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/cy/cy.go b/resources/locales/cy/cy.go index ffac3a2..9ea464f 100644 --- a/resources/locales/cy/cy.go +++ b/resources/locales/cy/cy.go @@ -1,44 +1,62 @@ package cy import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cy struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cy' locale func New() locales.Translator { return &cy{ - locale: "cy", + locale: "cy", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cy) Locale() string { - return l.locale +func (t *cy) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'cy' +func (t *cy) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cy) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cy' +func (t *cy) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n == 3 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n == 6 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/cy_GB/cy_GB.go b/resources/locales/cy_GB/cy_GB.go index b357387..ef6225c 100644 --- a/resources/locales/cy_GB/cy_GB.go +++ b/resources/locales/cy_GB/cy_GB.go @@ -1,44 +1,62 @@ package cy_GB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type cy_GB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'cy_GB' locale func New() locales.Translator { return &cy_GB{ - locale: "cy_GB", + locale: "cy_GB", + plurals: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *cy_GB) Locale() string { - return l.locale +func (t *cy_GB) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'cy_GB' +func (t *cy_GB) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *cy_GB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'cy_GB' +func (t *cy_GB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n == 3 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n == 6 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/da/da.go b/resources/locales/da/da.go index 907b778..78e3450 100644 --- a/resources/locales/da/da.go +++ b/resources/locales/da/da.go @@ -1,46 +1,56 @@ package da import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type da struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'da' locale func New() locales.Translator { return &da{ - locale: "da", + locale: "da", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *da) Locale() string { - return l.locale +func (t *da) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *da) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'da' +func (t *da) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'da' +func (t *da) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) if (n == 1) || (t != 0 && (i == 0 || i == 1)) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/da_DK/da_DK.go b/resources/locales/da_DK/da_DK.go index 3a8e838..fea9180 100644 --- a/resources/locales/da_DK/da_DK.go +++ b/resources/locales/da_DK/da_DK.go @@ -1,46 +1,56 @@ package da_DK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type da_DK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'da_DK' locale func New() locales.Translator { return &da_DK{ - locale: "da_DK", + locale: "da_DK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *da_DK) Locale() string { - return l.locale +func (t *da_DK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *da_DK) CardinalPluralRule(num string) (locales.PluralRule, error) { - - t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'da_DK' +func (t *da_DK) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'da_DK' +func (t *da_DK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) if (n == 1) || (t != 0 && (i == 0 || i == 1)) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/da_GL/da_GL.go b/resources/locales/da_GL/da_GL.go index 7c07341..ce20fd7 100644 --- a/resources/locales/da_GL/da_GL.go +++ b/resources/locales/da_GL/da_GL.go @@ -1,46 +1,56 @@ package da_GL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type da_GL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'da_GL' locale func New() locales.Translator { return &da_GL{ - locale: "da_GL", + locale: "da_GL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *da_GL) Locale() string { - return l.locale +func (t *da_GL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *da_GL) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'da_GL' +func (t *da_GL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'da_GL' +func (t *da_GL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) if (n == 1) || (t != 0 && (i == 0 || i == 1)) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/dav/dav.go b/resources/locales/dav/dav.go index b99e1b9..a84ee2e 100644 --- a/resources/locales/dav/dav.go +++ b/resources/locales/dav/dav.go @@ -1,26 +1,43 @@ package dav -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dav struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dav' locale func New() locales.Translator { return &dav{ - locale: "dav", + locale: "dav", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dav) Locale() string { - return l.locale +func (t *dav) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dav) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dav' +func (t *dav) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dav' +func (t *dav) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dav_KE/dav_KE.go b/resources/locales/dav_KE/dav_KE.go index 80b7454..bfb3a25 100644 --- a/resources/locales/dav_KE/dav_KE.go +++ b/resources/locales/dav_KE/dav_KE.go @@ -1,26 +1,43 @@ package dav_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dav_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dav_KE' locale func New() locales.Translator { return &dav_KE{ - locale: "dav_KE", + locale: "dav_KE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *dav_KE) Locale() string { - return l.locale +func (t *dav_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dav_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dav_KE' +func (t *dav_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dav_KE' +func (t *dav_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/de/de.go b/resources/locales/de/de.go index ea1ed67..0617af8 100644 --- a/resources/locales/de/de.go +++ b/resources/locales/de/de.go @@ -1,38 +1,55 @@ package de import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de' locale func New() locales.Translator { return &de{ - locale: "de", + locale: "de", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de) Locale() string { - return l.locale +func (t *de) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de' +func (t *de) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de' +func (t *de) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_AT/de_AT.go b/resources/locales/de_AT/de_AT.go index e1ee07f..6a2106e 100644 --- a/resources/locales/de_AT/de_AT.go +++ b/resources/locales/de_AT/de_AT.go @@ -1,38 +1,55 @@ package de_AT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_AT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_AT' locale func New() locales.Translator { return &de_AT{ - locale: "de_AT", + locale: "de_AT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_AT) Locale() string { - return l.locale +func (t *de_AT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_AT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_AT' +func (t *de_AT) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_AT' +func (t *de_AT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_BE/de_BE.go b/resources/locales/de_BE/de_BE.go index 09b2315..d098072 100644 --- a/resources/locales/de_BE/de_BE.go +++ b/resources/locales/de_BE/de_BE.go @@ -1,38 +1,55 @@ package de_BE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_BE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_BE' locale func New() locales.Translator { return &de_BE{ - locale: "de_BE", + locale: "de_BE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_BE) Locale() string { - return l.locale +func (t *de_BE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_BE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_BE' +func (t *de_BE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_BE' +func (t *de_BE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_CH/de_CH.go b/resources/locales/de_CH/de_CH.go index a7692fa..355586a 100644 --- a/resources/locales/de_CH/de_CH.go +++ b/resources/locales/de_CH/de_CH.go @@ -1,38 +1,55 @@ package de_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_CH' locale func New() locales.Translator { return &de_CH{ - locale: "de_CH", + locale: "de_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x27}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_CH) Locale() string { - return l.locale +func (t *de_CH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_CH' +func (t *de_CH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_CH' +func (t *de_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_DE/de_DE.go b/resources/locales/de_DE/de_DE.go index 99a427b..6da6938 100644 --- a/resources/locales/de_DE/de_DE.go +++ b/resources/locales/de_DE/de_DE.go @@ -1,38 +1,55 @@ package de_DE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_DE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_DE' locale func New() locales.Translator { return &de_DE{ - locale: "de_DE", + locale: "de_DE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_DE) Locale() string { - return l.locale +func (t *de_DE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_DE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_DE' +func (t *de_DE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_DE' +func (t *de_DE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_LI/de_LI.go b/resources/locales/de_LI/de_LI.go index aed1ed5..07b53df 100644 --- a/resources/locales/de_LI/de_LI.go +++ b/resources/locales/de_LI/de_LI.go @@ -1,38 +1,55 @@ package de_LI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_LI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_LI' locale func New() locales.Translator { return &de_LI{ - locale: "de_LI", + locale: "de_LI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x27}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_LI) Locale() string { - return l.locale +func (t *de_LI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_LI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_LI' +func (t *de_LI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_LI' +func (t *de_LI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/de_LU/de_LU.go b/resources/locales/de_LU/de_LU.go index e799559..824b4c4 100644 --- a/resources/locales/de_LU/de_LU.go +++ b/resources/locales/de_LU/de_LU.go @@ -1,38 +1,55 @@ package de_LU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type de_LU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'de_LU' locale func New() locales.Translator { return &de_LU{ - locale: "de_LU", + locale: "de_LU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *de_LU) Locale() string { - return l.locale +func (t *de_LU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *de_LU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'de_LU' +func (t *de_LU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'de_LU' +func (t *de_LU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/dje/dje.go b/resources/locales/dje/dje.go index d8d6279..ed4ac64 100644 --- a/resources/locales/dje/dje.go +++ b/resources/locales/dje/dje.go @@ -1,26 +1,43 @@ package dje -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dje struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dje' locale func New() locales.Translator { return &dje{ - locale: "dje", + locale: "dje", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dje) Locale() string { - return l.locale +func (t *dje) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dje) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dje' +func (t *dje) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dje' +func (t *dje) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dje_NE/dje_NE.go b/resources/locales/dje_NE/dje_NE.go index 8c22e8f..e3c6b05 100644 --- a/resources/locales/dje_NE/dje_NE.go +++ b/resources/locales/dje_NE/dje_NE.go @@ -1,26 +1,43 @@ package dje_NE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dje_NE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dje_NE' locale func New() locales.Translator { return &dje_NE{ - locale: "dje_NE", + locale: "dje_NE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *dje_NE) Locale() string { - return l.locale +func (t *dje_NE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dje_NE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dje_NE' +func (t *dje_NE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dje_NE' +func (t *dje_NE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dsb/dsb.go b/resources/locales/dsb/dsb.go index 6f31f24..280a0f3 100644 --- a/resources/locales/dsb/dsb.go +++ b/resources/locales/dsb/dsb.go @@ -1,47 +1,60 @@ package dsb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type dsb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dsb' locale func New() locales.Translator { return &dsb{ - locale: "dsb", + locale: "dsb", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dsb) Locale() string { - return l.locale +func (t *dsb) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dsb) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'dsb' +func (t *dsb) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dsb' +func (t *dsb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%100 == 1) || (f%100 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%100 == 2) || (f%100 == 2) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (f%100 >= 3 && f%100 <= 4) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/dsb_DE/dsb_DE.go b/resources/locales/dsb_DE/dsb_DE.go index f5f0d16..d9cac9e 100644 --- a/resources/locales/dsb_DE/dsb_DE.go +++ b/resources/locales/dsb_DE/dsb_DE.go @@ -1,47 +1,60 @@ package dsb_DE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type dsb_DE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dsb_DE' locale func New() locales.Translator { return &dsb_DE{ - locale: "dsb_DE", + locale: "dsb_DE", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dsb_DE) Locale() string { - return l.locale +func (t *dsb_DE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dsb_DE) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'dsb_DE' +func (t *dsb_DE) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dsb_DE' +func (t *dsb_DE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%100 == 1) || (f%100 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%100 == 2) || (f%100 == 2) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (f%100 >= 3 && f%100 <= 4) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/dua/dua.go b/resources/locales/dua/dua.go index c076788..99d4973 100644 --- a/resources/locales/dua/dua.go +++ b/resources/locales/dua/dua.go @@ -1,26 +1,43 @@ package dua -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dua struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dua' locale func New() locales.Translator { return &dua{ - locale: "dua", + locale: "dua", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dua) Locale() string { - return l.locale +func (t *dua) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dua) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dua' +func (t *dua) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dua' +func (t *dua) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dua_CM/dua_CM.go b/resources/locales/dua_CM/dua_CM.go index 14a9a21..dd223d2 100644 --- a/resources/locales/dua_CM/dua_CM.go +++ b/resources/locales/dua_CM/dua_CM.go @@ -1,26 +1,43 @@ package dua_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dua_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dua_CM' locale func New() locales.Translator { return &dua_CM{ - locale: "dua_CM", + locale: "dua_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dua_CM) Locale() string { - return l.locale +func (t *dua_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dua_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dua_CM' +func (t *dua_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dua_CM' +func (t *dua_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dyo/dyo.go b/resources/locales/dyo/dyo.go index c3d4fe3..384fdc6 100644 --- a/resources/locales/dyo/dyo.go +++ b/resources/locales/dyo/dyo.go @@ -1,26 +1,43 @@ package dyo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dyo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dyo' locale func New() locales.Translator { return &dyo{ - locale: "dyo", + locale: "dyo", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dyo) Locale() string { - return l.locale +func (t *dyo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dyo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dyo' +func (t *dyo) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dyo' +func (t *dyo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dyo_SN/dyo_SN.go b/resources/locales/dyo_SN/dyo_SN.go index 52e85b8..82afddd 100644 --- a/resources/locales/dyo_SN/dyo_SN.go +++ b/resources/locales/dyo_SN/dyo_SN.go @@ -1,26 +1,43 @@ package dyo_SN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dyo_SN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dyo_SN' locale func New() locales.Translator { return &dyo_SN{ - locale: "dyo_SN", + locale: "dyo_SN", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dyo_SN) Locale() string { - return l.locale +func (t *dyo_SN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dyo_SN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dyo_SN' +func (t *dyo_SN) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dyo_SN' +func (t *dyo_SN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/dz/dz.go b/resources/locales/dz/dz.go index e6f64f2..b244fa6 100644 --- a/resources/locales/dz/dz.go +++ b/resources/locales/dz/dz.go @@ -1,27 +1,43 @@ package dz -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dz struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dz' locale func New() locales.Translator { return &dz{ - locale: "dz", + locale: "dz", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *dz) Locale() string { - return l.locale +func (t *dz) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dz) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dz' +func (t *dz) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dz' +func (t *dz) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/dz_BT/dz_BT.go b/resources/locales/dz_BT/dz_BT.go index e55a53f..28a8b34 100644 --- a/resources/locales/dz_BT/dz_BT.go +++ b/resources/locales/dz_BT/dz_BT.go @@ -1,27 +1,43 @@ package dz_BT -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type dz_BT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'dz_BT' locale func New() locales.Translator { return &dz_BT{ - locale: "dz_BT", + locale: "dz_BT", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *dz_BT) Locale() string { - return l.locale +func (t *dz_BT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *dz_BT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'dz_BT' +func (t *dz_BT) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'dz_BT' +func (t *dz_BT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ebu/ebu.go b/resources/locales/ebu/ebu.go index ff479fd..911a620 100644 --- a/resources/locales/ebu/ebu.go +++ b/resources/locales/ebu/ebu.go @@ -1,26 +1,43 @@ package ebu -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ebu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ebu' locale func New() locales.Translator { return &ebu{ - locale: "ebu", + locale: "ebu", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ebu) Locale() string { - return l.locale +func (t *ebu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ebu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ebu' +func (t *ebu) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ebu' +func (t *ebu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ebu_KE/ebu_KE.go b/resources/locales/ebu_KE/ebu_KE.go index a85b52a..1f45d46 100644 --- a/resources/locales/ebu_KE/ebu_KE.go +++ b/resources/locales/ebu_KE/ebu_KE.go @@ -1,26 +1,43 @@ package ebu_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ebu_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ebu_KE' locale func New() locales.Translator { return &ebu_KE{ - locale: "ebu_KE", + locale: "ebu_KE", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ebu_KE) Locale() string { - return l.locale +func (t *ebu_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ebu_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ebu_KE' +func (t *ebu_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ebu_KE' +func (t *ebu_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ee/ee.go b/resources/locales/ee/ee.go index 9542e3a..ac1b60e 100644 --- a/resources/locales/ee/ee.go +++ b/resources/locales/ee/ee.go @@ -1,36 +1,54 @@ package ee import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ee struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ee' locale func New() locales.Translator { return &ee{ - locale: "ee", + locale: "ee", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ee) Locale() string { - return l.locale +func (t *ee) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ee' +func (t *ee) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ee) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ee' +func (t *ee) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ee_GH/ee_GH.go b/resources/locales/ee_GH/ee_GH.go index 229d298..d018d54 100644 --- a/resources/locales/ee_GH/ee_GH.go +++ b/resources/locales/ee_GH/ee_GH.go @@ -1,36 +1,54 @@ package ee_GH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ee_GH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ee_GH' locale func New() locales.Translator { return &ee_GH{ - locale: "ee_GH", + locale: "ee_GH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ee_GH) Locale() string { - return l.locale +func (t *ee_GH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ee_GH' +func (t *ee_GH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ee_GH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ee_GH' +func (t *ee_GH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ee_TG/ee_TG.go b/resources/locales/ee_TG/ee_TG.go index a65c6ce..8afacb9 100644 --- a/resources/locales/ee_TG/ee_TG.go +++ b/resources/locales/ee_TG/ee_TG.go @@ -1,36 +1,54 @@ package ee_TG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ee_TG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ee_TG' locale func New() locales.Translator { return &ee_TG{ - locale: "ee_TG", + locale: "ee_TG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ee_TG) Locale() string { - return l.locale +func (t *ee_TG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ee_TG' +func (t *ee_TG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ee_TG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ee_TG' +func (t *ee_TG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/el/el.go b/resources/locales/el/el.go index 262a2bf..3e8203e 100644 --- a/resources/locales/el/el.go +++ b/resources/locales/el/el.go @@ -1,36 +1,54 @@ package el import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type el struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'el' locale func New() locales.Translator { return &el{ - locale: "el", + locale: "el", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *el) Locale() string { - return l.locale +func (t *el) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'el' +func (t *el) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *el) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'el' +func (t *el) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/el_CY/el_CY.go b/resources/locales/el_CY/el_CY.go index f3b576a..4c1ba6e 100644 --- a/resources/locales/el_CY/el_CY.go +++ b/resources/locales/el_CY/el_CY.go @@ -1,36 +1,54 @@ package el_CY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type el_CY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'el_CY' locale func New() locales.Translator { return &el_CY{ - locale: "el_CY", + locale: "el_CY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *el_CY) Locale() string { - return l.locale +func (t *el_CY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'el_CY' +func (t *el_CY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *el_CY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'el_CY' +func (t *el_CY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/el_GR/el_GR.go b/resources/locales/el_GR/el_GR.go index 011d5fd..650f737 100644 --- a/resources/locales/el_GR/el_GR.go +++ b/resources/locales/el_GR/el_GR.go @@ -1,36 +1,54 @@ package el_GR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type el_GR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'el_GR' locale func New() locales.Translator { return &el_GR{ - locale: "el_GR", + locale: "el_GR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *el_GR) Locale() string { - return l.locale +func (t *el_GR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'el_GR' +func (t *el_GR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *el_GR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'el_GR' +func (t *el_GR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en/en.go b/resources/locales/en/en.go index 9c2ce85..20d7a74 100644 --- a/resources/locales/en/en.go +++ b/resources/locales/en/en.go @@ -1,38 +1,55 @@ package en import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en' locale func New() locales.Translator { return &en{ - locale: "en", + locale: "en", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en) Locale() string { - return l.locale +func (t *en) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en' +func (t *en) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en' +func (t *en) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_001/en_001.go b/resources/locales/en_001/en_001.go index 2b1a8be..bd4b997 100644 --- a/resources/locales/en_001/en_001.go +++ b/resources/locales/en_001/en_001.go @@ -1,38 +1,55 @@ package en_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_001' locale func New() locales.Translator { return &en_001{ - locale: "en_001", + locale: "en_001", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_001) Locale() string { - return l.locale +func (t *en_001) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_001) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_001' +func (t *en_001) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_001' +func (t *en_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_150/en_150.go b/resources/locales/en_150/en_150.go index 575e37a..5b00120 100644 --- a/resources/locales/en_150/en_150.go +++ b/resources/locales/en_150/en_150.go @@ -1,38 +1,55 @@ package en_150 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_150 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_150' locale func New() locales.Translator { return &en_150{ - locale: "en_150", + locale: "en_150", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_150) Locale() string { - return l.locale +func (t *en_150) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_150) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_150' +func (t *en_150) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_150' +func (t *en_150) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_AG/en_AG.go b/resources/locales/en_AG/en_AG.go index 404f6a6..8fda796 100644 --- a/resources/locales/en_AG/en_AG.go +++ b/resources/locales/en_AG/en_AG.go @@ -1,38 +1,55 @@ package en_AG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_AG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_AG' locale func New() locales.Translator { return &en_AG{ - locale: "en_AG", + locale: "en_AG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_AG) Locale() string { - return l.locale +func (t *en_AG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_AG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_AG' +func (t *en_AG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_AG' +func (t *en_AG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_AI/en_AI.go b/resources/locales/en_AI/en_AI.go index 5d93973..ea5a496 100644 --- a/resources/locales/en_AI/en_AI.go +++ b/resources/locales/en_AI/en_AI.go @@ -1,38 +1,55 @@ package en_AI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_AI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_AI' locale func New() locales.Translator { return &en_AI{ - locale: "en_AI", + locale: "en_AI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_AI) Locale() string { - return l.locale +func (t *en_AI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_AI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_AI' +func (t *en_AI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_AI' +func (t *en_AI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_AS/en_AS.go b/resources/locales/en_AS/en_AS.go index 4b954bd..ff19085 100644 --- a/resources/locales/en_AS/en_AS.go +++ b/resources/locales/en_AS/en_AS.go @@ -1,38 +1,55 @@ package en_AS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_AS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_AS' locale func New() locales.Translator { return &en_AS{ - locale: "en_AS", + locale: "en_AS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_AS) Locale() string { - return l.locale +func (t *en_AS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_AS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_AS' +func (t *en_AS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_AS' +func (t *en_AS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_AT/en_AT.go b/resources/locales/en_AT/en_AT.go index 7eaf7bb..d1a35f8 100644 --- a/resources/locales/en_AT/en_AT.go +++ b/resources/locales/en_AT/en_AT.go @@ -1,38 +1,55 @@ package en_AT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_AT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_AT' locale func New() locales.Translator { return &en_AT{ - locale: "en_AT", + locale: "en_AT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_AT) Locale() string { - return l.locale +func (t *en_AT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_AT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_AT' +func (t *en_AT) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_AT' +func (t *en_AT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_AU/en_AU.go b/resources/locales/en_AU/en_AU.go index 1de54cb..a411038 100644 --- a/resources/locales/en_AU/en_AU.go +++ b/resources/locales/en_AU/en_AU.go @@ -1,38 +1,55 @@ package en_AU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_AU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_AU' locale func New() locales.Translator { return &en_AU{ - locale: "en_AU", + locale: "en_AU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_AU) Locale() string { - return l.locale +func (t *en_AU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_AU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_AU' +func (t *en_AU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_AU' +func (t *en_AU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BB/en_BB.go b/resources/locales/en_BB/en_BB.go index 9179265..ccf6075 100644 --- a/resources/locales/en_BB/en_BB.go +++ b/resources/locales/en_BB/en_BB.go @@ -1,38 +1,55 @@ package en_BB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BB' locale func New() locales.Translator { return &en_BB{ - locale: "en_BB", + locale: "en_BB", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BB) Locale() string { - return l.locale +func (t *en_BB) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BB' +func (t *en_BB) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BB' +func (t *en_BB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BE/en_BE.go b/resources/locales/en_BE/en_BE.go index 9b691c5..4a5d461 100644 --- a/resources/locales/en_BE/en_BE.go +++ b/resources/locales/en_BE/en_BE.go @@ -1,38 +1,55 @@ package en_BE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BE' locale func New() locales.Translator { return &en_BE{ - locale: "en_BE", + locale: "en_BE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BE) Locale() string { - return l.locale +func (t *en_BE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BE' +func (t *en_BE) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BE' +func (t *en_BE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BI/en_BI.go b/resources/locales/en_BI/en_BI.go index 9e9fd1e..18c7d15 100644 --- a/resources/locales/en_BI/en_BI.go +++ b/resources/locales/en_BI/en_BI.go @@ -1,38 +1,55 @@ package en_BI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BI' locale func New() locales.Translator { return &en_BI{ - locale: "en_BI", + locale: "en_BI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BI) Locale() string { - return l.locale +func (t *en_BI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BI' +func (t *en_BI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BI' +func (t *en_BI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BM/en_BM.go b/resources/locales/en_BM/en_BM.go index 4405e56..be3c900 100644 --- a/resources/locales/en_BM/en_BM.go +++ b/resources/locales/en_BM/en_BM.go @@ -1,38 +1,55 @@ package en_BM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BM' locale func New() locales.Translator { return &en_BM{ - locale: "en_BM", + locale: "en_BM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_BM) Locale() string { - return l.locale +func (t *en_BM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BM' +func (t *en_BM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BM' +func (t *en_BM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BS/en_BS.go b/resources/locales/en_BS/en_BS.go index 623484e..9d4975f 100644 --- a/resources/locales/en_BS/en_BS.go +++ b/resources/locales/en_BS/en_BS.go @@ -1,38 +1,55 @@ package en_BS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BS' locale func New() locales.Translator { return &en_BS{ - locale: "en_BS", + locale: "en_BS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BS) Locale() string { - return l.locale +func (t *en_BS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BS' +func (t *en_BS) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BS' +func (t *en_BS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BW/en_BW.go b/resources/locales/en_BW/en_BW.go index 9ab6280..aca947d 100644 --- a/resources/locales/en_BW/en_BW.go +++ b/resources/locales/en_BW/en_BW.go @@ -1,38 +1,55 @@ package en_BW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BW' locale func New() locales.Translator { return &en_BW{ - locale: "en_BW", + locale: "en_BW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BW) Locale() string { - return l.locale +func (t *en_BW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BW' +func (t *en_BW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BW' +func (t *en_BW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_BZ/en_BZ.go b/resources/locales/en_BZ/en_BZ.go index 99fee21..4f4e6bb 100644 --- a/resources/locales/en_BZ/en_BZ.go +++ b/resources/locales/en_BZ/en_BZ.go @@ -1,38 +1,55 @@ package en_BZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_BZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_BZ' locale func New() locales.Translator { return &en_BZ{ - locale: "en_BZ", + locale: "en_BZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_BZ) Locale() string { - return l.locale +func (t *en_BZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_BZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_BZ' +func (t *en_BZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_BZ' +func (t *en_BZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CA/en_CA.go b/resources/locales/en_CA/en_CA.go index c619504..519b27e 100644 --- a/resources/locales/en_CA/en_CA.go +++ b/resources/locales/en_CA/en_CA.go @@ -1,38 +1,55 @@ package en_CA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CA' locale func New() locales.Translator { return &en_CA{ - locale: "en_CA", + locale: "en_CA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CA) Locale() string { - return l.locale +func (t *en_CA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CA' +func (t *en_CA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CA' +func (t *en_CA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CC/en_CC.go b/resources/locales/en_CC/en_CC.go index 71158a5..e0cc64e 100644 --- a/resources/locales/en_CC/en_CC.go +++ b/resources/locales/en_CC/en_CC.go @@ -1,38 +1,55 @@ package en_CC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CC' locale func New() locales.Translator { return &en_CC{ - locale: "en_CC", + locale: "en_CC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CC) Locale() string { - return l.locale +func (t *en_CC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CC' +func (t *en_CC) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CC' +func (t *en_CC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CH/en_CH.go b/resources/locales/en_CH/en_CH.go index 73bf763..138a572 100644 --- a/resources/locales/en_CH/en_CH.go +++ b/resources/locales/en_CH/en_CH.go @@ -1,38 +1,55 @@ package en_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CH' locale func New() locales.Translator { return &en_CH{ - locale: "en_CH", + locale: "en_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CH) Locale() string { - return l.locale +func (t *en_CH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CH' +func (t *en_CH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CH' +func (t *en_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CK/en_CK.go b/resources/locales/en_CK/en_CK.go index 1ca2869..e5fb394 100644 --- a/resources/locales/en_CK/en_CK.go +++ b/resources/locales/en_CK/en_CK.go @@ -1,38 +1,55 @@ package en_CK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CK' locale func New() locales.Translator { return &en_CK{ - locale: "en_CK", + locale: "en_CK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CK) Locale() string { - return l.locale +func (t *en_CK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CK' +func (t *en_CK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CK' +func (t *en_CK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CM/en_CM.go b/resources/locales/en_CM/en_CM.go index 0d8dc30..9ca727e 100644 --- a/resources/locales/en_CM/en_CM.go +++ b/resources/locales/en_CM/en_CM.go @@ -1,38 +1,55 @@ package en_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CM' locale func New() locales.Translator { return &en_CM{ - locale: "en_CM", + locale: "en_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CM) Locale() string { - return l.locale +func (t *en_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CM' +func (t *en_CM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CM' +func (t *en_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CX/en_CX.go b/resources/locales/en_CX/en_CX.go index 96fbaab..8340148 100644 --- a/resources/locales/en_CX/en_CX.go +++ b/resources/locales/en_CX/en_CX.go @@ -1,38 +1,55 @@ package en_CX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CX' locale func New() locales.Translator { return &en_CX{ - locale: "en_CX", + locale: "en_CX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CX) Locale() string { - return l.locale +func (t *en_CX) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CX' +func (t *en_CX) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CX' +func (t *en_CX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_CY/en_CY.go b/resources/locales/en_CY/en_CY.go index c3cf132..a65e6f0 100644 --- a/resources/locales/en_CY/en_CY.go +++ b/resources/locales/en_CY/en_CY.go @@ -1,38 +1,55 @@ package en_CY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_CY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_CY' locale func New() locales.Translator { return &en_CY{ - locale: "en_CY", + locale: "en_CY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_CY) Locale() string { - return l.locale +func (t *en_CY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_CY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_CY' +func (t *en_CY) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_CY' +func (t *en_CY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_DE/en_DE.go b/resources/locales/en_DE/en_DE.go index 1781926..8b821c7 100644 --- a/resources/locales/en_DE/en_DE.go +++ b/resources/locales/en_DE/en_DE.go @@ -1,38 +1,55 @@ package en_DE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_DE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_DE' locale func New() locales.Translator { return &en_DE{ - locale: "en_DE", + locale: "en_DE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_DE) Locale() string { - return l.locale +func (t *en_DE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_DE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_DE' +func (t *en_DE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_DE' +func (t *en_DE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_DG/en_DG.go b/resources/locales/en_DG/en_DG.go index 76ad178..53ef753 100644 --- a/resources/locales/en_DG/en_DG.go +++ b/resources/locales/en_DG/en_DG.go @@ -1,38 +1,55 @@ package en_DG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_DG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_DG' locale func New() locales.Translator { return &en_DG{ - locale: "en_DG", + locale: "en_DG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_DG) Locale() string { - return l.locale +func (t *en_DG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_DG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_DG' +func (t *en_DG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_DG' +func (t *en_DG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_DK/en_DK.go b/resources/locales/en_DK/en_DK.go index 41d37c8..72504d0 100644 --- a/resources/locales/en_DK/en_DK.go +++ b/resources/locales/en_DK/en_DK.go @@ -1,38 +1,55 @@ package en_DK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_DK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_DK' locale func New() locales.Translator { return &en_DK{ - locale: "en_DK", + locale: "en_DK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_DK) Locale() string { - return l.locale +func (t *en_DK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_DK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_DK' +func (t *en_DK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_DK' +func (t *en_DK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_DM/en_DM.go b/resources/locales/en_DM/en_DM.go index fed59ed..c577801 100644 --- a/resources/locales/en_DM/en_DM.go +++ b/resources/locales/en_DM/en_DM.go @@ -1,38 +1,55 @@ package en_DM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_DM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_DM' locale func New() locales.Translator { return &en_DM{ - locale: "en_DM", + locale: "en_DM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_DM) Locale() string { - return l.locale +func (t *en_DM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_DM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_DM' +func (t *en_DM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_DM' +func (t *en_DM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_ER/en_ER.go b/resources/locales/en_ER/en_ER.go index 94ce6f4..3f510d1 100644 --- a/resources/locales/en_ER/en_ER.go +++ b/resources/locales/en_ER/en_ER.go @@ -1,38 +1,55 @@ package en_ER import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_ER struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_ER' locale func New() locales.Translator { return &en_ER{ - locale: "en_ER", + locale: "en_ER", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_ER) Locale() string { - return l.locale +func (t *en_ER) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_ER) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_ER' +func (t *en_ER) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_ER' +func (t *en_ER) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_FI/en_FI.go b/resources/locales/en_FI/en_FI.go index 5d0bb24..5a75b87 100644 --- a/resources/locales/en_FI/en_FI.go +++ b/resources/locales/en_FI/en_FI.go @@ -1,38 +1,55 @@ package en_FI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_FI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_FI' locale func New() locales.Translator { return &en_FI{ - locale: "en_FI", + locale: "en_FI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_FI) Locale() string { - return l.locale +func (t *en_FI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_FI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_FI' +func (t *en_FI) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_FI' +func (t *en_FI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_FJ/en_FJ.go b/resources/locales/en_FJ/en_FJ.go index fab8f81..480c3a9 100644 --- a/resources/locales/en_FJ/en_FJ.go +++ b/resources/locales/en_FJ/en_FJ.go @@ -1,38 +1,55 @@ package en_FJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_FJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_FJ' locale func New() locales.Translator { return &en_FJ{ - locale: "en_FJ", + locale: "en_FJ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_FJ) Locale() string { - return l.locale +func (t *en_FJ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_FJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_FJ' +func (t *en_FJ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_FJ' +func (t *en_FJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_FK/en_FK.go b/resources/locales/en_FK/en_FK.go index e1ccea1..4e35cb0 100644 --- a/resources/locales/en_FK/en_FK.go +++ b/resources/locales/en_FK/en_FK.go @@ -1,38 +1,55 @@ package en_FK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_FK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_FK' locale func New() locales.Translator { return &en_FK{ - locale: "en_FK", + locale: "en_FK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_FK) Locale() string { - return l.locale +func (t *en_FK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_FK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_FK' +func (t *en_FK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_FK' +func (t *en_FK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_FM/en_FM.go b/resources/locales/en_FM/en_FM.go index 62ab5d9..a3b0d37 100644 --- a/resources/locales/en_FM/en_FM.go +++ b/resources/locales/en_FM/en_FM.go @@ -1,38 +1,55 @@ package en_FM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_FM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_FM' locale func New() locales.Translator { return &en_FM{ - locale: "en_FM", + locale: "en_FM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_FM) Locale() string { - return l.locale +func (t *en_FM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_FM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_FM' +func (t *en_FM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_FM' +func (t *en_FM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GB/en_GB.go b/resources/locales/en_GB/en_GB.go index 239003d..364b42f 100644 --- a/resources/locales/en_GB/en_GB.go +++ b/resources/locales/en_GB/en_GB.go @@ -1,38 +1,55 @@ package en_GB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GB' locale func New() locales.Translator { return &en_GB{ - locale: "en_GB", + locale: "en_GB", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GB) Locale() string { - return l.locale +func (t *en_GB) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GB' +func (t *en_GB) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GB' +func (t *en_GB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GD/en_GD.go b/resources/locales/en_GD/en_GD.go index 4756102..fcd9867 100644 --- a/resources/locales/en_GD/en_GD.go +++ b/resources/locales/en_GD/en_GD.go @@ -1,38 +1,55 @@ package en_GD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GD' locale func New() locales.Translator { return &en_GD{ - locale: "en_GD", + locale: "en_GD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GD) Locale() string { - return l.locale +func (t *en_GD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GD' +func (t *en_GD) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GD' +func (t *en_GD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GG/en_GG.go b/resources/locales/en_GG/en_GG.go index f50a342..79dd5bf 100644 --- a/resources/locales/en_GG/en_GG.go +++ b/resources/locales/en_GG/en_GG.go @@ -1,38 +1,55 @@ package en_GG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GG' locale func New() locales.Translator { return &en_GG{ - locale: "en_GG", + locale: "en_GG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GG) Locale() string { - return l.locale +func (t *en_GG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GG' +func (t *en_GG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GG' +func (t *en_GG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GH/en_GH.go b/resources/locales/en_GH/en_GH.go index 630e4c6..07f6920 100644 --- a/resources/locales/en_GH/en_GH.go +++ b/resources/locales/en_GH/en_GH.go @@ -1,38 +1,55 @@ package en_GH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GH' locale func New() locales.Translator { return &en_GH{ - locale: "en_GH", + locale: "en_GH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_GH) Locale() string { - return l.locale +func (t *en_GH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GH' +func (t *en_GH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GH' +func (t *en_GH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GI/en_GI.go b/resources/locales/en_GI/en_GI.go index 6b947d2..231b55b 100644 --- a/resources/locales/en_GI/en_GI.go +++ b/resources/locales/en_GI/en_GI.go @@ -1,38 +1,55 @@ package en_GI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GI' locale func New() locales.Translator { return &en_GI{ - locale: "en_GI", + locale: "en_GI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GI) Locale() string { - return l.locale +func (t *en_GI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GI' +func (t *en_GI) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GI' +func (t *en_GI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GM/en_GM.go b/resources/locales/en_GM/en_GM.go index bfb4d47..86fb053 100644 --- a/resources/locales/en_GM/en_GM.go +++ b/resources/locales/en_GM/en_GM.go @@ -1,38 +1,55 @@ package en_GM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GM' locale func New() locales.Translator { return &en_GM{ - locale: "en_GM", + locale: "en_GM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GM) Locale() string { - return l.locale +func (t *en_GM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GM' +func (t *en_GM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GM' +func (t *en_GM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GU/en_GU.go b/resources/locales/en_GU/en_GU.go index 2acb8b1..79d2f73 100644 --- a/resources/locales/en_GU/en_GU.go +++ b/resources/locales/en_GU/en_GU.go @@ -1,38 +1,55 @@ package en_GU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GU' locale func New() locales.Translator { return &en_GU{ - locale: "en_GU", + locale: "en_GU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_GU) Locale() string { - return l.locale +func (t *en_GU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GU' +func (t *en_GU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GU' +func (t *en_GU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_GY/en_GY.go b/resources/locales/en_GY/en_GY.go index b96d2c0..a28f4a2 100644 --- a/resources/locales/en_GY/en_GY.go +++ b/resources/locales/en_GY/en_GY.go @@ -1,38 +1,55 @@ package en_GY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_GY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_GY' locale func New() locales.Translator { return &en_GY{ - locale: "en_GY", + locale: "en_GY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_GY) Locale() string { - return l.locale +func (t *en_GY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_GY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_GY' +func (t *en_GY) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_GY' +func (t *en_GY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_HK/en_HK.go b/resources/locales/en_HK/en_HK.go index 1015359..634567c 100644 --- a/resources/locales/en_HK/en_HK.go +++ b/resources/locales/en_HK/en_HK.go @@ -1,38 +1,55 @@ package en_HK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_HK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_HK' locale func New() locales.Translator { return &en_HK{ - locale: "en_HK", + locale: "en_HK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_HK) Locale() string { - return l.locale +func (t *en_HK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_HK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_HK' +func (t *en_HK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_HK' +func (t *en_HK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_IE/en_IE.go b/resources/locales/en_IE/en_IE.go index d5d4f3a..fd0b9d8 100644 --- a/resources/locales/en_IE/en_IE.go +++ b/resources/locales/en_IE/en_IE.go @@ -1,38 +1,55 @@ package en_IE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_IE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_IE' locale func New() locales.Translator { return &en_IE{ - locale: "en_IE", + locale: "en_IE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_IE) Locale() string { - return l.locale +func (t *en_IE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_IE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_IE' +func (t *en_IE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_IE' +func (t *en_IE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_IL/en_IL.go b/resources/locales/en_IL/en_IL.go index 687b09a..62a5f79 100644 --- a/resources/locales/en_IL/en_IL.go +++ b/resources/locales/en_IL/en_IL.go @@ -1,38 +1,55 @@ package en_IL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_IL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_IL' locale func New() locales.Translator { return &en_IL{ - locale: "en_IL", + locale: "en_IL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_IL) Locale() string { - return l.locale +func (t *en_IL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_IL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_IL' +func (t *en_IL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_IL' +func (t *en_IL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_IM/en_IM.go b/resources/locales/en_IM/en_IM.go index 42ef41c..0f65388 100644 --- a/resources/locales/en_IM/en_IM.go +++ b/resources/locales/en_IM/en_IM.go @@ -1,38 +1,55 @@ package en_IM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_IM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_IM' locale func New() locales.Translator { return &en_IM{ - locale: "en_IM", + locale: "en_IM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_IM) Locale() string { - return l.locale +func (t *en_IM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_IM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_IM' +func (t *en_IM) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_IM' +func (t *en_IM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_IN/en_IN.go b/resources/locales/en_IN/en_IN.go index 2f21d16..5d07ac4 100644 --- a/resources/locales/en_IN/en_IN.go +++ b/resources/locales/en_IN/en_IN.go @@ -1,38 +1,55 @@ package en_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_IN' locale func New() locales.Translator { return &en_IN{ - locale: "en_IN", + locale: "en_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_IN) Locale() string { - return l.locale +func (t *en_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_IN' +func (t *en_IN) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_IN' +func (t *en_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_IO/en_IO.go b/resources/locales/en_IO/en_IO.go index 46a6036..ff2a20d 100644 --- a/resources/locales/en_IO/en_IO.go +++ b/resources/locales/en_IO/en_IO.go @@ -1,38 +1,55 @@ package en_IO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_IO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_IO' locale func New() locales.Translator { return &en_IO{ - locale: "en_IO", + locale: "en_IO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_IO) Locale() string { - return l.locale +func (t *en_IO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_IO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_IO' +func (t *en_IO) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_IO' +func (t *en_IO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_JE/en_JE.go b/resources/locales/en_JE/en_JE.go index b2510de..4a337e5 100644 --- a/resources/locales/en_JE/en_JE.go +++ b/resources/locales/en_JE/en_JE.go @@ -1,38 +1,55 @@ package en_JE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_JE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_JE' locale func New() locales.Translator { return &en_JE{ - locale: "en_JE", + locale: "en_JE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_JE) Locale() string { - return l.locale +func (t *en_JE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_JE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_JE' +func (t *en_JE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_JE' +func (t *en_JE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_JM/en_JM.go b/resources/locales/en_JM/en_JM.go index 9403527..4831e00 100644 --- a/resources/locales/en_JM/en_JM.go +++ b/resources/locales/en_JM/en_JM.go @@ -1,38 +1,55 @@ package en_JM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_JM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_JM' locale func New() locales.Translator { return &en_JM{ - locale: "en_JM", + locale: "en_JM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_JM) Locale() string { - return l.locale +func (t *en_JM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_JM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_JM' +func (t *en_JM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_JM' +func (t *en_JM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_KE/en_KE.go b/resources/locales/en_KE/en_KE.go index a85bf75..7b37244 100644 --- a/resources/locales/en_KE/en_KE.go +++ b/resources/locales/en_KE/en_KE.go @@ -1,38 +1,55 @@ package en_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_KE' locale func New() locales.Translator { return &en_KE{ - locale: "en_KE", + locale: "en_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_KE) Locale() string { - return l.locale +func (t *en_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_KE' +func (t *en_KE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_KE' +func (t *en_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_KI/en_KI.go b/resources/locales/en_KI/en_KI.go index ab8c01f..0367c0a 100644 --- a/resources/locales/en_KI/en_KI.go +++ b/resources/locales/en_KI/en_KI.go @@ -1,38 +1,55 @@ package en_KI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_KI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_KI' locale func New() locales.Translator { return &en_KI{ - locale: "en_KI", + locale: "en_KI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_KI) Locale() string { - return l.locale +func (t *en_KI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_KI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_KI' +func (t *en_KI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_KI' +func (t *en_KI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_KN/en_KN.go b/resources/locales/en_KN/en_KN.go index 796f4ed..7a5e203 100644 --- a/resources/locales/en_KN/en_KN.go +++ b/resources/locales/en_KN/en_KN.go @@ -1,38 +1,55 @@ package en_KN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_KN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_KN' locale func New() locales.Translator { return &en_KN{ - locale: "en_KN", + locale: "en_KN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_KN) Locale() string { - return l.locale +func (t *en_KN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_KN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_KN' +func (t *en_KN) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_KN' +func (t *en_KN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_KY/en_KY.go b/resources/locales/en_KY/en_KY.go index f4c490d..ebfe316 100644 --- a/resources/locales/en_KY/en_KY.go +++ b/resources/locales/en_KY/en_KY.go @@ -1,38 +1,55 @@ package en_KY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_KY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_KY' locale func New() locales.Translator { return &en_KY{ - locale: "en_KY", + locale: "en_KY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_KY) Locale() string { - return l.locale +func (t *en_KY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_KY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_KY' +func (t *en_KY) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_KY' +func (t *en_KY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_LC/en_LC.go b/resources/locales/en_LC/en_LC.go index e375c79..a85f699 100644 --- a/resources/locales/en_LC/en_LC.go +++ b/resources/locales/en_LC/en_LC.go @@ -1,38 +1,55 @@ package en_LC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_LC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_LC' locale func New() locales.Translator { return &en_LC{ - locale: "en_LC", + locale: "en_LC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_LC) Locale() string { - return l.locale +func (t *en_LC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_LC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_LC' +func (t *en_LC) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_LC' +func (t *en_LC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_LR/en_LR.go b/resources/locales/en_LR/en_LR.go index b7287d8..f9ab78a 100644 --- a/resources/locales/en_LR/en_LR.go +++ b/resources/locales/en_LR/en_LR.go @@ -1,38 +1,55 @@ package en_LR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_LR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_LR' locale func New() locales.Translator { return &en_LR{ - locale: "en_LR", + locale: "en_LR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_LR) Locale() string { - return l.locale +func (t *en_LR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_LR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_LR' +func (t *en_LR) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_LR' +func (t *en_LR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_LS/en_LS.go b/resources/locales/en_LS/en_LS.go index 48a0dc5..1fc47fe 100644 --- a/resources/locales/en_LS/en_LS.go +++ b/resources/locales/en_LS/en_LS.go @@ -1,38 +1,55 @@ package en_LS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_LS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_LS' locale func New() locales.Translator { return &en_LS{ - locale: "en_LS", + locale: "en_LS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_LS) Locale() string { - return l.locale +func (t *en_LS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_LS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_LS' +func (t *en_LS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_LS' +func (t *en_LS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MG/en_MG.go b/resources/locales/en_MG/en_MG.go index aaba545..360c3a3 100644 --- a/resources/locales/en_MG/en_MG.go +++ b/resources/locales/en_MG/en_MG.go @@ -1,38 +1,55 @@ package en_MG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MG' locale func New() locales.Translator { return &en_MG{ - locale: "en_MG", + locale: "en_MG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MG) Locale() string { - return l.locale +func (t *en_MG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MG' +func (t *en_MG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MG' +func (t *en_MG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MH/en_MH.go b/resources/locales/en_MH/en_MH.go index 7ce96a2..8fc7fe4 100644 --- a/resources/locales/en_MH/en_MH.go +++ b/resources/locales/en_MH/en_MH.go @@ -1,38 +1,55 @@ package en_MH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MH' locale func New() locales.Translator { return &en_MH{ - locale: "en_MH", + locale: "en_MH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MH) Locale() string { - return l.locale +func (t *en_MH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MH' +func (t *en_MH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MH' +func (t *en_MH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MO/en_MO.go b/resources/locales/en_MO/en_MO.go index 2d176aa..9532d3e 100644 --- a/resources/locales/en_MO/en_MO.go +++ b/resources/locales/en_MO/en_MO.go @@ -1,38 +1,55 @@ package en_MO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MO' locale func New() locales.Translator { return &en_MO{ - locale: "en_MO", + locale: "en_MO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MO) Locale() string { - return l.locale +func (t *en_MO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MO' +func (t *en_MO) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MO' +func (t *en_MO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MP/en_MP.go b/resources/locales/en_MP/en_MP.go index a8b7cfc..b6262a1 100644 --- a/resources/locales/en_MP/en_MP.go +++ b/resources/locales/en_MP/en_MP.go @@ -1,38 +1,55 @@ package en_MP import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MP struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MP' locale func New() locales.Translator { return &en_MP{ - locale: "en_MP", + locale: "en_MP", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MP) Locale() string { - return l.locale +func (t *en_MP) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MP) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MP' +func (t *en_MP) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MP' +func (t *en_MP) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MS/en_MS.go b/resources/locales/en_MS/en_MS.go index cee715f..86edbcc 100644 --- a/resources/locales/en_MS/en_MS.go +++ b/resources/locales/en_MS/en_MS.go @@ -1,38 +1,55 @@ package en_MS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MS' locale func New() locales.Translator { return &en_MS{ - locale: "en_MS", + locale: "en_MS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MS) Locale() string { - return l.locale +func (t *en_MS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MS' +func (t *en_MS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MS' +func (t *en_MS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MT/en_MT.go b/resources/locales/en_MT/en_MT.go index 0009a57..954661e 100644 --- a/resources/locales/en_MT/en_MT.go +++ b/resources/locales/en_MT/en_MT.go @@ -1,38 +1,55 @@ package en_MT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MT' locale func New() locales.Translator { return &en_MT{ - locale: "en_MT", + locale: "en_MT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MT) Locale() string { - return l.locale +func (t *en_MT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MT' +func (t *en_MT) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MT' +func (t *en_MT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MU/en_MU.go b/resources/locales/en_MU/en_MU.go index 79c958c..be8eae1 100644 --- a/resources/locales/en_MU/en_MU.go +++ b/resources/locales/en_MU/en_MU.go @@ -1,38 +1,55 @@ package en_MU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MU' locale func New() locales.Translator { return &en_MU{ - locale: "en_MU", + locale: "en_MU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MU) Locale() string { - return l.locale +func (t *en_MU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MU' +func (t *en_MU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MU' +func (t *en_MU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MW/en_MW.go b/resources/locales/en_MW/en_MW.go index 30e2146..d65f95c 100644 --- a/resources/locales/en_MW/en_MW.go +++ b/resources/locales/en_MW/en_MW.go @@ -1,38 +1,55 @@ package en_MW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MW' locale func New() locales.Translator { return &en_MW{ - locale: "en_MW", + locale: "en_MW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MW) Locale() string { - return l.locale +func (t *en_MW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MW' +func (t *en_MW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MW' +func (t *en_MW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_MY/en_MY.go b/resources/locales/en_MY/en_MY.go index 3a3578b..6790317 100644 --- a/resources/locales/en_MY/en_MY.go +++ b/resources/locales/en_MY/en_MY.go @@ -1,38 +1,55 @@ package en_MY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_MY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_MY' locale func New() locales.Translator { return &en_MY{ - locale: "en_MY", + locale: "en_MY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_MY) Locale() string { - return l.locale +func (t *en_MY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_MY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_MY' +func (t *en_MY) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_MY' +func (t *en_MY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NA/en_NA.go b/resources/locales/en_NA/en_NA.go index 52bf532..d581548 100644 --- a/resources/locales/en_NA/en_NA.go +++ b/resources/locales/en_NA/en_NA.go @@ -1,38 +1,55 @@ package en_NA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NA' locale func New() locales.Translator { return &en_NA{ - locale: "en_NA", + locale: "en_NA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NA) Locale() string { - return l.locale +func (t *en_NA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NA' +func (t *en_NA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NA' +func (t *en_NA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NF/en_NF.go b/resources/locales/en_NF/en_NF.go index 01163ec..c15dd5a 100644 --- a/resources/locales/en_NF/en_NF.go +++ b/resources/locales/en_NF/en_NF.go @@ -1,38 +1,55 @@ package en_NF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NF' locale func New() locales.Translator { return &en_NF{ - locale: "en_NF", + locale: "en_NF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NF) Locale() string { - return l.locale +func (t *en_NF) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NF' +func (t *en_NF) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NF' +func (t *en_NF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NG/en_NG.go b/resources/locales/en_NG/en_NG.go index 6355b69..5c24561 100644 --- a/resources/locales/en_NG/en_NG.go +++ b/resources/locales/en_NG/en_NG.go @@ -1,38 +1,55 @@ package en_NG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NG' locale func New() locales.Translator { return &en_NG{ - locale: "en_NG", + locale: "en_NG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NG) Locale() string { - return l.locale +func (t *en_NG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NG' +func (t *en_NG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NG' +func (t *en_NG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NL/en_NL.go b/resources/locales/en_NL/en_NL.go index 9822e72..cead218 100644 --- a/resources/locales/en_NL/en_NL.go +++ b/resources/locales/en_NL/en_NL.go @@ -1,38 +1,55 @@ package en_NL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NL' locale func New() locales.Translator { return &en_NL{ - locale: "en_NL", + locale: "en_NL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_NL) Locale() string { - return l.locale +func (t *en_NL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NL' +func (t *en_NL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NL' +func (t *en_NL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NR/en_NR.go b/resources/locales/en_NR/en_NR.go index d899497..caa5ef9 100644 --- a/resources/locales/en_NR/en_NR.go +++ b/resources/locales/en_NR/en_NR.go @@ -1,38 +1,55 @@ package en_NR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NR' locale func New() locales.Translator { return &en_NR{ - locale: "en_NR", + locale: "en_NR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NR) Locale() string { - return l.locale +func (t *en_NR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NR' +func (t *en_NR) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NR' +func (t *en_NR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NU/en_NU.go b/resources/locales/en_NU/en_NU.go index a82fe21..6002c09 100644 --- a/resources/locales/en_NU/en_NU.go +++ b/resources/locales/en_NU/en_NU.go @@ -1,38 +1,55 @@ package en_NU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NU' locale func New() locales.Translator { return &en_NU{ - locale: "en_NU", + locale: "en_NU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NU) Locale() string { - return l.locale +func (t *en_NU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NU' +func (t *en_NU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NU' +func (t *en_NU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_NZ/en_NZ.go b/resources/locales/en_NZ/en_NZ.go index 743ecab..083ff4d 100644 --- a/resources/locales/en_NZ/en_NZ.go +++ b/resources/locales/en_NZ/en_NZ.go @@ -1,38 +1,55 @@ package en_NZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_NZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_NZ' locale func New() locales.Translator { return &en_NZ{ - locale: "en_NZ", + locale: "en_NZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_NZ) Locale() string { - return l.locale +func (t *en_NZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_NZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_NZ' +func (t *en_NZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_NZ' +func (t *en_NZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PG/en_PG.go b/resources/locales/en_PG/en_PG.go index d82ecb1..e78a9bd 100644 --- a/resources/locales/en_PG/en_PG.go +++ b/resources/locales/en_PG/en_PG.go @@ -1,38 +1,55 @@ package en_PG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PG' locale func New() locales.Translator { return &en_PG{ - locale: "en_PG", + locale: "en_PG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PG) Locale() string { - return l.locale +func (t *en_PG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PG' +func (t *en_PG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PG' +func (t *en_PG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PH/en_PH.go b/resources/locales/en_PH/en_PH.go index 20d87df..d1d97f9 100644 --- a/resources/locales/en_PH/en_PH.go +++ b/resources/locales/en_PH/en_PH.go @@ -1,38 +1,55 @@ package en_PH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PH' locale func New() locales.Translator { return &en_PH{ - locale: "en_PH", + locale: "en_PH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PH) Locale() string { - return l.locale +func (t *en_PH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PH' +func (t *en_PH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PH' +func (t *en_PH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PK/en_PK.go b/resources/locales/en_PK/en_PK.go index aac7422..f0d360f 100644 --- a/resources/locales/en_PK/en_PK.go +++ b/resources/locales/en_PK/en_PK.go @@ -1,38 +1,55 @@ package en_PK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PK' locale func New() locales.Translator { return &en_PK{ - locale: "en_PK", + locale: "en_PK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PK) Locale() string { - return l.locale +func (t *en_PK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PK' +func (t *en_PK) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PK' +func (t *en_PK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PN/en_PN.go b/resources/locales/en_PN/en_PN.go index a51e903..8d906ad 100644 --- a/resources/locales/en_PN/en_PN.go +++ b/resources/locales/en_PN/en_PN.go @@ -1,38 +1,55 @@ package en_PN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PN' locale func New() locales.Translator { return &en_PN{ - locale: "en_PN", + locale: "en_PN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PN) Locale() string { - return l.locale +func (t *en_PN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PN' +func (t *en_PN) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PN' +func (t *en_PN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PR/en_PR.go b/resources/locales/en_PR/en_PR.go index 498f9ce..dc8861f 100644 --- a/resources/locales/en_PR/en_PR.go +++ b/resources/locales/en_PR/en_PR.go @@ -1,38 +1,55 @@ package en_PR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PR' locale func New() locales.Translator { return &en_PR{ - locale: "en_PR", + locale: "en_PR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PR) Locale() string { - return l.locale +func (t *en_PR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PR' +func (t *en_PR) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PR' +func (t *en_PR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_PW/en_PW.go b/resources/locales/en_PW/en_PW.go index 7097ae7..ce53889 100644 --- a/resources/locales/en_PW/en_PW.go +++ b/resources/locales/en_PW/en_PW.go @@ -1,38 +1,55 @@ package en_PW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_PW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_PW' locale func New() locales.Translator { return &en_PW{ - locale: "en_PW", + locale: "en_PW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_PW) Locale() string { - return l.locale +func (t *en_PW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_PW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_PW' +func (t *en_PW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_PW' +func (t *en_PW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_RW/en_RW.go b/resources/locales/en_RW/en_RW.go index 12e75e7..6285180 100644 --- a/resources/locales/en_RW/en_RW.go +++ b/resources/locales/en_RW/en_RW.go @@ -1,38 +1,55 @@ package en_RW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_RW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_RW' locale func New() locales.Translator { return &en_RW{ - locale: "en_RW", + locale: "en_RW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_RW) Locale() string { - return l.locale +func (t *en_RW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_RW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_RW' +func (t *en_RW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_RW' +func (t *en_RW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SB/en_SB.go b/resources/locales/en_SB/en_SB.go index e80328d..5357dce 100644 --- a/resources/locales/en_SB/en_SB.go +++ b/resources/locales/en_SB/en_SB.go @@ -1,38 +1,55 @@ package en_SB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SB' locale func New() locales.Translator { return &en_SB{ - locale: "en_SB", + locale: "en_SB", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SB) Locale() string { - return l.locale +func (t *en_SB) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SB' +func (t *en_SB) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SB' +func (t *en_SB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SC/en_SC.go b/resources/locales/en_SC/en_SC.go index 12bb4c9..49a0108 100644 --- a/resources/locales/en_SC/en_SC.go +++ b/resources/locales/en_SC/en_SC.go @@ -1,38 +1,55 @@ package en_SC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SC' locale func New() locales.Translator { return &en_SC{ - locale: "en_SC", + locale: "en_SC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SC) Locale() string { - return l.locale +func (t *en_SC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SC' +func (t *en_SC) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SC' +func (t *en_SC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SD/en_SD.go b/resources/locales/en_SD/en_SD.go index fa724be..20cbc43 100644 --- a/resources/locales/en_SD/en_SD.go +++ b/resources/locales/en_SD/en_SD.go @@ -1,38 +1,55 @@ package en_SD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SD' locale func New() locales.Translator { return &en_SD{ - locale: "en_SD", + locale: "en_SD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SD) Locale() string { - return l.locale +func (t *en_SD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SD' +func (t *en_SD) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SD' +func (t *en_SD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SE/en_SE.go b/resources/locales/en_SE/en_SE.go index be21925..45b3223 100644 --- a/resources/locales/en_SE/en_SE.go +++ b/resources/locales/en_SE/en_SE.go @@ -1,38 +1,55 @@ package en_SE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SE' locale func New() locales.Translator { return &en_SE{ - locale: "en_SE", + locale: "en_SE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SE) Locale() string { - return l.locale +func (t *en_SE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SE' +func (t *en_SE) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SE' +func (t *en_SE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SG/en_SG.go b/resources/locales/en_SG/en_SG.go index d7f1689..a0357eb 100644 --- a/resources/locales/en_SG/en_SG.go +++ b/resources/locales/en_SG/en_SG.go @@ -1,38 +1,55 @@ package en_SG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SG' locale func New() locales.Translator { return &en_SG{ - locale: "en_SG", + locale: "en_SG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SG) Locale() string { - return l.locale +func (t *en_SG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SG' +func (t *en_SG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SG' +func (t *en_SG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SH/en_SH.go b/resources/locales/en_SH/en_SH.go index d88d39e..45ad4dc 100644 --- a/resources/locales/en_SH/en_SH.go +++ b/resources/locales/en_SH/en_SH.go @@ -1,38 +1,55 @@ package en_SH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SH' locale func New() locales.Translator { return &en_SH{ - locale: "en_SH", + locale: "en_SH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SH) Locale() string { - return l.locale +func (t *en_SH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SH' +func (t *en_SH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SH' +func (t *en_SH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SI/en_SI.go b/resources/locales/en_SI/en_SI.go index aa04a2a..7ae50d0 100644 --- a/resources/locales/en_SI/en_SI.go +++ b/resources/locales/en_SI/en_SI.go @@ -1,38 +1,55 @@ package en_SI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SI' locale func New() locales.Translator { return &en_SI{ - locale: "en_SI", + locale: "en_SI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SI) Locale() string { - return l.locale +func (t *en_SI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SI' +func (t *en_SI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SI' +func (t *en_SI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SL/en_SL.go b/resources/locales/en_SL/en_SL.go index 90efb85..cf6dc82 100644 --- a/resources/locales/en_SL/en_SL.go +++ b/resources/locales/en_SL/en_SL.go @@ -1,38 +1,55 @@ package en_SL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SL' locale func New() locales.Translator { return &en_SL{ - locale: "en_SL", + locale: "en_SL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SL) Locale() string { - return l.locale +func (t *en_SL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SL' +func (t *en_SL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SL' +func (t *en_SL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SS/en_SS.go b/resources/locales/en_SS/en_SS.go index 0ef05a4..4b0c1c5 100644 --- a/resources/locales/en_SS/en_SS.go +++ b/resources/locales/en_SS/en_SS.go @@ -1,38 +1,55 @@ package en_SS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SS' locale func New() locales.Translator { return &en_SS{ - locale: "en_SS", + locale: "en_SS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SS) Locale() string { - return l.locale +func (t *en_SS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SS' +func (t *en_SS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SS' +func (t *en_SS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SX/en_SX.go b/resources/locales/en_SX/en_SX.go index f9e413a..7d0f45c 100644 --- a/resources/locales/en_SX/en_SX.go +++ b/resources/locales/en_SX/en_SX.go @@ -1,38 +1,55 @@ package en_SX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SX' locale func New() locales.Translator { return &en_SX{ - locale: "en_SX", + locale: "en_SX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SX) Locale() string { - return l.locale +func (t *en_SX) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SX' +func (t *en_SX) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SX' +func (t *en_SX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_SZ/en_SZ.go b/resources/locales/en_SZ/en_SZ.go index fef4bf6..ab00dea 100644 --- a/resources/locales/en_SZ/en_SZ.go +++ b/resources/locales/en_SZ/en_SZ.go @@ -1,38 +1,55 @@ package en_SZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_SZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_SZ' locale func New() locales.Translator { return &en_SZ{ - locale: "en_SZ", + locale: "en_SZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_SZ) Locale() string { - return l.locale +func (t *en_SZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_SZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_SZ' +func (t *en_SZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_SZ' +func (t *en_SZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TC/en_TC.go b/resources/locales/en_TC/en_TC.go index 49a47b6..3ce9504 100644 --- a/resources/locales/en_TC/en_TC.go +++ b/resources/locales/en_TC/en_TC.go @@ -1,38 +1,55 @@ package en_TC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TC' locale func New() locales.Translator { return &en_TC{ - locale: "en_TC", + locale: "en_TC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_TC) Locale() string { - return l.locale +func (t *en_TC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TC' +func (t *en_TC) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TC' +func (t *en_TC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TK/en_TK.go b/resources/locales/en_TK/en_TK.go index 48564e8..3641713 100644 --- a/resources/locales/en_TK/en_TK.go +++ b/resources/locales/en_TK/en_TK.go @@ -1,38 +1,55 @@ package en_TK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TK' locale func New() locales.Translator { return &en_TK{ - locale: "en_TK", + locale: "en_TK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_TK) Locale() string { - return l.locale +func (t *en_TK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TK' +func (t *en_TK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TK' +func (t *en_TK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TO/en_TO.go b/resources/locales/en_TO/en_TO.go index 94aa6d6..9cc14ac 100644 --- a/resources/locales/en_TO/en_TO.go +++ b/resources/locales/en_TO/en_TO.go @@ -1,38 +1,55 @@ package en_TO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TO' locale func New() locales.Translator { return &en_TO{ - locale: "en_TO", + locale: "en_TO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_TO) Locale() string { - return l.locale +func (t *en_TO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TO' +func (t *en_TO) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TO' +func (t *en_TO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TT/en_TT.go b/resources/locales/en_TT/en_TT.go index 8a1f076..7f2f8c0 100644 --- a/resources/locales/en_TT/en_TT.go +++ b/resources/locales/en_TT/en_TT.go @@ -1,38 +1,55 @@ package en_TT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TT' locale func New() locales.Translator { return &en_TT{ - locale: "en_TT", + locale: "en_TT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_TT) Locale() string { - return l.locale +func (t *en_TT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TT' +func (t *en_TT) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TT' +func (t *en_TT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TV/en_TV.go b/resources/locales/en_TV/en_TV.go index b966376..9d41c2d 100644 --- a/resources/locales/en_TV/en_TV.go +++ b/resources/locales/en_TV/en_TV.go @@ -1,38 +1,55 @@ package en_TV import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TV struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TV' locale func New() locales.Translator { return &en_TV{ - locale: "en_TV", + locale: "en_TV", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_TV) Locale() string { - return l.locale +func (t *en_TV) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TV) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TV' +func (t *en_TV) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TV' +func (t *en_TV) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_TZ/en_TZ.go b/resources/locales/en_TZ/en_TZ.go index 54ee129..1dcd070 100644 --- a/resources/locales/en_TZ/en_TZ.go +++ b/resources/locales/en_TZ/en_TZ.go @@ -1,38 +1,55 @@ package en_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_TZ' locale func New() locales.Translator { return &en_TZ{ - locale: "en_TZ", + locale: "en_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_TZ) Locale() string { - return l.locale +func (t *en_TZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_TZ' +func (t *en_TZ) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_TZ' +func (t *en_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_UG/en_UG.go b/resources/locales/en_UG/en_UG.go index b5e10d3..1ed8653 100644 --- a/resources/locales/en_UG/en_UG.go +++ b/resources/locales/en_UG/en_UG.go @@ -1,38 +1,55 @@ package en_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_UG' locale func New() locales.Translator { return &en_UG{ - locale: "en_UG", + locale: "en_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_UG) Locale() string { - return l.locale +func (t *en_UG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_UG' +func (t *en_UG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_UG' +func (t *en_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_UM/en_UM.go b/resources/locales/en_UM/en_UM.go index 5194441..b4ffe73 100644 --- a/resources/locales/en_UM/en_UM.go +++ b/resources/locales/en_UM/en_UM.go @@ -1,38 +1,55 @@ package en_UM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_UM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_UM' locale func New() locales.Translator { return &en_UM{ - locale: "en_UM", + locale: "en_UM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_UM) Locale() string { - return l.locale +func (t *en_UM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_UM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_UM' +func (t *en_UM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_UM' +func (t *en_UM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_US/en_US.go b/resources/locales/en_US/en_US.go index fea463f..5848258 100644 --- a/resources/locales/en_US/en_US.go +++ b/resources/locales/en_US/en_US.go @@ -1,38 +1,55 @@ package en_US import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_US struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_US' locale func New() locales.Translator { return &en_US{ - locale: "en_US", + locale: "en_US", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_US) Locale() string { - return l.locale +func (t *en_US) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_US) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_US' +func (t *en_US) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_US' +func (t *en_US) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_US_POSIX/en_US_POSIX.go b/resources/locales/en_US_POSIX/en_US_POSIX.go index 083a85f..0aeab0b 100644 --- a/resources/locales/en_US_POSIX/en_US_POSIX.go +++ b/resources/locales/en_US_POSIX/en_US_POSIX.go @@ -1,38 +1,55 @@ package en_US_POSIX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_US_POSIX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_US_POSIX' locale func New() locales.Translator { return &en_US_POSIX{ - locale: "en_US_POSIX", + locale: "en_US_POSIX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x30, 0x2f, 0x30, 0x30}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *en_US_POSIX) Locale() string { - return l.locale +func (t *en_US_POSIX) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_US_POSIX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_US_POSIX' +func (t *en_US_POSIX) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_US_POSIX' +func (t *en_US_POSIX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_VC/en_VC.go b/resources/locales/en_VC/en_VC.go index 8b8a0d8..eff67e9 100644 --- a/resources/locales/en_VC/en_VC.go +++ b/resources/locales/en_VC/en_VC.go @@ -1,38 +1,55 @@ package en_VC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_VC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_VC' locale func New() locales.Translator { return &en_VC{ - locale: "en_VC", + locale: "en_VC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_VC) Locale() string { - return l.locale +func (t *en_VC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_VC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_VC' +func (t *en_VC) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_VC' +func (t *en_VC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_VG/en_VG.go b/resources/locales/en_VG/en_VG.go index 20e6008..f812c16 100644 --- a/resources/locales/en_VG/en_VG.go +++ b/resources/locales/en_VG/en_VG.go @@ -1,38 +1,55 @@ package en_VG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_VG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_VG' locale func New() locales.Translator { return &en_VG{ - locale: "en_VG", + locale: "en_VG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_VG) Locale() string { - return l.locale +func (t *en_VG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_VG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_VG' +func (t *en_VG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_VG' +func (t *en_VG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_VI/en_VI.go b/resources/locales/en_VI/en_VI.go index 11d0a99..121c237 100644 --- a/resources/locales/en_VI/en_VI.go +++ b/resources/locales/en_VI/en_VI.go @@ -1,38 +1,55 @@ package en_VI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_VI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_VI' locale func New() locales.Translator { return &en_VI{ - locale: "en_VI", + locale: "en_VI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_VI) Locale() string { - return l.locale +func (t *en_VI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_VI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_VI' +func (t *en_VI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_VI' +func (t *en_VI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_VU/en_VU.go b/resources/locales/en_VU/en_VU.go index 3303c3e..689951d 100644 --- a/resources/locales/en_VU/en_VU.go +++ b/resources/locales/en_VU/en_VU.go @@ -1,38 +1,55 @@ package en_VU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_VU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_VU' locale func New() locales.Translator { return &en_VU{ - locale: "en_VU", + locale: "en_VU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_VU) Locale() string { - return l.locale +func (t *en_VU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_VU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_VU' +func (t *en_VU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_VU' +func (t *en_VU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_WS/en_WS.go b/resources/locales/en_WS/en_WS.go index 8403be8..3cf4ff5 100644 --- a/resources/locales/en_WS/en_WS.go +++ b/resources/locales/en_WS/en_WS.go @@ -1,38 +1,55 @@ package en_WS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_WS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_WS' locale func New() locales.Translator { return &en_WS{ - locale: "en_WS", + locale: "en_WS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_WS) Locale() string { - return l.locale +func (t *en_WS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_WS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_WS' +func (t *en_WS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_WS' +func (t *en_WS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_ZA/en_ZA.go b/resources/locales/en_ZA/en_ZA.go index 48a4223..eac64c5 100644 --- a/resources/locales/en_ZA/en_ZA.go +++ b/resources/locales/en_ZA/en_ZA.go @@ -1,38 +1,55 @@ package en_ZA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_ZA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_ZA' locale func New() locales.Translator { return &en_ZA{ - locale: "en_ZA", + locale: "en_ZA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_ZA) Locale() string { - return l.locale +func (t *en_ZA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_ZA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_ZA' +func (t *en_ZA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_ZA' +func (t *en_ZA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_ZM/en_ZM.go b/resources/locales/en_ZM/en_ZM.go index fb3837a..48bd251 100644 --- a/resources/locales/en_ZM/en_ZM.go +++ b/resources/locales/en_ZM/en_ZM.go @@ -1,38 +1,55 @@ package en_ZM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_ZM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_ZM' locale func New() locales.Translator { return &en_ZM{ - locale: "en_ZM", + locale: "en_ZM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_ZM) Locale() string { - return l.locale +func (t *en_ZM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_ZM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_ZM' +func (t *en_ZM) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_ZM' +func (t *en_ZM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/en_ZW/en_ZW.go b/resources/locales/en_ZW/en_ZW.go index 583f07f..ae45174 100644 --- a/resources/locales/en_ZW/en_ZW.go +++ b/resources/locales/en_ZW/en_ZW.go @@ -1,38 +1,55 @@ package en_ZW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type en_ZW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'en_ZW' locale func New() locales.Translator { return &en_ZW{ - locale: "en_ZW", + locale: "en_ZW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *en_ZW) Locale() string { - return l.locale +func (t *en_ZW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *en_ZW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'en_ZW' +func (t *en_ZW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'en_ZW' +func (t *en_ZW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/eo/eo.go b/resources/locales/eo/eo.go index 828f275..c44b7b4 100644 --- a/resources/locales/eo/eo.go +++ b/resources/locales/eo/eo.go @@ -1,36 +1,54 @@ package eo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type eo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'eo' locale func New() locales.Translator { return &eo{ - locale: "eo", + locale: "eo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *eo) Locale() string { - return l.locale +func (t *eo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'eo' +func (t *eo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *eo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'eo' +func (t *eo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/eo_001/eo_001.go b/resources/locales/eo_001/eo_001.go index 4783a72..e4123f5 100644 --- a/resources/locales/eo_001/eo_001.go +++ b/resources/locales/eo_001/eo_001.go @@ -1,36 +1,54 @@ package eo_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type eo_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'eo_001' locale func New() locales.Translator { return &eo_001{ - locale: "eo_001", + locale: "eo_001", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *eo_001) Locale() string { - return l.locale +func (t *eo_001) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'eo_001' +func (t *eo_001) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *eo_001) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'eo_001' +func (t *eo_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es/es.go b/resources/locales/es/es.go index 8ab78d2..25abe1d 100644 --- a/resources/locales/es/es.go +++ b/resources/locales/es/es.go @@ -1,36 +1,54 @@ package es import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es' locale func New() locales.Translator { return &es{ - locale: "es", + locale: "es", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es) Locale() string { - return l.locale +func (t *es) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es' +func (t *es) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es' +func (t *es) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_419/es_419.go b/resources/locales/es_419/es_419.go index 4950703..e099f7d 100644 --- a/resources/locales/es_419/es_419.go +++ b/resources/locales/es_419/es_419.go @@ -1,36 +1,54 @@ package es_419 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_419 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_419' locale func New() locales.Translator { return &es_419{ - locale: "es_419", + locale: "es_419", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_419) Locale() string { - return l.locale +func (t *es_419) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_419' +func (t *es_419) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_419) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_419' +func (t *es_419) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_AR/es_AR.go b/resources/locales/es_AR/es_AR.go index 5f1fa7b..c4a9be5 100644 --- a/resources/locales/es_AR/es_AR.go +++ b/resources/locales/es_AR/es_AR.go @@ -1,36 +1,54 @@ package es_AR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_AR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_AR' locale func New() locales.Translator { return &es_AR{ - locale: "es_AR", + locale: "es_AR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_AR) Locale() string { - return l.locale +func (t *es_AR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_AR' +func (t *es_AR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_AR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_AR' +func (t *es_AR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_BO/es_BO.go b/resources/locales/es_BO/es_BO.go index dd50aaa..933e456 100644 --- a/resources/locales/es_BO/es_BO.go +++ b/resources/locales/es_BO/es_BO.go @@ -1,36 +1,54 @@ package es_BO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_BO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_BO' locale func New() locales.Translator { return &es_BO{ - locale: "es_BO", + locale: "es_BO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_BO) Locale() string { - return l.locale +func (t *es_BO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_BO' +func (t *es_BO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_BO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_BO' +func (t *es_BO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_BR/es_BR.go b/resources/locales/es_BR/es_BR.go index a515773..b04acca 100644 --- a/resources/locales/es_BR/es_BR.go +++ b/resources/locales/es_BR/es_BR.go @@ -1,36 +1,54 @@ package es_BR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_BR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_BR' locale func New() locales.Translator { return &es_BR{ - locale: "es_BR", + locale: "es_BR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_BR) Locale() string { - return l.locale +func (t *es_BR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_BR' +func (t *es_BR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_BR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_BR' +func (t *es_BR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_CL/es_CL.go b/resources/locales/es_CL/es_CL.go index eac85ed..36a2696 100644 --- a/resources/locales/es_CL/es_CL.go +++ b/resources/locales/es_CL/es_CL.go @@ -1,36 +1,54 @@ package es_CL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_CL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_CL' locale func New() locales.Translator { return &es_CL{ - locale: "es_CL", + locale: "es_CL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_CL) Locale() string { - return l.locale +func (t *es_CL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_CL' +func (t *es_CL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_CL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_CL' +func (t *es_CL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_CO/es_CO.go b/resources/locales/es_CO/es_CO.go index 25937a9..8b809b9 100644 --- a/resources/locales/es_CO/es_CO.go +++ b/resources/locales/es_CO/es_CO.go @@ -1,36 +1,54 @@ package es_CO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_CO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_CO' locale func New() locales.Translator { return &es_CO{ - locale: "es_CO", + locale: "es_CO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_CO) Locale() string { - return l.locale +func (t *es_CO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_CO' +func (t *es_CO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_CO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_CO' +func (t *es_CO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_CR/es_CR.go b/resources/locales/es_CR/es_CR.go index f052bda..e932e60 100644 --- a/resources/locales/es_CR/es_CR.go +++ b/resources/locales/es_CR/es_CR.go @@ -1,36 +1,54 @@ package es_CR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_CR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_CR' locale func New() locales.Translator { return &es_CR{ - locale: "es_CR", + locale: "es_CR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_CR) Locale() string { - return l.locale +func (t *es_CR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_CR' +func (t *es_CR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_CR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_CR' +func (t *es_CR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_CU/es_CU.go b/resources/locales/es_CU/es_CU.go index b0ac973..93ac6ff 100644 --- a/resources/locales/es_CU/es_CU.go +++ b/resources/locales/es_CU/es_CU.go @@ -1,36 +1,54 @@ package es_CU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_CU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_CU' locale func New() locales.Translator { return &es_CU{ - locale: "es_CU", + locale: "es_CU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_CU) Locale() string { - return l.locale +func (t *es_CU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_CU' +func (t *es_CU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_CU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_CU' +func (t *es_CU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_DO/es_DO.go b/resources/locales/es_DO/es_DO.go index cfdeb25..7c60bea 100644 --- a/resources/locales/es_DO/es_DO.go +++ b/resources/locales/es_DO/es_DO.go @@ -1,36 +1,54 @@ package es_DO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_DO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_DO' locale func New() locales.Translator { return &es_DO{ - locale: "es_DO", + locale: "es_DO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_DO) Locale() string { - return l.locale +func (t *es_DO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_DO' +func (t *es_DO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_DO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_DO' +func (t *es_DO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_EA/es_EA.go b/resources/locales/es_EA/es_EA.go index 5037183..e650e1b 100644 --- a/resources/locales/es_EA/es_EA.go +++ b/resources/locales/es_EA/es_EA.go @@ -1,36 +1,54 @@ package es_EA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_EA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_EA' locale func New() locales.Translator { return &es_EA{ - locale: "es_EA", + locale: "es_EA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_EA) Locale() string { - return l.locale +func (t *es_EA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_EA' +func (t *es_EA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_EA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_EA' +func (t *es_EA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_EC/es_EC.go b/resources/locales/es_EC/es_EC.go index 8cc9fc4..de1a373 100644 --- a/resources/locales/es_EC/es_EC.go +++ b/resources/locales/es_EC/es_EC.go @@ -1,36 +1,54 @@ package es_EC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_EC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_EC' locale func New() locales.Translator { return &es_EC{ - locale: "es_EC", + locale: "es_EC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_EC) Locale() string { - return l.locale +func (t *es_EC) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_EC' +func (t *es_EC) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_EC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_EC' +func (t *es_EC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_ES/es_ES.go b/resources/locales/es_ES/es_ES.go index f1fb31a..620e75f 100644 --- a/resources/locales/es_ES/es_ES.go +++ b/resources/locales/es_ES/es_ES.go @@ -1,36 +1,54 @@ package es_ES import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_ES struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_ES' locale func New() locales.Translator { return &es_ES{ - locale: "es_ES", + locale: "es_ES", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_ES) Locale() string { - return l.locale +func (t *es_ES) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_ES' +func (t *es_ES) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_ES) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_ES' +func (t *es_ES) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_GQ/es_GQ.go b/resources/locales/es_GQ/es_GQ.go index f105df8..3538f7b 100644 --- a/resources/locales/es_GQ/es_GQ.go +++ b/resources/locales/es_GQ/es_GQ.go @@ -1,36 +1,54 @@ package es_GQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_GQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_GQ' locale func New() locales.Translator { return &es_GQ{ - locale: "es_GQ", + locale: "es_GQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_GQ) Locale() string { - return l.locale +func (t *es_GQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_GQ' +func (t *es_GQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_GQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_GQ' +func (t *es_GQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_GT/es_GT.go b/resources/locales/es_GT/es_GT.go index 27257a3..a704edf 100644 --- a/resources/locales/es_GT/es_GT.go +++ b/resources/locales/es_GT/es_GT.go @@ -1,36 +1,54 @@ package es_GT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_GT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_GT' locale func New() locales.Translator { return &es_GT{ - locale: "es_GT", + locale: "es_GT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_GT) Locale() string { - return l.locale +func (t *es_GT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_GT' +func (t *es_GT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_GT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_GT' +func (t *es_GT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_HN/es_HN.go b/resources/locales/es_HN/es_HN.go index 765f43b..da85e7c 100644 --- a/resources/locales/es_HN/es_HN.go +++ b/resources/locales/es_HN/es_HN.go @@ -1,36 +1,54 @@ package es_HN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_HN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_HN' locale func New() locales.Translator { return &es_HN{ - locale: "es_HN", + locale: "es_HN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_HN) Locale() string { - return l.locale +func (t *es_HN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_HN' +func (t *es_HN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_HN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_HN' +func (t *es_HN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_IC/es_IC.go b/resources/locales/es_IC/es_IC.go index 738757b..24f5a32 100644 --- a/resources/locales/es_IC/es_IC.go +++ b/resources/locales/es_IC/es_IC.go @@ -1,36 +1,54 @@ package es_IC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_IC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_IC' locale func New() locales.Translator { return &es_IC{ - locale: "es_IC", + locale: "es_IC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_IC) Locale() string { - return l.locale +func (t *es_IC) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_IC' +func (t *es_IC) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_IC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_IC' +func (t *es_IC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_MX/es_MX.go b/resources/locales/es_MX/es_MX.go index 7fa4cff..cdb2fd6 100644 --- a/resources/locales/es_MX/es_MX.go +++ b/resources/locales/es_MX/es_MX.go @@ -1,36 +1,54 @@ package es_MX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_MX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_MX' locale func New() locales.Translator { return &es_MX{ - locale: "es_MX", + locale: "es_MX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_MX) Locale() string { - return l.locale +func (t *es_MX) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_MX' +func (t *es_MX) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_MX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_MX' +func (t *es_MX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_NI/es_NI.go b/resources/locales/es_NI/es_NI.go index aa50b25..b9d9814 100644 --- a/resources/locales/es_NI/es_NI.go +++ b/resources/locales/es_NI/es_NI.go @@ -1,36 +1,54 @@ package es_NI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_NI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_NI' locale func New() locales.Translator { return &es_NI{ - locale: "es_NI", + locale: "es_NI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_NI) Locale() string { - return l.locale +func (t *es_NI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_NI' +func (t *es_NI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_NI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_NI' +func (t *es_NI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_PA/es_PA.go b/resources/locales/es_PA/es_PA.go index 8a94e01..414ac2c 100644 --- a/resources/locales/es_PA/es_PA.go +++ b/resources/locales/es_PA/es_PA.go @@ -1,36 +1,54 @@ package es_PA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_PA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_PA' locale func New() locales.Translator { return &es_PA{ - locale: "es_PA", + locale: "es_PA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_PA) Locale() string { - return l.locale +func (t *es_PA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_PA' +func (t *es_PA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_PA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_PA' +func (t *es_PA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_PE/es_PE.go b/resources/locales/es_PE/es_PE.go index 4435f18..909ea53 100644 --- a/resources/locales/es_PE/es_PE.go +++ b/resources/locales/es_PE/es_PE.go @@ -1,36 +1,54 @@ package es_PE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_PE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_PE' locale func New() locales.Translator { return &es_PE{ - locale: "es_PE", + locale: "es_PE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_PE) Locale() string { - return l.locale +func (t *es_PE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_PE' +func (t *es_PE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_PE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_PE' +func (t *es_PE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_PH/es_PH.go b/resources/locales/es_PH/es_PH.go index fb4db4c..69113e1 100644 --- a/resources/locales/es_PH/es_PH.go +++ b/resources/locales/es_PH/es_PH.go @@ -1,36 +1,54 @@ package es_PH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_PH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_PH' locale func New() locales.Translator { return &es_PH{ - locale: "es_PH", + locale: "es_PH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_PH) Locale() string { - return l.locale +func (t *es_PH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_PH' +func (t *es_PH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_PH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_PH' +func (t *es_PH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_PR/es_PR.go b/resources/locales/es_PR/es_PR.go index be877ff..278d546 100644 --- a/resources/locales/es_PR/es_PR.go +++ b/resources/locales/es_PR/es_PR.go @@ -1,36 +1,54 @@ package es_PR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_PR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_PR' locale func New() locales.Translator { return &es_PR{ - locale: "es_PR", + locale: "es_PR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *es_PR) Locale() string { - return l.locale +func (t *es_PR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_PR' +func (t *es_PR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_PR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_PR' +func (t *es_PR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_PY/es_PY.go b/resources/locales/es_PY/es_PY.go index 95ae9af..10a4c0e 100644 --- a/resources/locales/es_PY/es_PY.go +++ b/resources/locales/es_PY/es_PY.go @@ -1,36 +1,54 @@ package es_PY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_PY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_PY' locale func New() locales.Translator { return &es_PY{ - locale: "es_PY", + locale: "es_PY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_PY) Locale() string { - return l.locale +func (t *es_PY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_PY' +func (t *es_PY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_PY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_PY' +func (t *es_PY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_SV/es_SV.go b/resources/locales/es_SV/es_SV.go index 0cf7409..1c08ddb 100644 --- a/resources/locales/es_SV/es_SV.go +++ b/resources/locales/es_SV/es_SV.go @@ -1,36 +1,54 @@ package es_SV import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_SV struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_SV' locale func New() locales.Translator { return &es_SV{ - locale: "es_SV", + locale: "es_SV", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_SV) Locale() string { - return l.locale +func (t *es_SV) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_SV' +func (t *es_SV) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_SV) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_SV' +func (t *es_SV) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_US/es_US.go b/resources/locales/es_US/es_US.go index d507f8b..6d93641 100644 --- a/resources/locales/es_US/es_US.go +++ b/resources/locales/es_US/es_US.go @@ -1,36 +1,54 @@ package es_US import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_US struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_US' locale func New() locales.Translator { return &es_US{ - locale: "es_US", + locale: "es_US", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_US) Locale() string { - return l.locale +func (t *es_US) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_US' +func (t *es_US) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_US) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_US' +func (t *es_US) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_UY/es_UY.go b/resources/locales/es_UY/es_UY.go index d035983..7046f90 100644 --- a/resources/locales/es_UY/es_UY.go +++ b/resources/locales/es_UY/es_UY.go @@ -1,36 +1,54 @@ package es_UY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_UY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_UY' locale func New() locales.Translator { return &es_UY{ - locale: "es_UY", + locale: "es_UY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_UY) Locale() string { - return l.locale +func (t *es_UY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_UY' +func (t *es_UY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_UY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_UY' +func (t *es_UY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/es_VE/es_VE.go b/resources/locales/es_VE/es_VE.go index ee39afd..db43875 100644 --- a/resources/locales/es_VE/es_VE.go +++ b/resources/locales/es_VE/es_VE.go @@ -1,36 +1,54 @@ package es_VE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type es_VE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'es_VE' locale func New() locales.Translator { return &es_VE{ - locale: "es_VE", + locale: "es_VE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *es_VE) Locale() string { - return l.locale +func (t *es_VE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'es_VE' +func (t *es_VE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *es_VE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'es_VE' +func (t *es_VE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/et/et.go b/resources/locales/et/et.go index 0ced270..e11aff0 100644 --- a/resources/locales/et/et.go +++ b/resources/locales/et/et.go @@ -1,38 +1,55 @@ package et import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type et struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'et' locale func New() locales.Translator { return &et{ - locale: "et", + locale: "et", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *et) Locale() string { - return l.locale +func (t *et) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *et) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'et' +func (t *et) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'et' +func (t *et) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/et_EE/et_EE.go b/resources/locales/et_EE/et_EE.go index e66b05d..3eaa8e6 100644 --- a/resources/locales/et_EE/et_EE.go +++ b/resources/locales/et_EE/et_EE.go @@ -1,38 +1,55 @@ package et_EE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type et_EE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'et_EE' locale func New() locales.Translator { return &et_EE{ - locale: "et_EE", + locale: "et_EE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *et_EE) Locale() string { - return l.locale +func (t *et_EE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *et_EE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'et_EE' +func (t *et_EE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'et_EE' +func (t *et_EE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/eu/eu.go b/resources/locales/eu/eu.go index 3b30fa0..ce4ebec 100644 --- a/resources/locales/eu/eu.go +++ b/resources/locales/eu/eu.go @@ -1,36 +1,54 @@ package eu import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type eu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'eu' locale func New() locales.Translator { return &eu{ - locale: "eu", + locale: "eu", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *eu) Locale() string { - return l.locale +func (t *eu) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'eu' +func (t *eu) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *eu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'eu' +func (t *eu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/eu_ES/eu_ES.go b/resources/locales/eu_ES/eu_ES.go index 2758e18..7ba5fd3 100644 --- a/resources/locales/eu_ES/eu_ES.go +++ b/resources/locales/eu_ES/eu_ES.go @@ -1,36 +1,54 @@ package eu_ES import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type eu_ES struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'eu_ES' locale func New() locales.Translator { return &eu_ES{ - locale: "eu_ES", + locale: "eu_ES", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *eu_ES) Locale() string { - return l.locale +func (t *eu_ES) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'eu_ES' +func (t *eu_ES) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *eu_ES) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'eu_ES' +func (t *eu_ES) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ewo/ewo.go b/resources/locales/ewo/ewo.go index f94a175..76c360d 100644 --- a/resources/locales/ewo/ewo.go +++ b/resources/locales/ewo/ewo.go @@ -1,26 +1,43 @@ package ewo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ewo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ewo' locale func New() locales.Translator { return &ewo{ - locale: "ewo", + locale: "ewo", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ewo) Locale() string { - return l.locale +func (t *ewo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ewo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ewo' +func (t *ewo) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ewo' +func (t *ewo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ewo_CM/ewo_CM.go b/resources/locales/ewo_CM/ewo_CM.go index 3e9ae4e..f3a2fc6 100644 --- a/resources/locales/ewo_CM/ewo_CM.go +++ b/resources/locales/ewo_CM/ewo_CM.go @@ -1,26 +1,43 @@ package ewo_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ewo_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ewo_CM' locale func New() locales.Translator { return &ewo_CM{ - locale: "ewo_CM", + locale: "ewo_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ewo_CM) Locale() string { - return l.locale +func (t *ewo_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ewo_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ewo_CM' +func (t *ewo_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ewo_CM' +func (t *ewo_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/fa/fa.go b/resources/locales/fa/fa.go index 0c66a77..92ab6c1 100644 --- a/resources/locales/fa/fa.go +++ b/resources/locales/fa/fa.go @@ -1,41 +1,55 @@ package fa import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fa struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fa' locale func New() locales.Translator { return &fa{ - locale: "fa", + locale: "fa", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fa) Locale() string { - return l.locale +func (t *fa) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fa) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fa' +func (t *fa) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fa' +func (t *fa) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fa_AF/fa_AF.go b/resources/locales/fa_AF/fa_AF.go index 7e1421e..4a58629 100644 --- a/resources/locales/fa_AF/fa_AF.go +++ b/resources/locales/fa_AF/fa_AF.go @@ -1,41 +1,55 @@ package fa_AF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fa_AF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fa_AF' locale func New() locales.Translator { return &fa_AF{ - locale: "fa_AF", + locale: "fa_AF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fa_AF) Locale() string { - return l.locale +func (t *fa_AF) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fa_AF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fa_AF' +func (t *fa_AF) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fa_AF' +func (t *fa_AF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fa_IR/fa_IR.go b/resources/locales/fa_IR/fa_IR.go index b4f0413..aa6057c 100644 --- a/resources/locales/fa_IR/fa_IR.go +++ b/resources/locales/fa_IR/fa_IR.go @@ -1,41 +1,55 @@ package fa_IR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fa_IR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fa_IR' locale func New() locales.Translator { return &fa_IR{ - locale: "fa_IR", + locale: "fa_IR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fa_IR) Locale() string { - return l.locale +func (t *fa_IR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fa_IR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fa_IR' +func (t *fa_IR) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fa_IR' +func (t *fa_IR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ff/ff.go b/resources/locales/ff/ff.go index b9757d7..0c201ce 100644 --- a/resources/locales/ff/ff.go +++ b/resources/locales/ff/ff.go @@ -1,36 +1,55 @@ package ff import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ff struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ff' locale func New() locales.Translator { return &ff{ - locale: "ff", + locale: "ff", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ff) Locale() string { - return l.locale +func (t *ff) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ff' +func (t *ff) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ff) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ff' +func (t *ff) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ff_CM/ff_CM.go b/resources/locales/ff_CM/ff_CM.go index d6733dc..efc82f9 100644 --- a/resources/locales/ff_CM/ff_CM.go +++ b/resources/locales/ff_CM/ff_CM.go @@ -1,36 +1,55 @@ package ff_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ff_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ff_CM' locale func New() locales.Translator { return &ff_CM{ - locale: "ff_CM", + locale: "ff_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ff_CM) Locale() string { - return l.locale +func (t *ff_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ff_CM' +func (t *ff_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ff_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ff_CM' +func (t *ff_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ff_GN/ff_GN.go b/resources/locales/ff_GN/ff_GN.go index fcd8888..8179741 100644 --- a/resources/locales/ff_GN/ff_GN.go +++ b/resources/locales/ff_GN/ff_GN.go @@ -1,36 +1,55 @@ package ff_GN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ff_GN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ff_GN' locale func New() locales.Translator { return &ff_GN{ - locale: "ff_GN", + locale: "ff_GN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ff_GN) Locale() string { - return l.locale +func (t *ff_GN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ff_GN' +func (t *ff_GN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ff_GN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ff_GN' +func (t *ff_GN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ff_MR/ff_MR.go b/resources/locales/ff_MR/ff_MR.go index 8e00e89..a58af90 100644 --- a/resources/locales/ff_MR/ff_MR.go +++ b/resources/locales/ff_MR/ff_MR.go @@ -1,36 +1,55 @@ package ff_MR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ff_MR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ff_MR' locale func New() locales.Translator { return &ff_MR{ - locale: "ff_MR", + locale: "ff_MR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ff_MR) Locale() string { - return l.locale +func (t *ff_MR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ff_MR' +func (t *ff_MR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ff_MR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ff_MR' +func (t *ff_MR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ff_SN/ff_SN.go b/resources/locales/ff_SN/ff_SN.go index b925f8e..816f1c4 100644 --- a/resources/locales/ff_SN/ff_SN.go +++ b/resources/locales/ff_SN/ff_SN.go @@ -1,36 +1,55 @@ package ff_SN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ff_SN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ff_SN' locale func New() locales.Translator { return &ff_SN{ - locale: "ff_SN", + locale: "ff_SN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ff_SN) Locale() string { - return l.locale +func (t *ff_SN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ff_SN' +func (t *ff_SN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ff_SN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ff_SN' +func (t *ff_SN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fi/fi.go b/resources/locales/fi/fi.go index 5e894d5..aeb8395 100644 --- a/resources/locales/fi/fi.go +++ b/resources/locales/fi/fi.go @@ -1,38 +1,55 @@ package fi import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fi struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fi' locale func New() locales.Translator { return &fi{ - locale: "fi", + locale: "fi", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fi) Locale() string { - return l.locale +func (t *fi) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fi) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fi' +func (t *fi) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fi' +func (t *fi) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fi_FI/fi_FI.go b/resources/locales/fi_FI/fi_FI.go index 60129f7..835645c 100644 --- a/resources/locales/fi_FI/fi_FI.go +++ b/resources/locales/fi_FI/fi_FI.go @@ -1,38 +1,55 @@ package fi_FI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fi_FI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fi_FI' locale func New() locales.Translator { return &fi_FI{ - locale: "fi_FI", + locale: "fi_FI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fi_FI) Locale() string { - return l.locale +func (t *fi_FI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fi_FI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fi_FI' +func (t *fi_FI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fi_FI' +func (t *fi_FI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fil/fil.go b/resources/locales/fil/fil.go index e6ef630..003de05 100644 --- a/resources/locales/fil/fil.go +++ b/resources/locales/fil/fil.go @@ -1,43 +1,56 @@ package fil import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fil struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fil' locale func New() locales.Translator { return &fil{ - locale: "fil", + locale: "fil", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fil) Locale() string { - return l.locale +func (t *fil) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fil) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fil' +func (t *fil) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fil' +func (t *fil) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && (i == 1 || i == 2 || i == 3)) || (v == 0 && (i%10 != 4 && i%10 != 6 && i%10 != 9)) || (v != 0 && (f%10 != 4 && f%10 != 6 && f%10 != 9)) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fil_PH/fil_PH.go b/resources/locales/fil_PH/fil_PH.go index 39b2ac6..6df8c7d 100644 --- a/resources/locales/fil_PH/fil_PH.go +++ b/resources/locales/fil_PH/fil_PH.go @@ -1,43 +1,56 @@ package fil_PH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fil_PH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fil_PH' locale func New() locales.Translator { return &fil_PH{ - locale: "fil_PH", + locale: "fil_PH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fil_PH) Locale() string { - return l.locale +func (t *fil_PH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fil_PH) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'fil_PH' +func (t *fil_PH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fil_PH' +func (t *fil_PH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && (i == 1 || i == 2 || i == 3)) || (v == 0 && (i%10 != 4 && i%10 != 6 && i%10 != 9)) || (v != 0 && (f%10 != 4 && f%10 != 6 && f%10 != 9)) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fo/fo.go b/resources/locales/fo/fo.go index ba84122..4a9e4eb 100644 --- a/resources/locales/fo/fo.go +++ b/resources/locales/fo/fo.go @@ -1,36 +1,54 @@ package fo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fo' locale func New() locales.Translator { return &fo{ - locale: "fo", + locale: "fo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fo) Locale() string { - return l.locale +func (t *fo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fo' +func (t *fo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fo' +func (t *fo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fo_DK/fo_DK.go b/resources/locales/fo_DK/fo_DK.go index f1bdc93..745cb65 100644 --- a/resources/locales/fo_DK/fo_DK.go +++ b/resources/locales/fo_DK/fo_DK.go @@ -1,36 +1,54 @@ package fo_DK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fo_DK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fo_DK' locale func New() locales.Translator { return &fo_DK{ - locale: "fo_DK", + locale: "fo_DK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fo_DK) Locale() string { - return l.locale +func (t *fo_DK) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fo_DK' +func (t *fo_DK) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fo_DK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fo_DK' +func (t *fo_DK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fo_FO/fo_FO.go b/resources/locales/fo_FO/fo_FO.go index 0f6b6ab..83b6939 100644 --- a/resources/locales/fo_FO/fo_FO.go +++ b/resources/locales/fo_FO/fo_FO.go @@ -1,36 +1,54 @@ package fo_FO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fo_FO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fo_FO' locale func New() locales.Translator { return &fo_FO{ - locale: "fo_FO", + locale: "fo_FO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fo_FO) Locale() string { - return l.locale +func (t *fo_FO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fo_FO' +func (t *fo_FO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fo_FO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fo_FO' +func (t *fo_FO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr/fr.go b/resources/locales/fr/fr.go index 3985581..4dd3d0b 100644 --- a/resources/locales/fr/fr.go +++ b/resources/locales/fr/fr.go @@ -1,36 +1,55 @@ package fr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr' locale func New() locales.Translator { return &fr{ - locale: "fr", + locale: "fr", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0xe2, 0x80, 0x8f, 0xe2, 0x88, 0x92}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr) Locale() string { - return l.locale +func (t *fr) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr' +func (t *fr) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr' +func (t *fr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_BE/fr_BE.go b/resources/locales/fr_BE/fr_BE.go index e4eb83d..8314449 100644 --- a/resources/locales/fr_BE/fr_BE.go +++ b/resources/locales/fr_BE/fr_BE.go @@ -1,36 +1,55 @@ package fr_BE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_BE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_BE' locale func New() locales.Translator { return &fr_BE{ - locale: "fr_BE", + locale: "fr_BE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_BE) Locale() string { - return l.locale +func (t *fr_BE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_BE' +func (t *fr_BE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_BE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_BE' +func (t *fr_BE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_BF/fr_BF.go b/resources/locales/fr_BF/fr_BF.go index d7577f9..ed77bef 100644 --- a/resources/locales/fr_BF/fr_BF.go +++ b/resources/locales/fr_BF/fr_BF.go @@ -1,36 +1,55 @@ package fr_BF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_BF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_BF' locale func New() locales.Translator { return &fr_BF{ - locale: "fr_BF", + locale: "fr_BF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_BF) Locale() string { - return l.locale +func (t *fr_BF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_BF' +func (t *fr_BF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_BF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_BF' +func (t *fr_BF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_BI/fr_BI.go b/resources/locales/fr_BI/fr_BI.go index 9c3b25f..2eea025 100644 --- a/resources/locales/fr_BI/fr_BI.go +++ b/resources/locales/fr_BI/fr_BI.go @@ -1,36 +1,55 @@ package fr_BI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_BI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_BI' locale func New() locales.Translator { return &fr_BI{ - locale: "fr_BI", + locale: "fr_BI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_BI) Locale() string { - return l.locale +func (t *fr_BI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_BI' +func (t *fr_BI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_BI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_BI' +func (t *fr_BI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_BJ/fr_BJ.go b/resources/locales/fr_BJ/fr_BJ.go index 1b2cd3a..a303170 100644 --- a/resources/locales/fr_BJ/fr_BJ.go +++ b/resources/locales/fr_BJ/fr_BJ.go @@ -1,36 +1,55 @@ package fr_BJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_BJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_BJ' locale func New() locales.Translator { return &fr_BJ{ - locale: "fr_BJ", + locale: "fr_BJ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_BJ) Locale() string { - return l.locale +func (t *fr_BJ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_BJ' +func (t *fr_BJ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_BJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_BJ' +func (t *fr_BJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_BL/fr_BL.go b/resources/locales/fr_BL/fr_BL.go index d6e9e65..1014bad 100644 --- a/resources/locales/fr_BL/fr_BL.go +++ b/resources/locales/fr_BL/fr_BL.go @@ -1,36 +1,55 @@ package fr_BL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_BL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_BL' locale func New() locales.Translator { return &fr_BL{ - locale: "fr_BL", + locale: "fr_BL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_BL) Locale() string { - return l.locale +func (t *fr_BL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_BL' +func (t *fr_BL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_BL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_BL' +func (t *fr_BL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CA/fr_CA.go b/resources/locales/fr_CA/fr_CA.go index 0946cfe..5fd18ff 100644 --- a/resources/locales/fr_CA/fr_CA.go +++ b/resources/locales/fr_CA/fr_CA.go @@ -1,36 +1,55 @@ package fr_CA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CA' locale func New() locales.Translator { return &fr_CA{ - locale: "fr_CA", + locale: "fr_CA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_CA) Locale() string { - return l.locale +func (t *fr_CA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CA' +func (t *fr_CA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CA' +func (t *fr_CA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CD/fr_CD.go b/resources/locales/fr_CD/fr_CD.go index 66ba4e0..5eaf6a4 100644 --- a/resources/locales/fr_CD/fr_CD.go +++ b/resources/locales/fr_CD/fr_CD.go @@ -1,36 +1,55 @@ package fr_CD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CD' locale func New() locales.Translator { return &fr_CD{ - locale: "fr_CD", + locale: "fr_CD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_CD) Locale() string { - return l.locale +func (t *fr_CD) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CD' +func (t *fr_CD) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CD' +func (t *fr_CD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CF/fr_CF.go b/resources/locales/fr_CF/fr_CF.go index 7d4ceb5..7a0376c 100644 --- a/resources/locales/fr_CF/fr_CF.go +++ b/resources/locales/fr_CF/fr_CF.go @@ -1,36 +1,55 @@ package fr_CF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CF' locale func New() locales.Translator { return &fr_CF{ - locale: "fr_CF", + locale: "fr_CF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_CF) Locale() string { - return l.locale +func (t *fr_CF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CF' +func (t *fr_CF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CF' +func (t *fr_CF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CG/fr_CG.go b/resources/locales/fr_CG/fr_CG.go index fd588c1..94ae1f2 100644 --- a/resources/locales/fr_CG/fr_CG.go +++ b/resources/locales/fr_CG/fr_CG.go @@ -1,36 +1,55 @@ package fr_CG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CG' locale func New() locales.Translator { return &fr_CG{ - locale: "fr_CG", + locale: "fr_CG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_CG) Locale() string { - return l.locale +func (t *fr_CG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CG' +func (t *fr_CG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CG' +func (t *fr_CG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CH/fr_CH.go b/resources/locales/fr_CH/fr_CH.go index 3aa0c2d..f55d82e 100644 --- a/resources/locales/fr_CH/fr_CH.go +++ b/resources/locales/fr_CH/fr_CH.go @@ -1,36 +1,55 @@ package fr_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CH' locale func New() locales.Translator { return &fr_CH{ - locale: "fr_CH", + locale: "fr_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_CH) Locale() string { - return l.locale +func (t *fr_CH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CH' +func (t *fr_CH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CH' +func (t *fr_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CI/fr_CI.go b/resources/locales/fr_CI/fr_CI.go index ea83c7e..4bef7a1 100644 --- a/resources/locales/fr_CI/fr_CI.go +++ b/resources/locales/fr_CI/fr_CI.go @@ -1,36 +1,55 @@ package fr_CI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CI' locale func New() locales.Translator { return &fr_CI{ - locale: "fr_CI", + locale: "fr_CI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_CI) Locale() string { - return l.locale +func (t *fr_CI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CI' +func (t *fr_CI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CI' +func (t *fr_CI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_CM/fr_CM.go b/resources/locales/fr_CM/fr_CM.go index 0788ead..eb7f837 100644 --- a/resources/locales/fr_CM/fr_CM.go +++ b/resources/locales/fr_CM/fr_CM.go @@ -1,36 +1,55 @@ package fr_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_CM' locale func New() locales.Translator { return &fr_CM{ - locale: "fr_CM", + locale: "fr_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_CM) Locale() string { - return l.locale +func (t *fr_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_CM' +func (t *fr_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_CM' +func (t *fr_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_DJ/fr_DJ.go b/resources/locales/fr_DJ/fr_DJ.go index 16344b0..c1906a0 100644 --- a/resources/locales/fr_DJ/fr_DJ.go +++ b/resources/locales/fr_DJ/fr_DJ.go @@ -1,36 +1,55 @@ package fr_DJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_DJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_DJ' locale func New() locales.Translator { return &fr_DJ{ - locale: "fr_DJ", + locale: "fr_DJ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_DJ) Locale() string { - return l.locale +func (t *fr_DJ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_DJ' +func (t *fr_DJ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_DJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_DJ' +func (t *fr_DJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_DZ/fr_DZ.go b/resources/locales/fr_DZ/fr_DZ.go index 8c8dcb6..616d991 100644 --- a/resources/locales/fr_DZ/fr_DZ.go +++ b/resources/locales/fr_DZ/fr_DZ.go @@ -1,36 +1,55 @@ package fr_DZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_DZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_DZ' locale func New() locales.Translator { return &fr_DZ{ - locale: "fr_DZ", + locale: "fr_DZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_DZ) Locale() string { - return l.locale +func (t *fr_DZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_DZ' +func (t *fr_DZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_DZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_DZ' +func (t *fr_DZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_FR/fr_FR.go b/resources/locales/fr_FR/fr_FR.go index e5f297b..84b1d2d 100644 --- a/resources/locales/fr_FR/fr_FR.go +++ b/resources/locales/fr_FR/fr_FR.go @@ -1,36 +1,55 @@ package fr_FR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_FR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_FR' locale func New() locales.Translator { return &fr_FR{ - locale: "fr_FR", + locale: "fr_FR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_FR) Locale() string { - return l.locale +func (t *fr_FR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_FR' +func (t *fr_FR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_FR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_FR' +func (t *fr_FR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_GA/fr_GA.go b/resources/locales/fr_GA/fr_GA.go index bb22c01..da6f113 100644 --- a/resources/locales/fr_GA/fr_GA.go +++ b/resources/locales/fr_GA/fr_GA.go @@ -1,36 +1,55 @@ package fr_GA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_GA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_GA' locale func New() locales.Translator { return &fr_GA{ - locale: "fr_GA", + locale: "fr_GA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_GA) Locale() string { - return l.locale +func (t *fr_GA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_GA' +func (t *fr_GA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_GA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_GA' +func (t *fr_GA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_GF/fr_GF.go b/resources/locales/fr_GF/fr_GF.go index 08800e6..b0a04a3 100644 --- a/resources/locales/fr_GF/fr_GF.go +++ b/resources/locales/fr_GF/fr_GF.go @@ -1,36 +1,55 @@ package fr_GF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_GF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_GF' locale func New() locales.Translator { return &fr_GF{ - locale: "fr_GF", + locale: "fr_GF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_GF) Locale() string { - return l.locale +func (t *fr_GF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_GF' +func (t *fr_GF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_GF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_GF' +func (t *fr_GF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_GN/fr_GN.go b/resources/locales/fr_GN/fr_GN.go index 1d451d8..1accb72 100644 --- a/resources/locales/fr_GN/fr_GN.go +++ b/resources/locales/fr_GN/fr_GN.go @@ -1,36 +1,55 @@ package fr_GN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_GN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_GN' locale func New() locales.Translator { return &fr_GN{ - locale: "fr_GN", + locale: "fr_GN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_GN) Locale() string { - return l.locale +func (t *fr_GN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_GN' +func (t *fr_GN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_GN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_GN' +func (t *fr_GN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_GP/fr_GP.go b/resources/locales/fr_GP/fr_GP.go index b2696a9..447cf28 100644 --- a/resources/locales/fr_GP/fr_GP.go +++ b/resources/locales/fr_GP/fr_GP.go @@ -1,36 +1,55 @@ package fr_GP import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_GP struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_GP' locale func New() locales.Translator { return &fr_GP{ - locale: "fr_GP", + locale: "fr_GP", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_GP) Locale() string { - return l.locale +func (t *fr_GP) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_GP' +func (t *fr_GP) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_GP) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_GP' +func (t *fr_GP) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_GQ/fr_GQ.go b/resources/locales/fr_GQ/fr_GQ.go index a07c952..657e09f 100644 --- a/resources/locales/fr_GQ/fr_GQ.go +++ b/resources/locales/fr_GQ/fr_GQ.go @@ -1,36 +1,55 @@ package fr_GQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_GQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_GQ' locale func New() locales.Translator { return &fr_GQ{ - locale: "fr_GQ", + locale: "fr_GQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_GQ) Locale() string { - return l.locale +func (t *fr_GQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_GQ' +func (t *fr_GQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_GQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_GQ' +func (t *fr_GQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_HT/fr_HT.go b/resources/locales/fr_HT/fr_HT.go index ac569ab..126672c 100644 --- a/resources/locales/fr_HT/fr_HT.go +++ b/resources/locales/fr_HT/fr_HT.go @@ -1,36 +1,55 @@ package fr_HT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_HT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_HT' locale func New() locales.Translator { return &fr_HT{ - locale: "fr_HT", + locale: "fr_HT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_HT) Locale() string { - return l.locale +func (t *fr_HT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_HT' +func (t *fr_HT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_HT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_HT' +func (t *fr_HT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_KM/fr_KM.go b/resources/locales/fr_KM/fr_KM.go index dca8330..216c011 100644 --- a/resources/locales/fr_KM/fr_KM.go +++ b/resources/locales/fr_KM/fr_KM.go @@ -1,36 +1,55 @@ package fr_KM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_KM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_KM' locale func New() locales.Translator { return &fr_KM{ - locale: "fr_KM", + locale: "fr_KM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_KM) Locale() string { - return l.locale +func (t *fr_KM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_KM' +func (t *fr_KM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_KM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_KM' +func (t *fr_KM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_LU/fr_LU.go b/resources/locales/fr_LU/fr_LU.go index 0a1e409..3ff6294 100644 --- a/resources/locales/fr_LU/fr_LU.go +++ b/resources/locales/fr_LU/fr_LU.go @@ -1,36 +1,55 @@ package fr_LU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_LU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_LU' locale func New() locales.Translator { return &fr_LU{ - locale: "fr_LU", + locale: "fr_LU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_LU) Locale() string { - return l.locale +func (t *fr_LU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_LU' +func (t *fr_LU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_LU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_LU' +func (t *fr_LU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MA/fr_MA.go b/resources/locales/fr_MA/fr_MA.go index 0d05c72..4372941 100644 --- a/resources/locales/fr_MA/fr_MA.go +++ b/resources/locales/fr_MA/fr_MA.go @@ -1,36 +1,55 @@ package fr_MA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MA' locale func New() locales.Translator { return &fr_MA{ - locale: "fr_MA", + locale: "fr_MA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MA) Locale() string { - return l.locale +func (t *fr_MA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MA' +func (t *fr_MA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MA' +func (t *fr_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MC/fr_MC.go b/resources/locales/fr_MC/fr_MC.go index d714304..5b4b6cb 100644 --- a/resources/locales/fr_MC/fr_MC.go +++ b/resources/locales/fr_MC/fr_MC.go @@ -1,36 +1,55 @@ package fr_MC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MC' locale func New() locales.Translator { return &fr_MC{ - locale: "fr_MC", + locale: "fr_MC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MC) Locale() string { - return l.locale +func (t *fr_MC) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MC' +func (t *fr_MC) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MC' +func (t *fr_MC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MF/fr_MF.go b/resources/locales/fr_MF/fr_MF.go index 839725b..375e80f 100644 --- a/resources/locales/fr_MF/fr_MF.go +++ b/resources/locales/fr_MF/fr_MF.go @@ -1,36 +1,55 @@ package fr_MF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MF' locale func New() locales.Translator { return &fr_MF{ - locale: "fr_MF", + locale: "fr_MF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MF) Locale() string { - return l.locale +func (t *fr_MF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MF' +func (t *fr_MF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MF' +func (t *fr_MF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MG/fr_MG.go b/resources/locales/fr_MG/fr_MG.go index b15ce6d..3e85d57 100644 --- a/resources/locales/fr_MG/fr_MG.go +++ b/resources/locales/fr_MG/fr_MG.go @@ -1,36 +1,55 @@ package fr_MG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MG' locale func New() locales.Translator { return &fr_MG{ - locale: "fr_MG", + locale: "fr_MG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MG) Locale() string { - return l.locale +func (t *fr_MG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MG' +func (t *fr_MG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MG' +func (t *fr_MG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_ML/fr_ML.go b/resources/locales/fr_ML/fr_ML.go index 7200123..4671036 100644 --- a/resources/locales/fr_ML/fr_ML.go +++ b/resources/locales/fr_ML/fr_ML.go @@ -1,36 +1,55 @@ package fr_ML import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_ML struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_ML' locale func New() locales.Translator { return &fr_ML{ - locale: "fr_ML", + locale: "fr_ML", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_ML) Locale() string { - return l.locale +func (t *fr_ML) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_ML' +func (t *fr_ML) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_ML) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_ML' +func (t *fr_ML) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MQ/fr_MQ.go b/resources/locales/fr_MQ/fr_MQ.go index 77a6f46..fbd73da 100644 --- a/resources/locales/fr_MQ/fr_MQ.go +++ b/resources/locales/fr_MQ/fr_MQ.go @@ -1,36 +1,55 @@ package fr_MQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MQ' locale func New() locales.Translator { return &fr_MQ{ - locale: "fr_MQ", + locale: "fr_MQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MQ) Locale() string { - return l.locale +func (t *fr_MQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MQ' +func (t *fr_MQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MQ' +func (t *fr_MQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MR/fr_MR.go b/resources/locales/fr_MR/fr_MR.go index 9d3f80b..34eebe8 100644 --- a/resources/locales/fr_MR/fr_MR.go +++ b/resources/locales/fr_MR/fr_MR.go @@ -1,36 +1,55 @@ package fr_MR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MR' locale func New() locales.Translator { return &fr_MR{ - locale: "fr_MR", + locale: "fr_MR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MR) Locale() string { - return l.locale +func (t *fr_MR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MR' +func (t *fr_MR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MR' +func (t *fr_MR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_MU/fr_MU.go b/resources/locales/fr_MU/fr_MU.go index 81dbfde..0d5d85b 100644 --- a/resources/locales/fr_MU/fr_MU.go +++ b/resources/locales/fr_MU/fr_MU.go @@ -1,36 +1,55 @@ package fr_MU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_MU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_MU' locale func New() locales.Translator { return &fr_MU{ - locale: "fr_MU", + locale: "fr_MU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_MU) Locale() string { - return l.locale +func (t *fr_MU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_MU' +func (t *fr_MU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_MU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_MU' +func (t *fr_MU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_NC/fr_NC.go b/resources/locales/fr_NC/fr_NC.go index ec90baa..4b37259 100644 --- a/resources/locales/fr_NC/fr_NC.go +++ b/resources/locales/fr_NC/fr_NC.go @@ -1,36 +1,55 @@ package fr_NC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_NC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_NC' locale func New() locales.Translator { return &fr_NC{ - locale: "fr_NC", + locale: "fr_NC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_NC) Locale() string { - return l.locale +func (t *fr_NC) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_NC' +func (t *fr_NC) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_NC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_NC' +func (t *fr_NC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_NE/fr_NE.go b/resources/locales/fr_NE/fr_NE.go index 099f6a0..221c113 100644 --- a/resources/locales/fr_NE/fr_NE.go +++ b/resources/locales/fr_NE/fr_NE.go @@ -1,36 +1,55 @@ package fr_NE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_NE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_NE' locale func New() locales.Translator { return &fr_NE{ - locale: "fr_NE", + locale: "fr_NE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_NE) Locale() string { - return l.locale +func (t *fr_NE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_NE' +func (t *fr_NE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_NE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_NE' +func (t *fr_NE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_PF/fr_PF.go b/resources/locales/fr_PF/fr_PF.go index 3fb9f89..ff60bb1 100644 --- a/resources/locales/fr_PF/fr_PF.go +++ b/resources/locales/fr_PF/fr_PF.go @@ -1,36 +1,55 @@ package fr_PF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_PF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_PF' locale func New() locales.Translator { return &fr_PF{ - locale: "fr_PF", + locale: "fr_PF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_PF) Locale() string { - return l.locale +func (t *fr_PF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_PF' +func (t *fr_PF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_PF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_PF' +func (t *fr_PF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_PM/fr_PM.go b/resources/locales/fr_PM/fr_PM.go index b849524..f5ea808 100644 --- a/resources/locales/fr_PM/fr_PM.go +++ b/resources/locales/fr_PM/fr_PM.go @@ -1,36 +1,55 @@ package fr_PM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_PM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_PM' locale func New() locales.Translator { return &fr_PM{ - locale: "fr_PM", + locale: "fr_PM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_PM) Locale() string { - return l.locale +func (t *fr_PM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_PM' +func (t *fr_PM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_PM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_PM' +func (t *fr_PM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_RE/fr_RE.go b/resources/locales/fr_RE/fr_RE.go index 9b5d763..0ddfb66 100644 --- a/resources/locales/fr_RE/fr_RE.go +++ b/resources/locales/fr_RE/fr_RE.go @@ -1,36 +1,55 @@ package fr_RE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_RE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_RE' locale func New() locales.Translator { return &fr_RE{ - locale: "fr_RE", + locale: "fr_RE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_RE) Locale() string { - return l.locale +func (t *fr_RE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_RE' +func (t *fr_RE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_RE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_RE' +func (t *fr_RE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_RW/fr_RW.go b/resources/locales/fr_RW/fr_RW.go index 1252086..29f7d87 100644 --- a/resources/locales/fr_RW/fr_RW.go +++ b/resources/locales/fr_RW/fr_RW.go @@ -1,36 +1,55 @@ package fr_RW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_RW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_RW' locale func New() locales.Translator { return &fr_RW{ - locale: "fr_RW", + locale: "fr_RW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_RW) Locale() string { - return l.locale +func (t *fr_RW) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_RW' +func (t *fr_RW) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_RW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_RW' +func (t *fr_RW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_SC/fr_SC.go b/resources/locales/fr_SC/fr_SC.go index 8e14ee1..63b9a76 100644 --- a/resources/locales/fr_SC/fr_SC.go +++ b/resources/locales/fr_SC/fr_SC.go @@ -1,36 +1,55 @@ package fr_SC import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_SC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_SC' locale func New() locales.Translator { return &fr_SC{ - locale: "fr_SC", + locale: "fr_SC", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_SC) Locale() string { - return l.locale +func (t *fr_SC) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_SC' +func (t *fr_SC) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_SC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_SC' +func (t *fr_SC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_SN/fr_SN.go b/resources/locales/fr_SN/fr_SN.go index ef49315..8f74dd9 100644 --- a/resources/locales/fr_SN/fr_SN.go +++ b/resources/locales/fr_SN/fr_SN.go @@ -1,36 +1,55 @@ package fr_SN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_SN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_SN' locale func New() locales.Translator { return &fr_SN{ - locale: "fr_SN", + locale: "fr_SN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_SN) Locale() string { - return l.locale +func (t *fr_SN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_SN' +func (t *fr_SN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_SN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_SN' +func (t *fr_SN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_SY/fr_SY.go b/resources/locales/fr_SY/fr_SY.go index dc0eada..75e9ab7 100644 --- a/resources/locales/fr_SY/fr_SY.go +++ b/resources/locales/fr_SY/fr_SY.go @@ -1,36 +1,55 @@ package fr_SY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_SY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_SY' locale func New() locales.Translator { return &fr_SY{ - locale: "fr_SY", + locale: "fr_SY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_SY) Locale() string { - return l.locale +func (t *fr_SY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_SY' +func (t *fr_SY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_SY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_SY' +func (t *fr_SY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_TD/fr_TD.go b/resources/locales/fr_TD/fr_TD.go index a35c7f7..03ae8f8 100644 --- a/resources/locales/fr_TD/fr_TD.go +++ b/resources/locales/fr_TD/fr_TD.go @@ -1,36 +1,55 @@ package fr_TD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_TD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_TD' locale func New() locales.Translator { return &fr_TD{ - locale: "fr_TD", + locale: "fr_TD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_TD) Locale() string { - return l.locale +func (t *fr_TD) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_TD' +func (t *fr_TD) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_TD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_TD' +func (t *fr_TD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_TG/fr_TG.go b/resources/locales/fr_TG/fr_TG.go index a38e26a..45bdf8b 100644 --- a/resources/locales/fr_TG/fr_TG.go +++ b/resources/locales/fr_TG/fr_TG.go @@ -1,36 +1,55 @@ package fr_TG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_TG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_TG' locale func New() locales.Translator { return &fr_TG{ - locale: "fr_TG", + locale: "fr_TG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_TG) Locale() string { - return l.locale +func (t *fr_TG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_TG' +func (t *fr_TG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_TG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_TG' +func (t *fr_TG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_TN/fr_TN.go b/resources/locales/fr_TN/fr_TN.go index 6ce3ab1..bbfd875 100644 --- a/resources/locales/fr_TN/fr_TN.go +++ b/resources/locales/fr_TN/fr_TN.go @@ -1,36 +1,55 @@ package fr_TN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_TN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_TN' locale func New() locales.Translator { return &fr_TN{ - locale: "fr_TN", + locale: "fr_TN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_TN) Locale() string { - return l.locale +func (t *fr_TN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_TN' +func (t *fr_TN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_TN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_TN' +func (t *fr_TN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_VU/fr_VU.go b/resources/locales/fr_VU/fr_VU.go index e5523a5..9ff4ed1 100644 --- a/resources/locales/fr_VU/fr_VU.go +++ b/resources/locales/fr_VU/fr_VU.go @@ -1,36 +1,55 @@ package fr_VU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_VU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_VU' locale func New() locales.Translator { return &fr_VU{ - locale: "fr_VU", + locale: "fr_VU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_VU) Locale() string { - return l.locale +func (t *fr_VU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_VU' +func (t *fr_VU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_VU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_VU' +func (t *fr_VU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_WF/fr_WF.go b/resources/locales/fr_WF/fr_WF.go index c803bac..b870335 100644 --- a/resources/locales/fr_WF/fr_WF.go +++ b/resources/locales/fr_WF/fr_WF.go @@ -1,36 +1,55 @@ package fr_WF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_WF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_WF' locale func New() locales.Translator { return &fr_WF{ - locale: "fr_WF", + locale: "fr_WF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fr_WF) Locale() string { - return l.locale +func (t *fr_WF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_WF' +func (t *fr_WF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_WF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_WF' +func (t *fr_WF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fr_YT/fr_YT.go b/resources/locales/fr_YT/fr_YT.go index 13557df..bbb58b7 100644 --- a/resources/locales/fr_YT/fr_YT.go +++ b/resources/locales/fr_YT/fr_YT.go @@ -1,36 +1,55 @@ package fr_YT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fr_YT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fr_YT' locale func New() locales.Translator { return &fr_YT{ - locale: "fr_YT", + locale: "fr_YT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fr_YT) Locale() string { - return l.locale +func (t *fr_YT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fr_YT' +func (t *fr_YT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fr_YT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fr_YT' +func (t *fr_YT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fur/fur.go b/resources/locales/fur/fur.go index 3fcb90d..690cc45 100644 --- a/resources/locales/fur/fur.go +++ b/resources/locales/fur/fur.go @@ -1,36 +1,54 @@ package fur import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fur struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fur' locale func New() locales.Translator { return &fur{ - locale: "fur", + locale: "fur", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fur) Locale() string { - return l.locale +func (t *fur) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fur' +func (t *fur) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fur) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fur' +func (t *fur) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fur_IT/fur_IT.go b/resources/locales/fur_IT/fur_IT.go index 952d6c7..a7536b3 100644 --- a/resources/locales/fur_IT/fur_IT.go +++ b/resources/locales/fur_IT/fur_IT.go @@ -1,36 +1,54 @@ package fur_IT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fur_IT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fur_IT' locale func New() locales.Translator { return &fur_IT{ - locale: "fur_IT", + locale: "fur_IT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fur_IT) Locale() string { - return l.locale +func (t *fur_IT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'fur_IT' +func (t *fur_IT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fur_IT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fur_IT' +func (t *fur_IT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fy/fy.go b/resources/locales/fy/fy.go index 1623424..a9fa657 100644 --- a/resources/locales/fy/fy.go +++ b/resources/locales/fy/fy.go @@ -1,38 +1,55 @@ package fy import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fy struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fy' locale func New() locales.Translator { return &fy{ - locale: "fy", + locale: "fy", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *fy) Locale() string { - return l.locale +func (t *fy) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fy) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fy' +func (t *fy) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fy' +func (t *fy) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/fy_NL/fy_NL.go b/resources/locales/fy_NL/fy_NL.go index 1f4bfb5..4156354 100644 --- a/resources/locales/fy_NL/fy_NL.go +++ b/resources/locales/fy_NL/fy_NL.go @@ -1,38 +1,55 @@ package fy_NL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type fy_NL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'fy_NL' locale func New() locales.Translator { return &fy_NL{ - locale: "fy_NL", + locale: "fy_NL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *fy_NL) Locale() string { - return l.locale +func (t *fy_NL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *fy_NL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'fy_NL' +func (t *fy_NL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'fy_NL' +func (t *fy_NL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ga/ga.go b/resources/locales/ga/ga.go index 910ca76..a206f4b 100644 --- a/resources/locales/ga/ga.go +++ b/resources/locales/ga/ga.go @@ -1,42 +1,60 @@ package ga import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ga struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ga' locale func New() locales.Translator { return &ga{ - locale: "ga", + locale: "ga", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ga) Locale() string { - return l.locale +func (t *ga) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ga' +func (t *ga) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ga) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ga' +func (t *ga) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n >= 3 && n <= 6 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n >= 7 && n <= 10 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ga_IE/ga_IE.go b/resources/locales/ga_IE/ga_IE.go index d460ce8..07a4c19 100644 --- a/resources/locales/ga_IE/ga_IE.go +++ b/resources/locales/ga_IE/ga_IE.go @@ -1,42 +1,60 @@ package ga_IE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ga_IE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ga_IE' locale func New() locales.Translator { return &ga_IE{ - locale: "ga_IE", + locale: "ga_IE", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ga_IE) Locale() string { - return l.locale +func (t *ga_IE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ga_IE' +func (t *ga_IE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ga_IE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ga_IE' +func (t *ga_IE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if n >= 3 && n <= 6 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n >= 7 && n <= 10 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gd/gd.go b/resources/locales/gd/gd.go index d6d8cf4..3a65acf 100644 --- a/resources/locales/gd/gd.go +++ b/resources/locales/gd/gd.go @@ -1,40 +1,58 @@ package gd import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gd struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gd' locale func New() locales.Translator { return &gd{ - locale: "gd", + locale: "gd", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0xe2, 0x80, 0x8f, 0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gd) Locale() string { - return l.locale +func (t *gd) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gd' +func (t *gd) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gd) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gd' +func (t *gd) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 || n == 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 || n == 12 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (n >= 3 && n <= 10) || (n >= 13 && n <= 19) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gd_GB/gd_GB.go b/resources/locales/gd_GB/gd_GB.go index 2c5bfba..8389c59 100644 --- a/resources/locales/gd_GB/gd_GB.go +++ b/resources/locales/gd_GB/gd_GB.go @@ -1,40 +1,58 @@ package gd_GB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gd_GB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gd_GB' locale func New() locales.Translator { return &gd_GB{ - locale: "gd_GB", + locale: "gd_GB", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *gd_GB) Locale() string { - return l.locale +func (t *gd_GB) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gd_GB' +func (t *gd_GB) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gd_GB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gd_GB' +func (t *gd_GB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 || n == 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 || n == 12 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (n >= 3 && n <= 10) || (n >= 13 && n <= 19) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gl/gl.go b/resources/locales/gl/gl.go index 7857e59..a9f7857 100644 --- a/resources/locales/gl/gl.go +++ b/resources/locales/gl/gl.go @@ -1,38 +1,55 @@ package gl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gl' locale func New() locales.Translator { return &gl{ - locale: "gl", + locale: "gl", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gl) Locale() string { - return l.locale +func (t *gl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gl' +func (t *gl) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gl' +func (t *gl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gl_ES/gl_ES.go b/resources/locales/gl_ES/gl_ES.go index 47656ee..a260ce9 100644 --- a/resources/locales/gl_ES/gl_ES.go +++ b/resources/locales/gl_ES/gl_ES.go @@ -1,38 +1,55 @@ package gl_ES import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gl_ES struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gl_ES' locale func New() locales.Translator { return &gl_ES{ - locale: "gl_ES", + locale: "gl_ES", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gl_ES) Locale() string { - return l.locale +func (t *gl_ES) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gl_ES) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gl_ES' +func (t *gl_ES) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gl_ES' +func (t *gl_ES) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gsw/gsw.go b/resources/locales/gsw/gsw.go index 48afabe..a1726f3 100644 --- a/resources/locales/gsw/gsw.go +++ b/resources/locales/gsw/gsw.go @@ -1,36 +1,54 @@ package gsw import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gsw struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gsw' locale func New() locales.Translator { return &gsw{ - locale: "gsw", + locale: "gsw", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0xe2, 0x80, 0x99}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gsw) Locale() string { - return l.locale +func (t *gsw) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gsw' +func (t *gsw) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gsw) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gsw' +func (t *gsw) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gsw_CH/gsw_CH.go b/resources/locales/gsw_CH/gsw_CH.go index 21a858d..65b4138 100644 --- a/resources/locales/gsw_CH/gsw_CH.go +++ b/resources/locales/gsw_CH/gsw_CH.go @@ -1,36 +1,54 @@ package gsw_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gsw_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gsw_CH' locale func New() locales.Translator { return &gsw_CH{ - locale: "gsw_CH", + locale: "gsw_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x39, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gsw_CH) Locale() string { - return l.locale +func (t *gsw_CH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gsw_CH' +func (t *gsw_CH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gsw_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gsw_CH' +func (t *gsw_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gsw_FR/gsw_FR.go b/resources/locales/gsw_FR/gsw_FR.go index e728ff3..d39666b 100644 --- a/resources/locales/gsw_FR/gsw_FR.go +++ b/resources/locales/gsw_FR/gsw_FR.go @@ -1,36 +1,54 @@ package gsw_FR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gsw_FR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gsw_FR' locale func New() locales.Translator { return &gsw_FR{ - locale: "gsw_FR", + locale: "gsw_FR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x39, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gsw_FR) Locale() string { - return l.locale +func (t *gsw_FR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gsw_FR' +func (t *gsw_FR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gsw_FR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gsw_FR' +func (t *gsw_FR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gsw_LI/gsw_LI.go b/resources/locales/gsw_LI/gsw_LI.go index 296f77d..698e7f1 100644 --- a/resources/locales/gsw_LI/gsw_LI.go +++ b/resources/locales/gsw_LI/gsw_LI.go @@ -1,36 +1,54 @@ package gsw_LI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gsw_LI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gsw_LI' locale func New() locales.Translator { return &gsw_LI{ - locale: "gsw_LI", + locale: "gsw_LI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x39, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *gsw_LI) Locale() string { - return l.locale +func (t *gsw_LI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'gsw_LI' +func (t *gsw_LI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gsw_LI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gsw_LI' +func (t *gsw_LI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gu/gu.go b/resources/locales/gu/gu.go index ca15d5a..cfa2ce2 100644 --- a/resources/locales/gu/gu.go +++ b/resources/locales/gu/gu.go @@ -1,41 +1,55 @@ package gu import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gu' locale func New() locales.Translator { return &gu{ - locale: "gu", + locale: "gu", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gu) Locale() string { - return l.locale +func (t *gu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gu' +func (t *gu) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gu' +func (t *gu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gu_IN/gu_IN.go b/resources/locales/gu_IN/gu_IN.go index 2631b10..89be69b 100644 --- a/resources/locales/gu_IN/gu_IN.go +++ b/resources/locales/gu_IN/gu_IN.go @@ -1,41 +1,55 @@ package gu_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gu_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gu_IN' locale func New() locales.Translator { return &gu_IN{ - locale: "gu_IN", + locale: "gu_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gu_IN) Locale() string { - return l.locale +func (t *gu_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gu_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gu_IN' +func (t *gu_IN) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gu_IN' +func (t *gu_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/guz/guz.go b/resources/locales/guz/guz.go index e984140..2591701 100644 --- a/resources/locales/guz/guz.go +++ b/resources/locales/guz/guz.go @@ -1,26 +1,43 @@ package guz -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type guz struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'guz' locale func New() locales.Translator { return &guz{ - locale: "guz", + locale: "guz", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *guz) Locale() string { - return l.locale +func (t *guz) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *guz) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'guz' +func (t *guz) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'guz' +func (t *guz) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/guz_KE/guz_KE.go b/resources/locales/guz_KE/guz_KE.go index 639c266..e48b1aa 100644 --- a/resources/locales/guz_KE/guz_KE.go +++ b/resources/locales/guz_KE/guz_KE.go @@ -1,26 +1,43 @@ package guz_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type guz_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'guz_KE' locale func New() locales.Translator { return &guz_KE{ - locale: "guz_KE", + locale: "guz_KE", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *guz_KE) Locale() string { - return l.locale +func (t *guz_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *guz_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'guz_KE' +func (t *guz_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'guz_KE' +func (t *guz_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/gv/gv.go b/resources/locales/gv/gv.go index 7da8994..085c3d3 100644 --- a/resources/locales/gv/gv.go +++ b/resources/locales/gv/gv.go @@ -1,44 +1,61 @@ package gv import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gv struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gv' locale func New() locales.Translator { return &gv{ - locale: "gv", + locale: "gv", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gv) Locale() string { - return l.locale +func (t *gv) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gv) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gv' +func (t *gv) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gv' +func (t *gv) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if v == 0 && (i%100 == 0 || i%100 == 20 || i%100 == 40 || i%100 == 60 || i%100 == 80) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/gv_IM/gv_IM.go b/resources/locales/gv_IM/gv_IM.go index c18da9f..3025992 100644 --- a/resources/locales/gv_IM/gv_IM.go +++ b/resources/locales/gv_IM/gv_IM.go @@ -1,44 +1,61 @@ package gv_IM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type gv_IM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'gv_IM' locale func New() locales.Translator { return &gv_IM{ - locale: "gv_IM", + locale: "gv_IM", + plurals: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *gv_IM) Locale() string { - return l.locale +func (t *gv_IM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *gv_IM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'gv_IM' +func (t *gv_IM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'gv_IM' +func (t *gv_IM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if v == 0 && (i%100 == 0 || i%100 == 20 || i%100 == 40 || i%100 == 60 || i%100 == 80) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ha/ha.go b/resources/locales/ha/ha.go index bf39bdf..81d8731 100644 --- a/resources/locales/ha/ha.go +++ b/resources/locales/ha/ha.go @@ -1,36 +1,54 @@ package ha import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ha struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ha' locale func New() locales.Translator { return &ha{ - locale: "ha", + locale: "ha", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ha) Locale() string { - return l.locale +func (t *ha) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ha' +func (t *ha) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ha) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ha' +func (t *ha) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ha_GH/ha_GH.go b/resources/locales/ha_GH/ha_GH.go index 9e38fb1..a97cf31 100644 --- a/resources/locales/ha_GH/ha_GH.go +++ b/resources/locales/ha_GH/ha_GH.go @@ -1,36 +1,54 @@ package ha_GH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ha_GH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ha_GH' locale func New() locales.Translator { return &ha_GH{ - locale: "ha_GH", + locale: "ha_GH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ha_GH) Locale() string { - return l.locale +func (t *ha_GH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ha_GH' +func (t *ha_GH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ha_GH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ha_GH' +func (t *ha_GH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ha_NE/ha_NE.go b/resources/locales/ha_NE/ha_NE.go index 3068423..eef8abd 100644 --- a/resources/locales/ha_NE/ha_NE.go +++ b/resources/locales/ha_NE/ha_NE.go @@ -1,36 +1,54 @@ package ha_NE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ha_NE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ha_NE' locale func New() locales.Translator { return &ha_NE{ - locale: "ha_NE", + locale: "ha_NE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ha_NE) Locale() string { - return l.locale +func (t *ha_NE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ha_NE' +func (t *ha_NE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ha_NE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ha_NE' +func (t *ha_NE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ha_NG/ha_NG.go b/resources/locales/ha_NG/ha_NG.go index 24f9d79..d6b919a 100644 --- a/resources/locales/ha_NG/ha_NG.go +++ b/resources/locales/ha_NG/ha_NG.go @@ -1,36 +1,54 @@ package ha_NG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ha_NG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ha_NG' locale func New() locales.Translator { return &ha_NG{ - locale: "ha_NG", + locale: "ha_NG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ha_NG) Locale() string { - return l.locale +func (t *ha_NG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ha_NG' +func (t *ha_NG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ha_NG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ha_NG' +func (t *ha_NG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/haw/haw.go b/resources/locales/haw/haw.go index 45fb1ef..6e3850a 100644 --- a/resources/locales/haw/haw.go +++ b/resources/locales/haw/haw.go @@ -1,36 +1,54 @@ package haw import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type haw struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'haw' locale func New() locales.Translator { return &haw{ - locale: "haw", + locale: "haw", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *haw) Locale() string { - return l.locale +func (t *haw) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'haw' +func (t *haw) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *haw) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'haw' +func (t *haw) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/haw_US/haw_US.go b/resources/locales/haw_US/haw_US.go index 06db245..3484e7f 100644 --- a/resources/locales/haw_US/haw_US.go +++ b/resources/locales/haw_US/haw_US.go @@ -1,36 +1,54 @@ package haw_US import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type haw_US struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'haw_US' locale func New() locales.Translator { return &haw_US{ - locale: "haw_US", + locale: "haw_US", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *haw_US) Locale() string { - return l.locale +func (t *haw_US) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'haw_US' +func (t *haw_US) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *haw_US) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'haw_US' +func (t *haw_US) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/he/he.go b/resources/locales/he/he.go index 438435f..7ef521d 100644 --- a/resources/locales/he/he.go +++ b/resources/locales/he/he.go @@ -1,47 +1,59 @@ package he import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type he struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'he' locale func New() locales.Translator { return &he{ - locale: "he", + locale: "he", + plurals: []locales.PluralRule{2, 3, 5, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0xe2, 0x80, 0x8e, 0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *he) Locale() string { - return l.locale +func (t *he) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *he) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'he' +func (t *he) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'he' +func (t *he) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i == 2 && v == 0 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if v == 0 && n < 0 && n > 10 && n%10 == 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/he_IL/he_IL.go b/resources/locales/he_IL/he_IL.go index 95a7122..bb47e82 100644 --- a/resources/locales/he_IL/he_IL.go +++ b/resources/locales/he_IL/he_IL.go @@ -1,47 +1,59 @@ package he_IL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type he_IL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'he_IL' locale func New() locales.Translator { return &he_IL{ - locale: "he_IL", + locale: "he_IL", + plurals: []locales.PluralRule{2, 3, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *he_IL) Locale() string { - return l.locale +func (t *he_IL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *he_IL) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'he_IL' +func (t *he_IL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'he_IL' +func (t *he_IL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i == 2 && v == 0 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if v == 0 && n < 0 && n > 10 && n%10 == 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hi/hi.go b/resources/locales/hi/hi.go index 13cf0c6..a48d7b0 100644 --- a/resources/locales/hi/hi.go +++ b/resources/locales/hi/hi.go @@ -1,41 +1,55 @@ package hi import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hi struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hi' locale func New() locales.Translator { return &hi{ - locale: "hi", + locale: "hi", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hi) Locale() string { - return l.locale +func (t *hi) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hi) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'hi' +func (t *hi) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hi' +func (t *hi) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hi_IN/hi_IN.go b/resources/locales/hi_IN/hi_IN.go index 653a48d..b623409 100644 --- a/resources/locales/hi_IN/hi_IN.go +++ b/resources/locales/hi_IN/hi_IN.go @@ -1,41 +1,55 @@ package hi_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hi_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hi_IN' locale func New() locales.Translator { return &hi_IN{ - locale: "hi_IN", + locale: "hi_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hi_IN) Locale() string { - return l.locale +func (t *hi_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hi_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'hi_IN' +func (t *hi_IN) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hi_IN' +func (t *hi_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hr/hr.go b/resources/locales/hr/hr.go index e3e0d76..fe09729 100644 --- a/resources/locales/hr/hr.go +++ b/resources/locales/hr/hr.go @@ -1,45 +1,58 @@ package hr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hr' locale func New() locales.Translator { return &hr{ - locale: "hr", + locale: "hr", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hr) Locale() string { - return l.locale +func (t *hr) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hr) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'hr' +func (t *hr) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hr' +func (t *hr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hr_BA/hr_BA.go b/resources/locales/hr_BA/hr_BA.go index 86292ae..3b7ad8e 100644 --- a/resources/locales/hr_BA/hr_BA.go +++ b/resources/locales/hr_BA/hr_BA.go @@ -1,45 +1,58 @@ package hr_BA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hr_BA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hr_BA' locale func New() locales.Translator { return &hr_BA{ - locale: "hr_BA", + locale: "hr_BA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *hr_BA) Locale() string { - return l.locale +func (t *hr_BA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hr_BA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'hr_BA' +func (t *hr_BA) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hr_BA' +func (t *hr_BA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hr_HR/hr_HR.go b/resources/locales/hr_HR/hr_HR.go index c291d5d..7b3544d 100644 --- a/resources/locales/hr_HR/hr_HR.go +++ b/resources/locales/hr_HR/hr_HR.go @@ -1,45 +1,58 @@ package hr_HR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hr_HR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hr_HR' locale func New() locales.Translator { return &hr_HR{ - locale: "hr_HR", + locale: "hr_HR", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *hr_HR) Locale() string { - return l.locale +func (t *hr_HR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hr_HR) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'hr_HR' +func (t *hr_HR) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hr_HR' +func (t *hr_HR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hsb/hsb.go b/resources/locales/hsb/hsb.go index 70487cd..d77da1d 100644 --- a/resources/locales/hsb/hsb.go +++ b/resources/locales/hsb/hsb.go @@ -1,47 +1,60 @@ package hsb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hsb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hsb' locale func New() locales.Translator { return &hsb{ - locale: "hsb", + locale: "hsb", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hsb) Locale() string { - return l.locale +func (t *hsb) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hsb) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'hsb' +func (t *hsb) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hsb' +func (t *hsb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%100 == 1) || (f%100 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%100 == 2) || (f%100 == 2) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (f%100 >= 3 && f%100 <= 4) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hsb_DE/hsb_DE.go b/resources/locales/hsb_DE/hsb_DE.go index 2fc451f..3cca5b5 100644 --- a/resources/locales/hsb_DE/hsb_DE.go +++ b/resources/locales/hsb_DE/hsb_DE.go @@ -1,47 +1,60 @@ package hsb_DE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hsb_DE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hsb_DE' locale func New() locales.Translator { return &hsb_DE{ - locale: "hsb_DE", + locale: "hsb_DE", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *hsb_DE) Locale() string { - return l.locale +func (t *hsb_DE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hsb_DE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'hsb_DE' +func (t *hsb_DE) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hsb_DE' +func (t *hsb_DE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%100 == 1) || (f%100 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%100 == 2) || (f%100 == 2) { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (f%100 >= 3 && f%100 <= 4) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hu/hu.go b/resources/locales/hu/hu.go index 5e83ed8..09b032b 100644 --- a/resources/locales/hu/hu.go +++ b/resources/locales/hu/hu.go @@ -1,36 +1,54 @@ package hu import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hu' locale func New() locales.Translator { return &hu{ - locale: "hu", + locale: "hu", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hu) Locale() string { - return l.locale +func (t *hu) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'hu' +func (t *hu) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hu' +func (t *hu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hu_HU/hu_HU.go b/resources/locales/hu_HU/hu_HU.go index 4dc6438..f517115 100644 --- a/resources/locales/hu_HU/hu_HU.go +++ b/resources/locales/hu_HU/hu_HU.go @@ -1,36 +1,54 @@ package hu_HU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hu_HU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hu_HU' locale func New() locales.Translator { return &hu_HU{ - locale: "hu_HU", + locale: "hu_HU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *hu_HU) Locale() string { - return l.locale +func (t *hu_HU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'hu_HU' +func (t *hu_HU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hu_HU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hu_HU' +func (t *hu_HU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hy/hy.go b/resources/locales/hy/hy.go index 3eee7f3..5459e02 100644 --- a/resources/locales/hy/hy.go +++ b/resources/locales/hy/hy.go @@ -1,36 +1,55 @@ package hy import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hy struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hy' locale func New() locales.Translator { return &hy{ - locale: "hy", + locale: "hy", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hy) Locale() string { - return l.locale +func (t *hy) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'hy' +func (t *hy) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hy) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hy' +func (t *hy) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/hy_AM/hy_AM.go b/resources/locales/hy_AM/hy_AM.go index 8d64f6a..605454b 100644 --- a/resources/locales/hy_AM/hy_AM.go +++ b/resources/locales/hy_AM/hy_AM.go @@ -1,36 +1,55 @@ package hy_AM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type hy_AM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'hy_AM' locale func New() locales.Translator { return &hy_AM{ - locale: "hy_AM", + locale: "hy_AM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *hy_AM) Locale() string { - return l.locale +func (t *hy_AM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'hy_AM' +func (t *hy_AM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *hy_AM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'hy_AM' +func (t *hy_AM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/id/id.go b/resources/locales/id/id.go index 7318ebc..871da8d 100644 --- a/resources/locales/id/id.go +++ b/resources/locales/id/id.go @@ -1,27 +1,43 @@ package id -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type id struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'id' locale func New() locales.Translator { return &id{ - locale: "id", + locale: "id", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *id) Locale() string { - return l.locale +func (t *id) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *id) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'id' +func (t *id) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'id' +func (t *id) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/id_ID/id_ID.go b/resources/locales/id_ID/id_ID.go index a6015b7..e9e8825 100644 --- a/resources/locales/id_ID/id_ID.go +++ b/resources/locales/id_ID/id_ID.go @@ -1,27 +1,43 @@ package id_ID -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type id_ID struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'id_ID' locale func New() locales.Translator { return &id_ID{ - locale: "id_ID", + locale: "id_ID", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *id_ID) Locale() string { - return l.locale +func (t *id_ID) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *id_ID) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'id_ID' +func (t *id_ID) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'id_ID' +func (t *id_ID) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ig/ig.go b/resources/locales/ig/ig.go index 9ec31d4..e3a3981 100644 --- a/resources/locales/ig/ig.go +++ b/resources/locales/ig/ig.go @@ -1,27 +1,43 @@ package ig -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ig struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ig' locale func New() locales.Translator { return &ig{ - locale: "ig", + locale: "ig", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ig) Locale() string { - return l.locale +func (t *ig) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ig) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ig' +func (t *ig) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ig' +func (t *ig) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ig_NG/ig_NG.go b/resources/locales/ig_NG/ig_NG.go index f271bcd..6a6f2a8 100644 --- a/resources/locales/ig_NG/ig_NG.go +++ b/resources/locales/ig_NG/ig_NG.go @@ -1,27 +1,43 @@ package ig_NG -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ig_NG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ig_NG' locale func New() locales.Translator { return &ig_NG{ - locale: "ig_NG", + locale: "ig_NG", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ig_NG) Locale() string { - return l.locale +func (t *ig_NG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ig_NG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ig_NG' +func (t *ig_NG) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ig_NG' +func (t *ig_NG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ii/ii.go b/resources/locales/ii/ii.go index 0fe684a..7e2cf62 100644 --- a/resources/locales/ii/ii.go +++ b/resources/locales/ii/ii.go @@ -1,27 +1,43 @@ package ii -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ii struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ii' locale func New() locales.Translator { return &ii{ - locale: "ii", + locale: "ii", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ii) Locale() string { - return l.locale +func (t *ii) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ii) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ii' +func (t *ii) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ii' +func (t *ii) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ii_CN/ii_CN.go b/resources/locales/ii_CN/ii_CN.go index 41b467e..d7a7637 100644 --- a/resources/locales/ii_CN/ii_CN.go +++ b/resources/locales/ii_CN/ii_CN.go @@ -1,27 +1,43 @@ package ii_CN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ii_CN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ii_CN' locale func New() locales.Translator { return &ii_CN{ - locale: "ii_CN", + locale: "ii_CN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ii_CN) Locale() string { - return l.locale +func (t *ii_CN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ii_CN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ii_CN' +func (t *ii_CN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ii_CN' +func (t *ii_CN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/is/is.go b/resources/locales/is/is.go index 81d67f8..0ebd749 100644 --- a/resources/locales/is/is.go +++ b/resources/locales/is/is.go @@ -1,41 +1,56 @@ package is import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type is struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'is' locale func New() locales.Translator { return &is{ - locale: "is", + locale: "is", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *is) Locale() string { - return l.locale +func (t *is) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *is) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'is' +func (t *is) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'is' +func (t *is) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) if (t == 0 && i%10 == 1 && i%100 != 11) || (t != 0) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/is_IS/is_IS.go b/resources/locales/is_IS/is_IS.go index d648eb4..907190b 100644 --- a/resources/locales/is_IS/is_IS.go +++ b/resources/locales/is_IS/is_IS.go @@ -1,41 +1,56 @@ package is_IS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type is_IS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'is_IS' locale func New() locales.Translator { return &is_IS{ - locale: "is_IS", + locale: "is_IS", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *is_IS) Locale() string { - return l.locale +func (t *is_IS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *is_IS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'is_IS' +func (t *is_IS) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'is_IS' +func (t *is_IS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - t, err := locales.T(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) if (t == 0 && i%10 == 1 && i%100 != 11) || (t != 0) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/it/it.go b/resources/locales/it/it.go index c4996d6..e8d9bde 100644 --- a/resources/locales/it/it.go +++ b/resources/locales/it/it.go @@ -1,38 +1,55 @@ package it import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type it struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'it' locale func New() locales.Translator { return &it{ - locale: "it", + locale: "it", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *it) Locale() string { - return l.locale +func (t *it) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *it) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'it' +func (t *it) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'it' +func (t *it) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/it_CH/it_CH.go b/resources/locales/it_CH/it_CH.go index 31bf759..44b373e 100644 --- a/resources/locales/it_CH/it_CH.go +++ b/resources/locales/it_CH/it_CH.go @@ -1,38 +1,55 @@ package it_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type it_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'it_CH' locale func New() locales.Translator { return &it_CH{ - locale: "it_CH", + locale: "it_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x27}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *it_CH) Locale() string { - return l.locale +func (t *it_CH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *it_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'it_CH' +func (t *it_CH) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'it_CH' +func (t *it_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/it_IT/it_IT.go b/resources/locales/it_IT/it_IT.go index 1cc30d0..10edd4f 100644 --- a/resources/locales/it_IT/it_IT.go +++ b/resources/locales/it_IT/it_IT.go @@ -1,38 +1,55 @@ package it_IT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type it_IT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'it_IT' locale func New() locales.Translator { return &it_IT{ - locale: "it_IT", + locale: "it_IT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *it_IT) Locale() string { - return l.locale +func (t *it_IT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *it_IT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'it_IT' +func (t *it_IT) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'it_IT' +func (t *it_IT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/it_SM/it_SM.go b/resources/locales/it_SM/it_SM.go index 95056db..46caeb1 100644 --- a/resources/locales/it_SM/it_SM.go +++ b/resources/locales/it_SM/it_SM.go @@ -1,38 +1,55 @@ package it_SM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type it_SM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'it_SM' locale func New() locales.Translator { return &it_SM{ - locale: "it_SM", + locale: "it_SM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *it_SM) Locale() string { - return l.locale +func (t *it_SM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *it_SM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'it_SM' +func (t *it_SM) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'it_SM' +func (t *it_SM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ja/ja.go b/resources/locales/ja/ja.go index d0472a0..6987360 100644 --- a/resources/locales/ja/ja.go +++ b/resources/locales/ja/ja.go @@ -1,27 +1,43 @@ package ja -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ja struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ja' locale func New() locales.Translator { return &ja{ - locale: "ja", + locale: "ja", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ja) Locale() string { - return l.locale +func (t *ja) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ja) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ja' +func (t *ja) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ja' +func (t *ja) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ja_JP/ja_JP.go b/resources/locales/ja_JP/ja_JP.go index b39d3c6..106d92c 100644 --- a/resources/locales/ja_JP/ja_JP.go +++ b/resources/locales/ja_JP/ja_JP.go @@ -1,27 +1,43 @@ package ja_JP -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ja_JP struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ja_JP' locale func New() locales.Translator { return &ja_JP{ - locale: "ja_JP", + locale: "ja_JP", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ja_JP) Locale() string { - return l.locale +func (t *ja_JP) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ja_JP) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ja_JP' +func (t *ja_JP) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ja_JP' +func (t *ja_JP) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/jgo/jgo.go b/resources/locales/jgo/jgo.go index fc75d0f..18b22fa 100644 --- a/resources/locales/jgo/jgo.go +++ b/resources/locales/jgo/jgo.go @@ -1,36 +1,54 @@ package jgo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type jgo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'jgo' locale func New() locales.Translator { return &jgo{ - locale: "jgo", + locale: "jgo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *jgo) Locale() string { - return l.locale +func (t *jgo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'jgo' +func (t *jgo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *jgo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'jgo' +func (t *jgo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/jgo_CM/jgo_CM.go b/resources/locales/jgo_CM/jgo_CM.go index 8ce2ae0..6a93f4e 100644 --- a/resources/locales/jgo_CM/jgo_CM.go +++ b/resources/locales/jgo_CM/jgo_CM.go @@ -1,36 +1,54 @@ package jgo_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type jgo_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'jgo_CM' locale func New() locales.Translator { return &jgo_CM{ - locale: "jgo_CM", + locale: "jgo_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *jgo_CM) Locale() string { - return l.locale +func (t *jgo_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'jgo_CM' +func (t *jgo_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *jgo_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'jgo_CM' +func (t *jgo_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/jmc/jmc.go b/resources/locales/jmc/jmc.go index d8c37d9..2e420b0 100644 --- a/resources/locales/jmc/jmc.go +++ b/resources/locales/jmc/jmc.go @@ -1,36 +1,54 @@ package jmc import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type jmc struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'jmc' locale func New() locales.Translator { return &jmc{ - locale: "jmc", + locale: "jmc", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *jmc) Locale() string { - return l.locale +func (t *jmc) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'jmc' +func (t *jmc) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *jmc) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'jmc' +func (t *jmc) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/jmc_TZ/jmc_TZ.go b/resources/locales/jmc_TZ/jmc_TZ.go index 53aa74d..33625f3 100644 --- a/resources/locales/jmc_TZ/jmc_TZ.go +++ b/resources/locales/jmc_TZ/jmc_TZ.go @@ -1,36 +1,54 @@ package jmc_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type jmc_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'jmc_TZ' locale func New() locales.Translator { return &jmc_TZ{ - locale: "jmc_TZ", + locale: "jmc_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *jmc_TZ) Locale() string { - return l.locale +func (t *jmc_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'jmc_TZ' +func (t *jmc_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *jmc_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'jmc_TZ' +func (t *jmc_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ka/ka.go b/resources/locales/ka/ka.go index c20eb55..6c55b44 100644 --- a/resources/locales/ka/ka.go +++ b/resources/locales/ka/ka.go @@ -1,36 +1,54 @@ package ka import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ka struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ka' locale func New() locales.Translator { return &ka{ - locale: "ka", + locale: "ka", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ka) Locale() string { - return l.locale +func (t *ka) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ka' +func (t *ka) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ka) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ka' +func (t *ka) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ka_GE/ka_GE.go b/resources/locales/ka_GE/ka_GE.go index 4d9059d..82382d6 100644 --- a/resources/locales/ka_GE/ka_GE.go +++ b/resources/locales/ka_GE/ka_GE.go @@ -1,36 +1,54 @@ package ka_GE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ka_GE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ka_GE' locale func New() locales.Translator { return &ka_GE{ - locale: "ka_GE", + locale: "ka_GE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ka_GE) Locale() string { - return l.locale +func (t *ka_GE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ka_GE' +func (t *ka_GE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ka_GE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ka_GE' +func (t *ka_GE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kab/kab.go b/resources/locales/kab/kab.go index 230c590..893bb47 100644 --- a/resources/locales/kab/kab.go +++ b/resources/locales/kab/kab.go @@ -1,36 +1,55 @@ package kab import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kab struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kab' locale func New() locales.Translator { return &kab{ - locale: "kab", + locale: "kab", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kab) Locale() string { - return l.locale +func (t *kab) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kab' +func (t *kab) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kab) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kab' +func (t *kab) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kab_DZ/kab_DZ.go b/resources/locales/kab_DZ/kab_DZ.go index f7e1b3c..945e41a 100644 --- a/resources/locales/kab_DZ/kab_DZ.go +++ b/resources/locales/kab_DZ/kab_DZ.go @@ -1,36 +1,55 @@ package kab_DZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kab_DZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kab_DZ' locale func New() locales.Translator { return &kab_DZ{ - locale: "kab_DZ", + locale: "kab_DZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kab_DZ) Locale() string { - return l.locale +func (t *kab_DZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kab_DZ' +func (t *kab_DZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kab_DZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kab_DZ' +func (t *kab_DZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 0 || i == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kam/kam.go b/resources/locales/kam/kam.go index b353592..4845861 100644 --- a/resources/locales/kam/kam.go +++ b/resources/locales/kam/kam.go @@ -1,26 +1,43 @@ package kam -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kam struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kam' locale func New() locales.Translator { return &kam{ - locale: "kam", + locale: "kam", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kam) Locale() string { - return l.locale +func (t *kam) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kam) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kam' +func (t *kam) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kam' +func (t *kam) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/kam_KE/kam_KE.go b/resources/locales/kam_KE/kam_KE.go index 3269b61..1eb3db4 100644 --- a/resources/locales/kam_KE/kam_KE.go +++ b/resources/locales/kam_KE/kam_KE.go @@ -1,26 +1,43 @@ package kam_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kam_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kam_KE' locale func New() locales.Translator { return &kam_KE{ - locale: "kam_KE", + locale: "kam_KE", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kam_KE) Locale() string { - return l.locale +func (t *kam_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kam_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kam_KE' +func (t *kam_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kam_KE' +func (t *kam_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/kde/kde.go b/resources/locales/kde/kde.go index 9e84cae..cab15f1 100644 --- a/resources/locales/kde/kde.go +++ b/resources/locales/kde/kde.go @@ -1,27 +1,43 @@ package kde -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kde struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kde' locale func New() locales.Translator { return &kde{ - locale: "kde", + locale: "kde", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kde) Locale() string { - return l.locale +func (t *kde) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kde) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kde' +func (t *kde) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kde' +func (t *kde) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/kde_TZ/kde_TZ.go b/resources/locales/kde_TZ/kde_TZ.go index 6aa316d..f196ddc 100644 --- a/resources/locales/kde_TZ/kde_TZ.go +++ b/resources/locales/kde_TZ/kde_TZ.go @@ -1,27 +1,43 @@ package kde_TZ -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kde_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kde_TZ' locale func New() locales.Translator { return &kde_TZ{ - locale: "kde_TZ", + locale: "kde_TZ", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kde_TZ) Locale() string { - return l.locale +func (t *kde_TZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kde_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kde_TZ' +func (t *kde_TZ) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kde_TZ' +func (t *kde_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/kea/kea.go b/resources/locales/kea/kea.go index 0b95347..f3a7cf1 100644 --- a/resources/locales/kea/kea.go +++ b/resources/locales/kea/kea.go @@ -1,27 +1,43 @@ package kea -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kea struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kea' locale func New() locales.Translator { return &kea{ - locale: "kea", + locale: "kea", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kea) Locale() string { - return l.locale +func (t *kea) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kea) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kea' +func (t *kea) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kea' +func (t *kea) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/kea_CV/kea_CV.go b/resources/locales/kea_CV/kea_CV.go index 74013f3..56255f6 100644 --- a/resources/locales/kea_CV/kea_CV.go +++ b/resources/locales/kea_CV/kea_CV.go @@ -1,27 +1,43 @@ package kea_CV -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kea_CV struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kea_CV' locale func New() locales.Translator { return &kea_CV{ - locale: "kea_CV", + locale: "kea_CV", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kea_CV) Locale() string { - return l.locale +func (t *kea_CV) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kea_CV) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kea_CV' +func (t *kea_CV) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kea_CV' +func (t *kea_CV) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/khq/khq.go b/resources/locales/khq/khq.go index 0921990..6c34028 100644 --- a/resources/locales/khq/khq.go +++ b/resources/locales/khq/khq.go @@ -1,26 +1,43 @@ package khq -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type khq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'khq' locale func New() locales.Translator { return &khq{ - locale: "khq", + locale: "khq", + plurals: nil, + decimal: []byte{}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *khq) Locale() string { - return l.locale +func (t *khq) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *khq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'khq' +func (t *khq) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'khq' +func (t *khq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/khq_ML/khq_ML.go b/resources/locales/khq_ML/khq_ML.go index 1dd0288..795067d 100644 --- a/resources/locales/khq_ML/khq_ML.go +++ b/resources/locales/khq_ML/khq_ML.go @@ -1,26 +1,43 @@ package khq_ML -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type khq_ML struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'khq_ML' locale func New() locales.Translator { return &khq_ML{ - locale: "khq_ML", + locale: "khq_ML", + plurals: nil, + decimal: []byte{}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *khq_ML) Locale() string { - return l.locale +func (t *khq_ML) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *khq_ML) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'khq_ML' +func (t *khq_ML) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'khq_ML' +func (t *khq_ML) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ki/ki.go b/resources/locales/ki/ki.go index de04f47..898b7b2 100644 --- a/resources/locales/ki/ki.go +++ b/resources/locales/ki/ki.go @@ -1,26 +1,43 @@ package ki -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ki struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ki' locale func New() locales.Translator { return &ki{ - locale: "ki", + locale: "ki", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ki) Locale() string { - return l.locale +func (t *ki) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ki) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ki' +func (t *ki) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ki' +func (t *ki) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ki_KE/ki_KE.go b/resources/locales/ki_KE/ki_KE.go index a7e14d7..cbf219e 100644 --- a/resources/locales/ki_KE/ki_KE.go +++ b/resources/locales/ki_KE/ki_KE.go @@ -1,26 +1,43 @@ package ki_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ki_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ki_KE' locale func New() locales.Translator { return &ki_KE{ - locale: "ki_KE", + locale: "ki_KE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ki_KE) Locale() string { - return l.locale +func (t *ki_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ki_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ki_KE' +func (t *ki_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ki_KE' +func (t *ki_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/kk/kk.go b/resources/locales/kk/kk.go index f39b56c..b5840f8 100644 --- a/resources/locales/kk/kk.go +++ b/resources/locales/kk/kk.go @@ -1,36 +1,54 @@ package kk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kk' locale func New() locales.Translator { return &kk{ - locale: "kk", + locale: "kk", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kk) Locale() string { - return l.locale +func (t *kk) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kk' +func (t *kk) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kk) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kk' +func (t *kk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kk_KZ/kk_KZ.go b/resources/locales/kk_KZ/kk_KZ.go index 2fb7453..904df39 100644 --- a/resources/locales/kk_KZ/kk_KZ.go +++ b/resources/locales/kk_KZ/kk_KZ.go @@ -1,36 +1,54 @@ package kk_KZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kk_KZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kk_KZ' locale func New() locales.Translator { return &kk_KZ{ - locale: "kk_KZ", + locale: "kk_KZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kk_KZ) Locale() string { - return l.locale +func (t *kk_KZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kk_KZ' +func (t *kk_KZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kk_KZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kk_KZ' +func (t *kk_KZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kkj/kkj.go b/resources/locales/kkj/kkj.go index 0ede1bb..0ef7db0 100644 --- a/resources/locales/kkj/kkj.go +++ b/resources/locales/kkj/kkj.go @@ -1,36 +1,54 @@ package kkj import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kkj struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kkj' locale func New() locales.Translator { return &kkj{ - locale: "kkj", + locale: "kkj", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kkj) Locale() string { - return l.locale +func (t *kkj) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kkj' +func (t *kkj) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kkj) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kkj' +func (t *kkj) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kkj_CM/kkj_CM.go b/resources/locales/kkj_CM/kkj_CM.go index 479277a..19121f8 100644 --- a/resources/locales/kkj_CM/kkj_CM.go +++ b/resources/locales/kkj_CM/kkj_CM.go @@ -1,36 +1,54 @@ package kkj_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kkj_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kkj_CM' locale func New() locales.Translator { return &kkj_CM{ - locale: "kkj_CM", + locale: "kkj_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kkj_CM) Locale() string { - return l.locale +func (t *kkj_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kkj_CM' +func (t *kkj_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kkj_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kkj_CM' +func (t *kkj_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kl/kl.go b/resources/locales/kl/kl.go index a8f5e6f..32c6a47 100644 --- a/resources/locales/kl/kl.go +++ b/resources/locales/kl/kl.go @@ -1,36 +1,54 @@ package kl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kl' locale func New() locales.Translator { return &kl{ - locale: "kl", + locale: "kl", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kl) Locale() string { - return l.locale +func (t *kl) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kl' +func (t *kl) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kl' +func (t *kl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kl_GL/kl_GL.go b/resources/locales/kl_GL/kl_GL.go index a477cfe..f94b470 100644 --- a/resources/locales/kl_GL/kl_GL.go +++ b/resources/locales/kl_GL/kl_GL.go @@ -1,36 +1,54 @@ package kl_GL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kl_GL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kl_GL' locale func New() locales.Translator { return &kl_GL{ - locale: "kl_GL", + locale: "kl_GL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kl_GL) Locale() string { - return l.locale +func (t *kl_GL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kl_GL' +func (t *kl_GL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kl_GL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kl_GL' +func (t *kl_GL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kln/kln.go b/resources/locales/kln/kln.go index 236eeed..a260378 100644 --- a/resources/locales/kln/kln.go +++ b/resources/locales/kln/kln.go @@ -1,26 +1,43 @@ package kln -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kln struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kln' locale func New() locales.Translator { return &kln{ - locale: "kln", + locale: "kln", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kln) Locale() string { - return l.locale +func (t *kln) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kln) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kln' +func (t *kln) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kln' +func (t *kln) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/kln_KE/kln_KE.go b/resources/locales/kln_KE/kln_KE.go index 9fd2fb2..6fd081e 100644 --- a/resources/locales/kln_KE/kln_KE.go +++ b/resources/locales/kln_KE/kln_KE.go @@ -1,26 +1,43 @@ package kln_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kln_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kln_KE' locale func New() locales.Translator { return &kln_KE{ - locale: "kln_KE", + locale: "kln_KE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kln_KE) Locale() string { - return l.locale +func (t *kln_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kln_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kln_KE' +func (t *kln_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kln_KE' +func (t *kln_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/km/km.go b/resources/locales/km/km.go index ab50b8f..e1c7156 100644 --- a/resources/locales/km/km.go +++ b/resources/locales/km/km.go @@ -1,27 +1,43 @@ package km -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type km struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'km' locale func New() locales.Translator { return &km{ - locale: "km", + locale: "km", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *km) Locale() string { - return l.locale +func (t *km) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *km) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'km' +func (t *km) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'km' +func (t *km) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/km_KH/km_KH.go b/resources/locales/km_KH/km_KH.go index 3d19f29..23e3d44 100644 --- a/resources/locales/km_KH/km_KH.go +++ b/resources/locales/km_KH/km_KH.go @@ -1,27 +1,43 @@ package km_KH -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type km_KH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'km_KH' locale func New() locales.Translator { return &km_KH{ - locale: "km_KH", + locale: "km_KH", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *km_KH) Locale() string { - return l.locale +func (t *km_KH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *km_KH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'km_KH' +func (t *km_KH) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'km_KH' +func (t *km_KH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/kn/kn.go b/resources/locales/kn/kn.go index 49bb474..981fef5 100644 --- a/resources/locales/kn/kn.go +++ b/resources/locales/kn/kn.go @@ -1,41 +1,55 @@ package kn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kn' locale func New() locales.Translator { return &kn{ - locale: "kn", + locale: "kn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kn) Locale() string { - return l.locale +func (t *kn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kn' +func (t *kn) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kn' +func (t *kn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kn_IN/kn_IN.go b/resources/locales/kn_IN/kn_IN.go index 54577ee..cea7597 100644 --- a/resources/locales/kn_IN/kn_IN.go +++ b/resources/locales/kn_IN/kn_IN.go @@ -1,41 +1,55 @@ package kn_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kn_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kn_IN' locale func New() locales.Translator { return &kn_IN{ - locale: "kn_IN", + locale: "kn_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kn_IN) Locale() string { - return l.locale +func (t *kn_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kn_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kn_IN' +func (t *kn_IN) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kn_IN' +func (t *kn_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ko/ko.go b/resources/locales/ko/ko.go index beae37a..f2896c0 100644 --- a/resources/locales/ko/ko.go +++ b/resources/locales/ko/ko.go @@ -1,27 +1,43 @@ package ko -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ko struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ko' locale func New() locales.Translator { return &ko{ - locale: "ko", + locale: "ko", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ko) Locale() string { - return l.locale +func (t *ko) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ko) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ko' +func (t *ko) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ko' +func (t *ko) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ko_KP/ko_KP.go b/resources/locales/ko_KP/ko_KP.go index 38ef888..4d7e484 100644 --- a/resources/locales/ko_KP/ko_KP.go +++ b/resources/locales/ko_KP/ko_KP.go @@ -1,27 +1,43 @@ package ko_KP -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ko_KP struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ko_KP' locale func New() locales.Translator { return &ko_KP{ - locale: "ko_KP", + locale: "ko_KP", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ko_KP) Locale() string { - return l.locale +func (t *ko_KP) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ko_KP) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ko_KP' +func (t *ko_KP) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ko_KP' +func (t *ko_KP) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ko_KR/ko_KR.go b/resources/locales/ko_KR/ko_KR.go index 0858f92..bfe5df2 100644 --- a/resources/locales/ko_KR/ko_KR.go +++ b/resources/locales/ko_KR/ko_KR.go @@ -1,27 +1,43 @@ package ko_KR -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ko_KR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ko_KR' locale func New() locales.Translator { return &ko_KR{ - locale: "ko_KR", + locale: "ko_KR", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ko_KR) Locale() string { - return l.locale +func (t *ko_KR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ko_KR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ko_KR' +func (t *ko_KR) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ko_KR' +func (t *ko_KR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/kok/kok.go b/resources/locales/kok/kok.go index e34ce44..61c9408 100644 --- a/resources/locales/kok/kok.go +++ b/resources/locales/kok/kok.go @@ -1,26 +1,43 @@ package kok -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kok struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kok' locale func New() locales.Translator { return &kok{ - locale: "kok", + locale: "kok", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kok) Locale() string { - return l.locale +func (t *kok) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kok) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kok' +func (t *kok) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kok' +func (t *kok) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/kok_IN/kok_IN.go b/resources/locales/kok_IN/kok_IN.go index fb307db..9ca67ef 100644 --- a/resources/locales/kok_IN/kok_IN.go +++ b/resources/locales/kok_IN/kok_IN.go @@ -1,26 +1,43 @@ package kok_IN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type kok_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kok_IN' locale func New() locales.Translator { return &kok_IN{ - locale: "kok_IN", + locale: "kok_IN", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kok_IN) Locale() string { - return l.locale +func (t *kok_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kok_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'kok_IN' +func (t *kok_IN) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kok_IN' +func (t *kok_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ks/ks.go b/resources/locales/ks/ks.go index 2b21f36..6daff56 100644 --- a/resources/locales/ks/ks.go +++ b/resources/locales/ks/ks.go @@ -1,36 +1,54 @@ package ks import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ks struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ks' locale func New() locales.Translator { return &ks{ - locale: "ks", + locale: "ks", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0xe2, 0x80, 0x8e, 0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ks) Locale() string { - return l.locale +func (t *ks) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ks' +func (t *ks) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ks) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ks' +func (t *ks) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ks_IN/ks_IN.go b/resources/locales/ks_IN/ks_IN.go index 2c6673c..9768371 100644 --- a/resources/locales/ks_IN/ks_IN.go +++ b/resources/locales/ks_IN/ks_IN.go @@ -1,36 +1,54 @@ package ks_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ks_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ks_IN' locale func New() locales.Translator { return &ks_IN{ - locale: "ks_IN", + locale: "ks_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ks_IN) Locale() string { - return l.locale +func (t *ks_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ks_IN' +func (t *ks_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ks_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ks_IN' +func (t *ks_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ksb/ksb.go b/resources/locales/ksb/ksb.go index 4f5bce8..fed7fe6 100644 --- a/resources/locales/ksb/ksb.go +++ b/resources/locales/ksb/ksb.go @@ -1,36 +1,54 @@ package ksb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ksb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksb' locale func New() locales.Translator { return &ksb{ - locale: "ksb", + locale: "ksb", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ksb) Locale() string { - return l.locale +func (t *ksb) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ksb' +func (t *ksb) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksb) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksb' +func (t *ksb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ksb_TZ/ksb_TZ.go b/resources/locales/ksb_TZ/ksb_TZ.go index 8af99f5..411bc43 100644 --- a/resources/locales/ksb_TZ/ksb_TZ.go +++ b/resources/locales/ksb_TZ/ksb_TZ.go @@ -1,36 +1,54 @@ package ksb_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ksb_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksb_TZ' locale func New() locales.Translator { return &ksb_TZ{ - locale: "ksb_TZ", + locale: "ksb_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ksb_TZ) Locale() string { - return l.locale +func (t *ksb_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ksb_TZ' +func (t *ksb_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksb_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksb_TZ' +func (t *ksb_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ksf/ksf.go b/resources/locales/ksf/ksf.go index 1d2bd94..d274369 100644 --- a/resources/locales/ksf/ksf.go +++ b/resources/locales/ksf/ksf.go @@ -1,26 +1,43 @@ package ksf -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ksf struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksf' locale func New() locales.Translator { return &ksf{ - locale: "ksf", + locale: "ksf", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ksf) Locale() string { - return l.locale +func (t *ksf) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksf) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ksf' +func (t *ksf) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksf' +func (t *ksf) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ksf_CM/ksf_CM.go b/resources/locales/ksf_CM/ksf_CM.go index 48d6453..8368e21 100644 --- a/resources/locales/ksf_CM/ksf_CM.go +++ b/resources/locales/ksf_CM/ksf_CM.go @@ -1,26 +1,43 @@ package ksf_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ksf_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksf_CM' locale func New() locales.Translator { return &ksf_CM{ - locale: "ksf_CM", + locale: "ksf_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ksf_CM) Locale() string { - return l.locale +func (t *ksf_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksf_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ksf_CM' +func (t *ksf_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksf_CM' +func (t *ksf_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ksh/ksh.go b/resources/locales/ksh/ksh.go index 600eec0..f431457 100644 --- a/resources/locales/ksh/ksh.go +++ b/resources/locales/ksh/ksh.go @@ -1,38 +1,56 @@ package ksh import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ksh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksh' locale func New() locales.Translator { return &ksh{ - locale: "ksh", + locale: "ksh", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ksh) Locale() string { - return l.locale +func (t *ksh) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ksh' +func (t *ksh) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksh' +func (t *ksh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ksh_DE/ksh_DE.go b/resources/locales/ksh_DE/ksh_DE.go index 028e48a..382ea5d 100644 --- a/resources/locales/ksh_DE/ksh_DE.go +++ b/resources/locales/ksh_DE/ksh_DE.go @@ -1,38 +1,56 @@ package ksh_DE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ksh_DE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ksh_DE' locale func New() locales.Translator { return &ksh_DE{ - locale: "ksh_DE", + locale: "ksh_DE", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ksh_DE) Locale() string { - return l.locale +func (t *ksh_DE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ksh_DE' +func (t *ksh_DE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ksh_DE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ksh_DE' +func (t *ksh_DE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kw/kw.go b/resources/locales/kw/kw.go index 09ace32..366cb16 100644 --- a/resources/locales/kw/kw.go +++ b/resources/locales/kw/kw.go @@ -1,38 +1,56 @@ package kw import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kw struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kw' locale func New() locales.Translator { return &kw{ - locale: "kw", + locale: "kw", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *kw) Locale() string { - return l.locale +func (t *kw) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kw' +func (t *kw) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kw) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kw' +func (t *kw) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/kw_GB/kw_GB.go b/resources/locales/kw_GB/kw_GB.go index 4857edb..3cbca7c 100644 --- a/resources/locales/kw_GB/kw_GB.go +++ b/resources/locales/kw_GB/kw_GB.go @@ -1,38 +1,56 @@ package kw_GB import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type kw_GB struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'kw_GB' locale func New() locales.Translator { return &kw_GB{ - locale: "kw_GB", + locale: "kw_GB", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *kw_GB) Locale() string { - return l.locale +func (t *kw_GB) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'kw_GB' +func (t *kw_GB) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *kw_GB) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'kw_GB' +func (t *kw_GB) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ky/ky.go b/resources/locales/ky/ky.go index 6a47baa..572ff84 100644 --- a/resources/locales/ky/ky.go +++ b/resources/locales/ky/ky.go @@ -1,36 +1,54 @@ package ky import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ky struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ky' locale func New() locales.Translator { return &ky{ - locale: "ky", + locale: "ky", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ky) Locale() string { - return l.locale +func (t *ky) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ky' +func (t *ky) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ky) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ky' +func (t *ky) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ky_KG/ky_KG.go b/resources/locales/ky_KG/ky_KG.go index 3f436ee..37e38e6 100644 --- a/resources/locales/ky_KG/ky_KG.go +++ b/resources/locales/ky_KG/ky_KG.go @@ -1,36 +1,54 @@ package ky_KG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ky_KG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ky_KG' locale func New() locales.Translator { return &ky_KG{ - locale: "ky_KG", + locale: "ky_KG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ky_KG) Locale() string { - return l.locale +func (t *ky_KG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ky_KG' +func (t *ky_KG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ky_KG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ky_KG' +func (t *ky_KG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lag/lag.go b/resources/locales/lag/lag.go index f744061..c944d82 100644 --- a/resources/locales/lag/lag.go +++ b/resources/locales/lag/lag.go @@ -1,43 +1,57 @@ package lag import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lag struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lag' locale func New() locales.Translator { return &lag{ - locale: "lag", + locale: "lag", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lag) Locale() string { - return l.locale +func (t *lag) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lag) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lag' +func (t *lag) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lag' +func (t *lag) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (i == 0 || i == 1) && n != 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lag_TZ/lag_TZ.go b/resources/locales/lag_TZ/lag_TZ.go index 4430d83..ffddc5b 100644 --- a/resources/locales/lag_TZ/lag_TZ.go +++ b/resources/locales/lag_TZ/lag_TZ.go @@ -1,43 +1,57 @@ package lag_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lag_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lag_TZ' locale func New() locales.Translator { return &lag_TZ{ - locale: "lag_TZ", + locale: "lag_TZ", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *lag_TZ) Locale() string { - return l.locale +func (t *lag_TZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lag_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lag_TZ' +func (t *lag_TZ) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lag_TZ' +func (t *lag_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if n == 0 { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (i == 0 || i == 1) && n != 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lb/lb.go b/resources/locales/lb/lb.go index 2ce8dd3..dd98236 100644 --- a/resources/locales/lb/lb.go +++ b/resources/locales/lb/lb.go @@ -1,36 +1,54 @@ package lb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lb' locale func New() locales.Translator { return &lb{ - locale: "lb", + locale: "lb", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lb) Locale() string { - return l.locale +func (t *lb) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'lb' +func (t *lb) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lb) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lb' +func (t *lb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lb_LU/lb_LU.go b/resources/locales/lb_LU/lb_LU.go index 717115d..2e9db9c 100644 --- a/resources/locales/lb_LU/lb_LU.go +++ b/resources/locales/lb_LU/lb_LU.go @@ -1,36 +1,54 @@ package lb_LU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lb_LU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lb_LU' locale func New() locales.Translator { return &lb_LU{ - locale: "lb_LU", + locale: "lb_LU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lb_LU) Locale() string { - return l.locale +func (t *lb_LU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'lb_LU' +func (t *lb_LU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lb_LU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lb_LU' +func (t *lb_LU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lg/lg.go b/resources/locales/lg/lg.go index d9067b5..067ee6b 100644 --- a/resources/locales/lg/lg.go +++ b/resources/locales/lg/lg.go @@ -1,36 +1,54 @@ package lg import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lg' locale func New() locales.Translator { return &lg{ - locale: "lg", + locale: "lg", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lg) Locale() string { - return l.locale +func (t *lg) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'lg' +func (t *lg) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lg' +func (t *lg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lg_UG/lg_UG.go b/resources/locales/lg_UG/lg_UG.go index a79fc59..50c5d36 100644 --- a/resources/locales/lg_UG/lg_UG.go +++ b/resources/locales/lg_UG/lg_UG.go @@ -1,36 +1,54 @@ package lg_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lg_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lg_UG' locale func New() locales.Translator { return &lg_UG{ - locale: "lg_UG", + locale: "lg_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lg_UG) Locale() string { - return l.locale +func (t *lg_UG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'lg_UG' +func (t *lg_UG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lg_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lg_UG' +func (t *lg_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lkt/lkt.go b/resources/locales/lkt/lkt.go index 8a50203..3e69ffd 100644 --- a/resources/locales/lkt/lkt.go +++ b/resources/locales/lkt/lkt.go @@ -1,27 +1,43 @@ package lkt -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lkt struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lkt' locale func New() locales.Translator { return &lkt{ - locale: "lkt", + locale: "lkt", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lkt) Locale() string { - return l.locale +func (t *lkt) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lkt) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lkt' +func (t *lkt) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lkt' +func (t *lkt) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/lkt_US/lkt_US.go b/resources/locales/lkt_US/lkt_US.go index b344366..86bcc98 100644 --- a/resources/locales/lkt_US/lkt_US.go +++ b/resources/locales/lkt_US/lkt_US.go @@ -1,27 +1,43 @@ package lkt_US -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lkt_US struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lkt_US' locale func New() locales.Translator { return &lkt_US{ - locale: "lkt_US", + locale: "lkt_US", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lkt_US) Locale() string { - return l.locale +func (t *lkt_US) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lkt_US) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lkt_US' +func (t *lkt_US) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lkt_US' +func (t *lkt_US) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ln/ln.go b/resources/locales/ln/ln.go index 4eb34ac..2c0a5eb 100644 --- a/resources/locales/ln/ln.go +++ b/resources/locales/ln/ln.go @@ -1,36 +1,54 @@ package ln import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ln struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ln' locale func New() locales.Translator { return &ln{ - locale: "ln", + locale: "ln", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ln) Locale() string { - return l.locale +func (t *ln) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ln' +func (t *ln) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ln) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ln' +func (t *ln) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ln_AO/ln_AO.go b/resources/locales/ln_AO/ln_AO.go index b8c9e63..28f38fe 100644 --- a/resources/locales/ln_AO/ln_AO.go +++ b/resources/locales/ln_AO/ln_AO.go @@ -1,36 +1,54 @@ package ln_AO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ln_AO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ln_AO' locale func New() locales.Translator { return &ln_AO{ - locale: "ln_AO", + locale: "ln_AO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ln_AO) Locale() string { - return l.locale +func (t *ln_AO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ln_AO' +func (t *ln_AO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ln_AO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ln_AO' +func (t *ln_AO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ln_CD/ln_CD.go b/resources/locales/ln_CD/ln_CD.go index cc161b7..d181908 100644 --- a/resources/locales/ln_CD/ln_CD.go +++ b/resources/locales/ln_CD/ln_CD.go @@ -1,36 +1,54 @@ package ln_CD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ln_CD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ln_CD' locale func New() locales.Translator { return &ln_CD{ - locale: "ln_CD", + locale: "ln_CD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ln_CD) Locale() string { - return l.locale +func (t *ln_CD) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ln_CD' +func (t *ln_CD) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ln_CD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ln_CD' +func (t *ln_CD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ln_CF/ln_CF.go b/resources/locales/ln_CF/ln_CF.go index 8378752..6125a20 100644 --- a/resources/locales/ln_CF/ln_CF.go +++ b/resources/locales/ln_CF/ln_CF.go @@ -1,36 +1,54 @@ package ln_CF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ln_CF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ln_CF' locale func New() locales.Translator { return &ln_CF{ - locale: "ln_CF", + locale: "ln_CF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ln_CF) Locale() string { - return l.locale +func (t *ln_CF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ln_CF' +func (t *ln_CF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ln_CF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ln_CF' +func (t *ln_CF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ln_CG/ln_CG.go b/resources/locales/ln_CG/ln_CG.go index 83925b7..b46cf37 100644 --- a/resources/locales/ln_CG/ln_CG.go +++ b/resources/locales/ln_CG/ln_CG.go @@ -1,36 +1,54 @@ package ln_CG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ln_CG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ln_CG' locale func New() locales.Translator { return &ln_CG{ - locale: "ln_CG", + locale: "ln_CG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ln_CG) Locale() string { - return l.locale +func (t *ln_CG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ln_CG' +func (t *ln_CG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ln_CG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ln_CG' +func (t *ln_CG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lo/lo.go b/resources/locales/lo/lo.go index d3920f1..900b647 100644 --- a/resources/locales/lo/lo.go +++ b/resources/locales/lo/lo.go @@ -1,27 +1,43 @@ package lo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lo' locale func New() locales.Translator { return &lo{ - locale: "lo", + locale: "lo", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lo) Locale() string { - return l.locale +func (t *lo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lo' +func (t *lo) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lo' +func (t *lo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/lo_LA/lo_LA.go b/resources/locales/lo_LA/lo_LA.go index d79b827..a090474 100644 --- a/resources/locales/lo_LA/lo_LA.go +++ b/resources/locales/lo_LA/lo_LA.go @@ -1,27 +1,43 @@ package lo_LA -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lo_LA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lo_LA' locale func New() locales.Translator { return &lo_LA{ - locale: "lo_LA", + locale: "lo_LA", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *lo_LA) Locale() string { - return l.locale +func (t *lo_LA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lo_LA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lo_LA' +func (t *lo_LA) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lo_LA' +func (t *lo_LA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/locale_info.go b/resources/locales/locale_info.go index 6aede51..1397410 100644 --- a/resources/locales/locale_info.go +++ b/resources/locales/locale_info.go @@ -1,24 +1,20 @@ package locales -import ( - "fmt" - "strconv" - "strings" -) +import "strconv" -// ErrBadNumberValue is returned when the number passed for -// plural rule determination cannot be parsed -type ErrBadNumberValue struct { - NumberValue string - InnerError error -} +// // ErrBadNumberValue is returned when the number passed for +// // plural rule determination cannot be parsed +// type ErrBadNumberValue struct { +// NumberValue string +// InnerError error +// } -// Error returns ErrBadNumberValue error string -func (e *ErrBadNumberValue) Error() string { - return fmt.Sprintf("Invalid Number Value '%s' %s", e.NumberValue, e.InnerError) -} +// // Error returns ErrBadNumberValue error string +// func (e *ErrBadNumberValue) Error() string { +// return fmt.Sprintf("Invalid Number Value '%s' %s", e.NumberValue, e.InnerError) +// } -var _ error = new(ErrBadNumberValue) +// var _ error = new(ErrBadNumberValue) // PluralRule denotes the type of plural rules type PluralRule int @@ -34,133 +30,155 @@ const ( PluralRuleOther // other - required—general plural form—also used if the language only has a single form ) +const ( + pluralsString = "UnknownZeroOneTwoFewManyOther" +) + // Translator encapsulates an instance of type Translator interface { - Locale() string -} -// PluralStringToInt returns the enum value of 'plural' provided -func PluralStringToInt(plural string) PluralRule { - - switch plural { - case "zero": - return PluralRuleZero - case "one": - return PluralRuleOne - case "two": - return PluralRuleTwo - case "few": - return PluralRuleFew - case "many": - return PluralRuleMany - case "other": - return PluralRuleOther - default: - return PluralRuleUnknown - } -} - -// N returns the absolute value of the source number (integer and decimals). -func N(num string) (float64, error) { - - if num[0] == '-' { - num = num[1:] - } - - f, err := strconv.ParseFloat(num, 64) - if err != nil { - return 0, err - } + // Locale returns the string value of the translator + Locale() string - return f, nil + // Plurals returns an array of plural rules associated + // with this translator + Plurals() []PluralRule } -// I returns the integer digits of N. -func I(num string) (int64, error) { - - i, err := strconv.ParseInt(num, 10, 64) - if err != nil { - return 0, err +// String returns the string value of PluralRule +func (p PluralRule) String() string { + + switch p { + case PluralRuleZero: + return pluralsString[7:11] + case PluralRuleOne: + return pluralsString[11:14] + case PluralRuleTwo: + return pluralsString[14:17] + case PluralRuleFew: + return pluralsString[17:20] + case PluralRuleMany: + return pluralsString[20:24] + case PluralRuleOther: + return pluralsString[24:] + default: + return pluralsString[:7] } - - return i, nil } -// V returns the number of visible fraction digits in N, with trailing zeros. -func V(num string) (v int64) { - - idx := strings.Index(num, ".") - - if idx != -1 { - v = int64(len(num[idx+1:])) - } - - return -} +// +// Precision Notes: +// +// must specify a precision >= 0, and here is why https://play.golang.org/p/LyL90U0Vyh +// +// v := float64(3.141) +// i := float64(int64(v)) +// +// fmt.Println(v - i) +// +// or +// +// s := strconv.FormatFloat(v-i, 'f', -1, 64) +// fmt.Println(s) +// +// these will not print what you'd expect: 0.14100000000000001 +// and so this library requires a precision to be specified, or +// inaccurate plural rules could be applied. +// +// +// +// n - absolute value of the source number (integer and decimals). +// i - integer digits of n. +// v - number of visible fraction digits in n, with trailing zeros. +// w - number of visible fraction digits in n, without trailing zeros. +// f - visible fractional digits in n, with trailing zeros. +// t - visible fractional digits in n, without trailing zeros. +// +// +// Func(num float64, v uint64) // v = digits/precision and prevents -1 as a special case as this can lead to very unexpected behaviour, see precision note's above. +// +// n := math.Abs(num) +// i := int64(n) +// v := v +// +// +// w := strconv.FormatFloat(num-float64(i), 'f', int(v), 64) // then parse backwards on string until no more zero's.... +// f := strconv.FormatFloat(n, 'f', int(v), 64) // then turn everything after decimal into an int64 +// t := strconv.FormatFloat(n, 'f', int(v), 64) // then parse backwards on string until no more zero's.... +// +// +// +// General Inclusion Rules +// - v will always be available inherently +// - all require n +// - w requires i +// // W returns the number of visible fraction digits in N, without trailing zeros. -func W(num string) (w int64, err error) { +func W(n float64, v uint64) (w int64) { - idx := strings.Index(num, ".") + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) - if idx != -1 { + // with either be '0' or '0.xxxx', so if 1 then w will be zero + // otherwise need to parse + if len(s) != 1 { - idx++ - end := len(num[idx:]) + 1 + s = s[2:] + end := len(s) + 1 for i := end; i >= 0; i-- { - if num[i] != '0' { + if s[i] != '0' { end = i + 1 break } } - w = int64(len(num[idx:end])) + w = int64(len(s[:end])) } - return w, nil + return } // F returns the visible fractional digits in N, with trailing zeros. -func F(num string) (w int64, err error) { +func F(n float64, v uint64) (f int64) { - idx := strings.Index(num, ".") + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) - if idx != -1 { + // with either be '0' or '0.xxxx', so if 1 then f will be zero + // otherwise need to parse + if len(s) != 1 { - w, err = strconv.ParseInt(num[idx+1:], 10, 64) - if err != nil { - return - } + // ignoring error, because it can't fail as we generated + // the string internally from a real number + f, _ = strconv.ParseInt(s[2:], 10, 64) } return } // T returns the visible fractional digits in N, without trailing zeros. -func T(num string) (t int64, err error) { +func T(n float64, v uint64) (t int64) { - idx := strings.Index(num, ".") + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) - if idx != -1 { + // with either be '0' or '0.xxxx', so if 1 then t will be zero + // otherwise need to parse + if len(s) != 1 { - idx++ - end := len(num[idx:]) + 1 + s = s[2:] + end := len(s) + 1 for i := end; i >= 0; i-- { - if num[i] != '0' { + if s[i] != '0' { end = i + 1 break } } - t, err = strconv.ParseInt(num[idx:end], 10, 64) - if err != nil { - return - } - - t = int64(t) + // ignoring error, because it can't fail as we generated + // the string internally from a real number + t, _ = strconv.ParseInt(s[:end], 10, 64) } - return t, nil + return } diff --git a/resources/locales/lrc/lrc.go b/resources/locales/lrc/lrc.go index 120e55e..06dd15b 100644 --- a/resources/locales/lrc/lrc.go +++ b/resources/locales/lrc/lrc.go @@ -1,26 +1,43 @@ package lrc -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lrc struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lrc' locale func New() locales.Translator { return &lrc{ - locale: "lrc", + locale: "lrc", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lrc) Locale() string { - return l.locale +func (t *lrc) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lrc) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lrc' +func (t *lrc) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lrc' +func (t *lrc) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/lrc_IQ/lrc_IQ.go b/resources/locales/lrc_IQ/lrc_IQ.go index cf2ad85..5427a84 100644 --- a/resources/locales/lrc_IQ/lrc_IQ.go +++ b/resources/locales/lrc_IQ/lrc_IQ.go @@ -1,26 +1,43 @@ package lrc_IQ -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lrc_IQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lrc_IQ' locale func New() locales.Translator { return &lrc_IQ{ - locale: "lrc_IQ", + locale: "lrc_IQ", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lrc_IQ) Locale() string { - return l.locale +func (t *lrc_IQ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lrc_IQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lrc_IQ' +func (t *lrc_IQ) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lrc_IQ' +func (t *lrc_IQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/lrc_IR/lrc_IR.go b/resources/locales/lrc_IR/lrc_IR.go index d63d479..e3be163 100644 --- a/resources/locales/lrc_IR/lrc_IR.go +++ b/resources/locales/lrc_IR/lrc_IR.go @@ -1,26 +1,43 @@ package lrc_IR -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lrc_IR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lrc_IR' locale func New() locales.Translator { return &lrc_IR{ - locale: "lrc_IR", + locale: "lrc_IR", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *lrc_IR) Locale() string { - return l.locale +func (t *lrc_IR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lrc_IR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lrc_IR' +func (t *lrc_IR) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lrc_IR' +func (t *lrc_IR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/lt/lt.go b/resources/locales/lt/lt.go index 34ef0b5..bb36352 100644 --- a/resources/locales/lt/lt.go +++ b/resources/locales/lt/lt.go @@ -1,45 +1,59 @@ package lt import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lt struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lt' locale func New() locales.Translator { return <{ - locale: "lt", + locale: "lt", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lt) Locale() string { - return l.locale +func (t *lt) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lt) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lt' +func (t *lt) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lt' +func (t *lt) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if n%10 == 1 && n%100 < 11 && n%100 > 19 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 >= 2 && n%10 <= 9 && n%100 < 11 && n%100 > 19 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if f != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lt_LT/lt_LT.go b/resources/locales/lt_LT/lt_LT.go index f01bfd5..7b1d26c 100644 --- a/resources/locales/lt_LT/lt_LT.go +++ b/resources/locales/lt_LT/lt_LT.go @@ -1,45 +1,59 @@ package lt_LT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lt_LT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lt_LT' locale func New() locales.Translator { return <_LT{ - locale: "lt_LT", + locale: "lt_LT", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *lt_LT) Locale() string { - return l.locale +func (t *lt_LT) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lt_LT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lt_LT' +func (t *lt_LT) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lt_LT' +func (t *lt_LT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if n%10 == 1 && n%100 < 11 && n%100 > 19 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n%10 >= 2 && n%10 <= 9 && n%100 < 11 && n%100 > 19 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if f != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lu/lu.go b/resources/locales/lu/lu.go index 2266e5f..bd23de8 100644 --- a/resources/locales/lu/lu.go +++ b/resources/locales/lu/lu.go @@ -1,26 +1,43 @@ package lu -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lu' locale func New() locales.Translator { return &lu{ - locale: "lu", + locale: "lu", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lu) Locale() string { - return l.locale +func (t *lu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lu' +func (t *lu) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lu' +func (t *lu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/lu_CD/lu_CD.go b/resources/locales/lu_CD/lu_CD.go index 07876df..ada8b49 100644 --- a/resources/locales/lu_CD/lu_CD.go +++ b/resources/locales/lu_CD/lu_CD.go @@ -1,26 +1,43 @@ package lu_CD -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type lu_CD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lu_CD' locale func New() locales.Translator { return &lu_CD{ - locale: "lu_CD", + locale: "lu_CD", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lu_CD) Locale() string { - return l.locale +func (t *lu_CD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lu_CD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'lu_CD' +func (t *lu_CD) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lu_CD' +func (t *lu_CD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/luo/luo.go b/resources/locales/luo/luo.go index 24c4bd7..355f147 100644 --- a/resources/locales/luo/luo.go +++ b/resources/locales/luo/luo.go @@ -1,26 +1,43 @@ package luo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type luo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'luo' locale func New() locales.Translator { return &luo{ - locale: "luo", + locale: "luo", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *luo) Locale() string { - return l.locale +func (t *luo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *luo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'luo' +func (t *luo) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'luo' +func (t *luo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/luo_KE/luo_KE.go b/resources/locales/luo_KE/luo_KE.go index ed79d58..7f391bf 100644 --- a/resources/locales/luo_KE/luo_KE.go +++ b/resources/locales/luo_KE/luo_KE.go @@ -1,26 +1,43 @@ package luo_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type luo_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'luo_KE' locale func New() locales.Translator { return &luo_KE{ - locale: "luo_KE", + locale: "luo_KE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *luo_KE) Locale() string { - return l.locale +func (t *luo_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *luo_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'luo_KE' +func (t *luo_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'luo_KE' +func (t *luo_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/luy/luy.go b/resources/locales/luy/luy.go index 6ebd761..20d85c2 100644 --- a/resources/locales/luy/luy.go +++ b/resources/locales/luy/luy.go @@ -1,26 +1,43 @@ package luy -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type luy struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'luy' locale func New() locales.Translator { return &luy{ - locale: "luy", + locale: "luy", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *luy) Locale() string { - return l.locale +func (t *luy) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *luy) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'luy' +func (t *luy) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'luy' +func (t *luy) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/luy_KE/luy_KE.go b/resources/locales/luy_KE/luy_KE.go index 7d5dc09..00ea788 100644 --- a/resources/locales/luy_KE/luy_KE.go +++ b/resources/locales/luy_KE/luy_KE.go @@ -1,26 +1,43 @@ package luy_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type luy_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'luy_KE' locale func New() locales.Translator { return &luy_KE{ - locale: "luy_KE", + locale: "luy_KE", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *luy_KE) Locale() string { - return l.locale +func (t *luy_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *luy_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'luy_KE' +func (t *luy_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'luy_KE' +func (t *luy_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/lv/lv.go b/resources/locales/lv/lv.go index dd2572f..d4ad4b6 100644 --- a/resources/locales/lv/lv.go +++ b/resources/locales/lv/lv.go @@ -1,45 +1,57 @@ package lv import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lv struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lv' locale func New() locales.Translator { return &lv{ - locale: "lv", + locale: "lv", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *lv) Locale() string { - return l.locale +func (t *lv) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lv) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'lv' +func (t *lv) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lv' +func (t *lv) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if (n%10 == 0) || (n%100 >= 11 && n%100 <= 19) || (v == 2 && f%100 >= 11 && f%100 <= 19) { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (n%10 == 1 && n%100 != 11) || (v == 2 && f%10 == 1 && f%100 != 11) || (v != 2 && f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/lv_LV/lv_LV.go b/resources/locales/lv_LV/lv_LV.go index cfd8d53..2e199b1 100644 --- a/resources/locales/lv_LV/lv_LV.go +++ b/resources/locales/lv_LV/lv_LV.go @@ -1,45 +1,57 @@ package lv_LV import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type lv_LV struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'lv_LV' locale func New() locales.Translator { return &lv_LV{ - locale: "lv_LV", + locale: "lv_LV", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *lv_LV) Locale() string { - return l.locale +func (t *lv_LV) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *lv_LV) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'lv_LV' +func (t *lv_LV) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'lv_LV' +func (t *lv_LV) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if (n%10 == 0) || (n%100 >= 11 && n%100 <= 19) || (v == 2 && f%100 >= 11 && f%100 <= 19) { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (n%10 == 1 && n%100 != 11) || (v == 2 && f%10 == 1 && f%100 != 11) || (v != 2 && f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mas/mas.go b/resources/locales/mas/mas.go index 009a02b..dcbb2c5 100644 --- a/resources/locales/mas/mas.go +++ b/resources/locales/mas/mas.go @@ -1,36 +1,54 @@ package mas import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mas struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mas' locale func New() locales.Translator { return &mas{ - locale: "mas", + locale: "mas", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mas) Locale() string { - return l.locale +func (t *mas) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mas' +func (t *mas) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mas) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mas' +func (t *mas) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mas_KE/mas_KE.go b/resources/locales/mas_KE/mas_KE.go index 8ffae0c..87af473 100644 --- a/resources/locales/mas_KE/mas_KE.go +++ b/resources/locales/mas_KE/mas_KE.go @@ -1,36 +1,54 @@ package mas_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mas_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mas_KE' locale func New() locales.Translator { return &mas_KE{ - locale: "mas_KE", + locale: "mas_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mas_KE) Locale() string { - return l.locale +func (t *mas_KE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mas_KE' +func (t *mas_KE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mas_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mas_KE' +func (t *mas_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mas_TZ/mas_TZ.go b/resources/locales/mas_TZ/mas_TZ.go index 4d055f5..a83d99b 100644 --- a/resources/locales/mas_TZ/mas_TZ.go +++ b/resources/locales/mas_TZ/mas_TZ.go @@ -1,36 +1,54 @@ package mas_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mas_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mas_TZ' locale func New() locales.Translator { return &mas_TZ{ - locale: "mas_TZ", + locale: "mas_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mas_TZ) Locale() string { - return l.locale +func (t *mas_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mas_TZ' +func (t *mas_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mas_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mas_TZ' +func (t *mas_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mer/mer.go b/resources/locales/mer/mer.go index 0b3e3c4..8377ad7 100644 --- a/resources/locales/mer/mer.go +++ b/resources/locales/mer/mer.go @@ -1,26 +1,43 @@ package mer -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mer struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mer' locale func New() locales.Translator { return &mer{ - locale: "mer", + locale: "mer", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mer) Locale() string { - return l.locale +func (t *mer) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mer) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mer' +func (t *mer) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mer' +func (t *mer) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mer_KE/mer_KE.go b/resources/locales/mer_KE/mer_KE.go index acb8c2b..a5fbb22 100644 --- a/resources/locales/mer_KE/mer_KE.go +++ b/resources/locales/mer_KE/mer_KE.go @@ -1,26 +1,43 @@ package mer_KE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mer_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mer_KE' locale func New() locales.Translator { return &mer_KE{ - locale: "mer_KE", + locale: "mer_KE", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mer_KE) Locale() string { - return l.locale +func (t *mer_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mer_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mer_KE' +func (t *mer_KE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mer_KE' +func (t *mer_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mfe/mfe.go b/resources/locales/mfe/mfe.go index 06bfb82..2442e2a 100644 --- a/resources/locales/mfe/mfe.go +++ b/resources/locales/mfe/mfe.go @@ -1,26 +1,43 @@ package mfe -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mfe struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mfe' locale func New() locales.Translator { return &mfe{ - locale: "mfe", + locale: "mfe", + plurals: nil, + decimal: []byte{}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mfe) Locale() string { - return l.locale +func (t *mfe) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mfe) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mfe' +func (t *mfe) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mfe' +func (t *mfe) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mfe_MU/mfe_MU.go b/resources/locales/mfe_MU/mfe_MU.go index 4703170..e96367e 100644 --- a/resources/locales/mfe_MU/mfe_MU.go +++ b/resources/locales/mfe_MU/mfe_MU.go @@ -1,26 +1,43 @@ package mfe_MU -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mfe_MU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mfe_MU' locale func New() locales.Translator { return &mfe_MU{ - locale: "mfe_MU", + locale: "mfe_MU", + plurals: nil, + decimal: []byte{}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mfe_MU) Locale() string { - return l.locale +func (t *mfe_MU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mfe_MU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mfe_MU' +func (t *mfe_MU) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mfe_MU' +func (t *mfe_MU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mg/mg.go b/resources/locales/mg/mg.go index 611ecaf..42929af 100644 --- a/resources/locales/mg/mg.go +++ b/resources/locales/mg/mg.go @@ -1,36 +1,54 @@ package mg import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mg' locale func New() locales.Translator { return &mg{ - locale: "mg", + locale: "mg", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mg) Locale() string { - return l.locale +func (t *mg) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mg' +func (t *mg) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mg' +func (t *mg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mg_MG/mg_MG.go b/resources/locales/mg_MG/mg_MG.go index bd432d7..d78e6b6 100644 --- a/resources/locales/mg_MG/mg_MG.go +++ b/resources/locales/mg_MG/mg_MG.go @@ -1,36 +1,54 @@ package mg_MG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mg_MG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mg_MG' locale func New() locales.Translator { return &mg_MG{ - locale: "mg_MG", + locale: "mg_MG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mg_MG) Locale() string { - return l.locale +func (t *mg_MG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mg_MG' +func (t *mg_MG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mg_MG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mg_MG' +func (t *mg_MG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mgh/mgh.go b/resources/locales/mgh/mgh.go index caaecd3..8a4bd6a 100644 --- a/resources/locales/mgh/mgh.go +++ b/resources/locales/mgh/mgh.go @@ -1,26 +1,43 @@ package mgh -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mgh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mgh' locale func New() locales.Translator { return &mgh{ - locale: "mgh", + locale: "mgh", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mgh) Locale() string { - return l.locale +func (t *mgh) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mgh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mgh' +func (t *mgh) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mgh' +func (t *mgh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mgh_MZ/mgh_MZ.go b/resources/locales/mgh_MZ/mgh_MZ.go index 3c226a1..65ce40d 100644 --- a/resources/locales/mgh_MZ/mgh_MZ.go +++ b/resources/locales/mgh_MZ/mgh_MZ.go @@ -1,26 +1,43 @@ package mgh_MZ -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mgh_MZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mgh_MZ' locale func New() locales.Translator { return &mgh_MZ{ - locale: "mgh_MZ", + locale: "mgh_MZ", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mgh_MZ) Locale() string { - return l.locale +func (t *mgh_MZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mgh_MZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mgh_MZ' +func (t *mgh_MZ) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mgh_MZ' +func (t *mgh_MZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mgo/mgo.go b/resources/locales/mgo/mgo.go index 6a76436..8cfb900 100644 --- a/resources/locales/mgo/mgo.go +++ b/resources/locales/mgo/mgo.go @@ -1,36 +1,54 @@ package mgo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mgo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mgo' locale func New() locales.Translator { return &mgo{ - locale: "mgo", + locale: "mgo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mgo) Locale() string { - return l.locale +func (t *mgo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mgo' +func (t *mgo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mgo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mgo' +func (t *mgo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mgo_CM/mgo_CM.go b/resources/locales/mgo_CM/mgo_CM.go index 1d15cba..6f10946 100644 --- a/resources/locales/mgo_CM/mgo_CM.go +++ b/resources/locales/mgo_CM/mgo_CM.go @@ -1,36 +1,54 @@ package mgo_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mgo_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mgo_CM' locale func New() locales.Translator { return &mgo_CM{ - locale: "mgo_CM", + locale: "mgo_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mgo_CM) Locale() string { - return l.locale +func (t *mgo_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mgo_CM' +func (t *mgo_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mgo_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM' +func (t *mgo_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mk/mk.go b/resources/locales/mk/mk.go index 60c89ca..83d7653 100644 --- a/resources/locales/mk/mk.go +++ b/resources/locales/mk/mk.go @@ -1,43 +1,56 @@ package mk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mk' locale func New() locales.Translator { return &mk{ - locale: "mk", + locale: "mk", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mk) Locale() string { - return l.locale +func (t *mk) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mk) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'mk' +func (t *mk) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mk' +func (t *mk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1) || (f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mk_MK/mk_MK.go b/resources/locales/mk_MK/mk_MK.go index e08a0a1..60424f5 100644 --- a/resources/locales/mk_MK/mk_MK.go +++ b/resources/locales/mk_MK/mk_MK.go @@ -1,43 +1,56 @@ package mk_MK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mk_MK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mk_MK' locale func New() locales.Translator { return &mk_MK{ - locale: "mk_MK", + locale: "mk_MK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mk_MK) Locale() string { - return l.locale +func (t *mk_MK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mk_MK) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'mk_MK' +func (t *mk_MK) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mk_MK' +func (t *mk_MK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1) || (f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ml/ml.go b/resources/locales/ml/ml.go index 5f6b9e2..ccc8d17 100644 --- a/resources/locales/ml/ml.go +++ b/resources/locales/ml/ml.go @@ -1,36 +1,54 @@ package ml import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ml struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ml' locale func New() locales.Translator { return &ml{ - locale: "ml", + locale: "ml", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ml) Locale() string { - return l.locale +func (t *ml) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ml' +func (t *ml) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ml) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ml' +func (t *ml) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ml_IN/ml_IN.go b/resources/locales/ml_IN/ml_IN.go index 3457eae..24d1688 100644 --- a/resources/locales/ml_IN/ml_IN.go +++ b/resources/locales/ml_IN/ml_IN.go @@ -1,36 +1,54 @@ package ml_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ml_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ml_IN' locale func New() locales.Translator { return &ml_IN{ - locale: "ml_IN", + locale: "ml_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ml_IN) Locale() string { - return l.locale +func (t *ml_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ml_IN' +func (t *ml_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ml_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ml_IN' +func (t *ml_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mn/mn.go b/resources/locales/mn/mn.go index c14628a..0422494 100644 --- a/resources/locales/mn/mn.go +++ b/resources/locales/mn/mn.go @@ -1,36 +1,54 @@ package mn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mn' locale func New() locales.Translator { return &mn{ - locale: "mn", + locale: "mn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mn) Locale() string { - return l.locale +func (t *mn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mn' +func (t *mn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mn' +func (t *mn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mn_MN/mn_MN.go b/resources/locales/mn_MN/mn_MN.go index c7d05fc..50d9f40 100644 --- a/resources/locales/mn_MN/mn_MN.go +++ b/resources/locales/mn_MN/mn_MN.go @@ -1,36 +1,54 @@ package mn_MN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mn_MN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mn_MN' locale func New() locales.Translator { return &mn_MN{ - locale: "mn_MN", + locale: "mn_MN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mn_MN) Locale() string { - return l.locale +func (t *mn_MN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mn_MN' +func (t *mn_MN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mn_MN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mn_MN' +func (t *mn_MN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mr/mr.go b/resources/locales/mr/mr.go index 9d9edda..d152eae 100644 --- a/resources/locales/mr/mr.go +++ b/resources/locales/mr/mr.go @@ -1,41 +1,55 @@ package mr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mr' locale func New() locales.Translator { return &mr{ - locale: "mr", + locale: "mr", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mr) Locale() string { - return l.locale +func (t *mr) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mr) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mr' +func (t *mr) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mr' +func (t *mr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mr_IN/mr_IN.go b/resources/locales/mr_IN/mr_IN.go index 54344a8..a302ae2 100644 --- a/resources/locales/mr_IN/mr_IN.go +++ b/resources/locales/mr_IN/mr_IN.go @@ -1,41 +1,55 @@ package mr_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mr_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mr_IN' locale func New() locales.Translator { return &mr_IN{ - locale: "mr_IN", + locale: "mr_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mr_IN) Locale() string { - return l.locale +func (t *mr_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mr_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mr_IN' +func (t *mr_IN) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mr_IN' +func (t *mr_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ms/ms.go b/resources/locales/ms/ms.go index 013b51f..bbb1509 100644 --- a/resources/locales/ms/ms.go +++ b/resources/locales/ms/ms.go @@ -1,27 +1,43 @@ package ms -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ms struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ms' locale func New() locales.Translator { return &ms{ - locale: "ms", + locale: "ms", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ms) Locale() string { - return l.locale +func (t *ms) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ms) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ms' +func (t *ms) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ms' +func (t *ms) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ms_BN/ms_BN.go b/resources/locales/ms_BN/ms_BN.go index 6afa282..f252a9f 100644 --- a/resources/locales/ms_BN/ms_BN.go +++ b/resources/locales/ms_BN/ms_BN.go @@ -1,27 +1,43 @@ package ms_BN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ms_BN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ms_BN' locale func New() locales.Translator { return &ms_BN{ - locale: "ms_BN", + locale: "ms_BN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ms_BN) Locale() string { - return l.locale +func (t *ms_BN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ms_BN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ms_BN' +func (t *ms_BN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ms_BN' +func (t *ms_BN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ms_MY/ms_MY.go b/resources/locales/ms_MY/ms_MY.go index b13895e..f112ed0 100644 --- a/resources/locales/ms_MY/ms_MY.go +++ b/resources/locales/ms_MY/ms_MY.go @@ -1,27 +1,43 @@ package ms_MY -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ms_MY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ms_MY' locale func New() locales.Translator { return &ms_MY{ - locale: "ms_MY", + locale: "ms_MY", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ms_MY) Locale() string { - return l.locale +func (t *ms_MY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ms_MY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ms_MY' +func (t *ms_MY) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ms_MY' +func (t *ms_MY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ms_SG/ms_SG.go b/resources/locales/ms_SG/ms_SG.go index 10f4d62..d5f8cef 100644 --- a/resources/locales/ms_SG/ms_SG.go +++ b/resources/locales/ms_SG/ms_SG.go @@ -1,27 +1,43 @@ package ms_SG -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ms_SG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ms_SG' locale func New() locales.Translator { return &ms_SG{ - locale: "ms_SG", + locale: "ms_SG", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ms_SG) Locale() string { - return l.locale +func (t *ms_SG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ms_SG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ms_SG' +func (t *ms_SG) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ms_SG' +func (t *ms_SG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/mt/mt.go b/resources/locales/mt/mt.go index 7916a35..5c22a06 100644 --- a/resources/locales/mt/mt.go +++ b/resources/locales/mt/mt.go @@ -1,40 +1,58 @@ package mt import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mt struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mt' locale func New() locales.Translator { return &mt{ - locale: "mt", + locale: "mt", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mt) Locale() string { - return l.locale +func (t *mt) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mt' +func (t *mt) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mt) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mt' +func (t *mt) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (n == 0) || (n%100 >= 2 && n%100 <= 10) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 19 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mt_MT/mt_MT.go b/resources/locales/mt_MT/mt_MT.go index 268cfba..9c47000 100644 --- a/resources/locales/mt_MT/mt_MT.go +++ b/resources/locales/mt_MT/mt_MT.go @@ -1,40 +1,58 @@ package mt_MT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type mt_MT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mt_MT' locale func New() locales.Translator { return &mt_MT{ - locale: "mt_MT", + locale: "mt_MT", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mt_MT) Locale() string { - return l.locale +func (t *mt_MT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'mt_MT' +func (t *mt_MT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mt_MT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mt_MT' +func (t *mt_MT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (n == 0) || (n%100 >= 2 && n%100 <= 10) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if n%100 >= 11 && n%100 <= 19 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/mua/mua.go b/resources/locales/mua/mua.go index b675aa7..ab32a24 100644 --- a/resources/locales/mua/mua.go +++ b/resources/locales/mua/mua.go @@ -1,26 +1,43 @@ package mua -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mua struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mua' locale func New() locales.Translator { return &mua{ - locale: "mua", + locale: "mua", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mua) Locale() string { - return l.locale +func (t *mua) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mua) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mua' +func (t *mua) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mua' +func (t *mua) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mua_CM/mua_CM.go b/resources/locales/mua_CM/mua_CM.go index 4afaa0b..c48454d 100644 --- a/resources/locales/mua_CM/mua_CM.go +++ b/resources/locales/mua_CM/mua_CM.go @@ -1,26 +1,43 @@ package mua_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mua_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mua_CM' locale func New() locales.Translator { return &mua_CM{ - locale: "mua_CM", + locale: "mua_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mua_CM) Locale() string { - return l.locale +func (t *mua_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mua_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mua_CM' +func (t *mua_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mua_CM' +func (t *mua_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/my/my.go b/resources/locales/my/my.go index deffcca..94d5894 100644 --- a/resources/locales/my/my.go +++ b/resources/locales/my/my.go @@ -1,27 +1,43 @@ package my -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type my struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'my' locale func New() locales.Translator { return &my{ - locale: "my", + locale: "my", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *my) Locale() string { - return l.locale +func (t *my) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *my) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'my' +func (t *my) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'my' +func (t *my) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/my_MM/my_MM.go b/resources/locales/my_MM/my_MM.go index 258fb61..6d8ef1f 100644 --- a/resources/locales/my_MM/my_MM.go +++ b/resources/locales/my_MM/my_MM.go @@ -1,27 +1,43 @@ package my_MM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type my_MM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'my_MM' locale func New() locales.Translator { return &my_MM{ - locale: "my_MM", + locale: "my_MM", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *my_MM) Locale() string { - return l.locale +func (t *my_MM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *my_MM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'my_MM' +func (t *my_MM) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'my_MM' +func (t *my_MM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/mzn/mzn.go b/resources/locales/mzn/mzn.go index b785cf9..7fd8edd 100644 --- a/resources/locales/mzn/mzn.go +++ b/resources/locales/mzn/mzn.go @@ -1,26 +1,43 @@ package mzn -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mzn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mzn' locale func New() locales.Translator { return &mzn{ - locale: "mzn", + locale: "mzn", + plurals: nil, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *mzn) Locale() string { - return l.locale +func (t *mzn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mzn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mzn' +func (t *mzn) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mzn' +func (t *mzn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/mzn_IR/mzn_IR.go b/resources/locales/mzn_IR/mzn_IR.go index 851e5fe..8a81b13 100644 --- a/resources/locales/mzn_IR/mzn_IR.go +++ b/resources/locales/mzn_IR/mzn_IR.go @@ -1,26 +1,43 @@ package mzn_IR -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type mzn_IR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'mzn_IR' locale func New() locales.Translator { return &mzn_IR{ - locale: "mzn_IR", + locale: "mzn_IR", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *mzn_IR) Locale() string { - return l.locale +func (t *mzn_IR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *mzn_IR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'mzn_IR' +func (t *mzn_IR) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'mzn_IR' +func (t *mzn_IR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/naq/naq.go b/resources/locales/naq/naq.go index 7b6cfe8..b8a9733 100644 --- a/resources/locales/naq/naq.go +++ b/resources/locales/naq/naq.go @@ -1,38 +1,56 @@ package naq import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type naq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'naq' locale func New() locales.Translator { return &naq{ - locale: "naq", + locale: "naq", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *naq) Locale() string { - return l.locale +func (t *naq) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'naq' +func (t *naq) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *naq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'naq' +func (t *naq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/naq_NA/naq_NA.go b/resources/locales/naq_NA/naq_NA.go index 223da27..0648ce4 100644 --- a/resources/locales/naq_NA/naq_NA.go +++ b/resources/locales/naq_NA/naq_NA.go @@ -1,38 +1,56 @@ package naq_NA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type naq_NA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'naq_NA' locale func New() locales.Translator { return &naq_NA{ - locale: "naq_NA", + locale: "naq_NA", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *naq_NA) Locale() string { - return l.locale +func (t *naq_NA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'naq_NA' +func (t *naq_NA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *naq_NA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'naq_NA' +func (t *naq_NA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nb/nb.go b/resources/locales/nb/nb.go index 4c0826a..11eb682 100644 --- a/resources/locales/nb/nb.go +++ b/resources/locales/nb/nb.go @@ -1,36 +1,54 @@ package nb import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nb struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nb' locale func New() locales.Translator { return &nb{ - locale: "nb", + locale: "nb", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nb) Locale() string { - return l.locale +func (t *nb) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nb' +func (t *nb) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nb) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nb' +func (t *nb) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nb_NO/nb_NO.go b/resources/locales/nb_NO/nb_NO.go index 568a632..34471fb 100644 --- a/resources/locales/nb_NO/nb_NO.go +++ b/resources/locales/nb_NO/nb_NO.go @@ -1,36 +1,54 @@ package nb_NO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nb_NO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nb_NO' locale func New() locales.Translator { return &nb_NO{ - locale: "nb_NO", + locale: "nb_NO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *nb_NO) Locale() string { - return l.locale +func (t *nb_NO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nb_NO' +func (t *nb_NO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nb_NO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nb_NO' +func (t *nb_NO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nb_SJ/nb_SJ.go b/resources/locales/nb_SJ/nb_SJ.go index dcc14e1..ca1e402 100644 --- a/resources/locales/nb_SJ/nb_SJ.go +++ b/resources/locales/nb_SJ/nb_SJ.go @@ -1,36 +1,54 @@ package nb_SJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nb_SJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nb_SJ' locale func New() locales.Translator { return &nb_SJ{ - locale: "nb_SJ", + locale: "nb_SJ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *nb_SJ) Locale() string { - return l.locale +func (t *nb_SJ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nb_SJ' +func (t *nb_SJ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nb_SJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nb_SJ' +func (t *nb_SJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nd/nd.go b/resources/locales/nd/nd.go index 1403274..d937fae 100644 --- a/resources/locales/nd/nd.go +++ b/resources/locales/nd/nd.go @@ -1,36 +1,54 @@ package nd import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nd struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nd' locale func New() locales.Translator { return &nd{ - locale: "nd", + locale: "nd", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nd) Locale() string { - return l.locale +func (t *nd) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nd' +func (t *nd) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nd) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nd' +func (t *nd) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nd_ZW/nd_ZW.go b/resources/locales/nd_ZW/nd_ZW.go index f38d49c..1adcef7 100644 --- a/resources/locales/nd_ZW/nd_ZW.go +++ b/resources/locales/nd_ZW/nd_ZW.go @@ -1,36 +1,54 @@ package nd_ZW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nd_ZW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nd_ZW' locale func New() locales.Translator { return &nd_ZW{ - locale: "nd_ZW", + locale: "nd_ZW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nd_ZW) Locale() string { - return l.locale +func (t *nd_ZW) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nd_ZW' +func (t *nd_ZW) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nd_ZW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nd_ZW' +func (t *nd_ZW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ne/ne.go b/resources/locales/ne/ne.go index 04363ff..860655a 100644 --- a/resources/locales/ne/ne.go +++ b/resources/locales/ne/ne.go @@ -1,36 +1,54 @@ package ne import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ne struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ne' locale func New() locales.Translator { return &ne{ - locale: "ne", + locale: "ne", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ne) Locale() string { - return l.locale +func (t *ne) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ne' +func (t *ne) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ne) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ne' +func (t *ne) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ne_IN/ne_IN.go b/resources/locales/ne_IN/ne_IN.go index e026d7f..561b3ee 100644 --- a/resources/locales/ne_IN/ne_IN.go +++ b/resources/locales/ne_IN/ne_IN.go @@ -1,36 +1,54 @@ package ne_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ne_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ne_IN' locale func New() locales.Translator { return &ne_IN{ - locale: "ne_IN", + locale: "ne_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ne_IN) Locale() string { - return l.locale +func (t *ne_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ne_IN' +func (t *ne_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ne_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ne_IN' +func (t *ne_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ne_NP/ne_NP.go b/resources/locales/ne_NP/ne_NP.go index a066989..3803b51 100644 --- a/resources/locales/ne_NP/ne_NP.go +++ b/resources/locales/ne_NP/ne_NP.go @@ -1,36 +1,54 @@ package ne_NP import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ne_NP struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ne_NP' locale func New() locales.Translator { return &ne_NP{ - locale: "ne_NP", + locale: "ne_NP", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ne_NP) Locale() string { - return l.locale +func (t *ne_NP) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ne_NP' +func (t *ne_NP) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ne_NP) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ne_NP' +func (t *ne_NP) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl/nl.go b/resources/locales/nl/nl.go index c2287fb..fa2260c 100644 --- a/resources/locales/nl/nl.go +++ b/resources/locales/nl/nl.go @@ -1,38 +1,55 @@ package nl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl' locale func New() locales.Translator { return &nl{ - locale: "nl", + locale: "nl", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl) Locale() string { - return l.locale +func (t *nl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl' +func (t *nl) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl' +func (t *nl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_AW/nl_AW.go b/resources/locales/nl_AW/nl_AW.go index 85a4a7a..e9d5bb1 100644 --- a/resources/locales/nl_AW/nl_AW.go +++ b/resources/locales/nl_AW/nl_AW.go @@ -1,38 +1,55 @@ package nl_AW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_AW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_AW' locale func New() locales.Translator { return &nl_AW{ - locale: "nl_AW", + locale: "nl_AW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_AW) Locale() string { - return l.locale +func (t *nl_AW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_AW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_AW' +func (t *nl_AW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_AW' +func (t *nl_AW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_BE/nl_BE.go b/resources/locales/nl_BE/nl_BE.go index 5950a83..360aac8 100644 --- a/resources/locales/nl_BE/nl_BE.go +++ b/resources/locales/nl_BE/nl_BE.go @@ -1,38 +1,55 @@ package nl_BE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_BE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_BE' locale func New() locales.Translator { return &nl_BE{ - locale: "nl_BE", + locale: "nl_BE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_BE) Locale() string { - return l.locale +func (t *nl_BE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_BE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_BE' +func (t *nl_BE) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_BE' +func (t *nl_BE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_BQ/nl_BQ.go b/resources/locales/nl_BQ/nl_BQ.go index 7c318d2..945611a 100644 --- a/resources/locales/nl_BQ/nl_BQ.go +++ b/resources/locales/nl_BQ/nl_BQ.go @@ -1,38 +1,55 @@ package nl_BQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_BQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_BQ' locale func New() locales.Translator { return &nl_BQ{ - locale: "nl_BQ", + locale: "nl_BQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_BQ) Locale() string { - return l.locale +func (t *nl_BQ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_BQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_BQ' +func (t *nl_BQ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_BQ' +func (t *nl_BQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_CW/nl_CW.go b/resources/locales/nl_CW/nl_CW.go index 0459f11..5bebb0c 100644 --- a/resources/locales/nl_CW/nl_CW.go +++ b/resources/locales/nl_CW/nl_CW.go @@ -1,38 +1,55 @@ package nl_CW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_CW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_CW' locale func New() locales.Translator { return &nl_CW{ - locale: "nl_CW", + locale: "nl_CW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_CW) Locale() string { - return l.locale +func (t *nl_CW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_CW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_CW' +func (t *nl_CW) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_CW' +func (t *nl_CW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_NL/nl_NL.go b/resources/locales/nl_NL/nl_NL.go index ff77c03..1977296 100644 --- a/resources/locales/nl_NL/nl_NL.go +++ b/resources/locales/nl_NL/nl_NL.go @@ -1,38 +1,55 @@ package nl_NL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_NL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_NL' locale func New() locales.Translator { return &nl_NL{ - locale: "nl_NL", + locale: "nl_NL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_NL) Locale() string { - return l.locale +func (t *nl_NL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_NL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_NL' +func (t *nl_NL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_NL' +func (t *nl_NL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_SR/nl_SR.go b/resources/locales/nl_SR/nl_SR.go index 3da061e..c62f352 100644 --- a/resources/locales/nl_SR/nl_SR.go +++ b/resources/locales/nl_SR/nl_SR.go @@ -1,38 +1,55 @@ package nl_SR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_SR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_SR' locale func New() locales.Translator { return &nl_SR{ - locale: "nl_SR", + locale: "nl_SR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_SR) Locale() string { - return l.locale +func (t *nl_SR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_SR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_SR' +func (t *nl_SR) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_SR' +func (t *nl_SR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nl_SX/nl_SX.go b/resources/locales/nl_SX/nl_SX.go index b8062e6..7aa122b 100644 --- a/resources/locales/nl_SX/nl_SX.go +++ b/resources/locales/nl_SX/nl_SX.go @@ -1,38 +1,55 @@ package nl_SX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nl_SX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nl_SX' locale func New() locales.Translator { return &nl_SX{ - locale: "nl_SX", + locale: "nl_SX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nl_SX) Locale() string { - return l.locale +func (t *nl_SX) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nl_SX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nl_SX' +func (t *nl_SX) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nl_SX' +func (t *nl_SX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nmg/nmg.go b/resources/locales/nmg/nmg.go index 2a5a6d9..95bc1e8 100644 --- a/resources/locales/nmg/nmg.go +++ b/resources/locales/nmg/nmg.go @@ -1,26 +1,43 @@ package nmg -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type nmg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nmg' locale func New() locales.Translator { return &nmg{ - locale: "nmg", + locale: "nmg", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nmg) Locale() string { - return l.locale +func (t *nmg) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nmg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nmg' +func (t *nmg) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nmg' +func (t *nmg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/nmg_CM/nmg_CM.go b/resources/locales/nmg_CM/nmg_CM.go index 69ba039..407cd2f 100644 --- a/resources/locales/nmg_CM/nmg_CM.go +++ b/resources/locales/nmg_CM/nmg_CM.go @@ -1,26 +1,43 @@ package nmg_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type nmg_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nmg_CM' locale func New() locales.Translator { return &nmg_CM{ - locale: "nmg_CM", + locale: "nmg_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *nmg_CM) Locale() string { - return l.locale +func (t *nmg_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nmg_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nmg_CM' +func (t *nmg_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nmg_CM' +func (t *nmg_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/nn/nn.go b/resources/locales/nn/nn.go index 840c9e7..5fca742 100644 --- a/resources/locales/nn/nn.go +++ b/resources/locales/nn/nn.go @@ -1,36 +1,54 @@ package nn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nn' locale func New() locales.Translator { return &nn{ - locale: "nn", + locale: "nn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nn) Locale() string { - return l.locale +func (t *nn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nn' +func (t *nn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nn' +func (t *nn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nn_NO/nn_NO.go b/resources/locales/nn_NO/nn_NO.go index d4a5145..8dd5a87 100644 --- a/resources/locales/nn_NO/nn_NO.go +++ b/resources/locales/nn_NO/nn_NO.go @@ -1,36 +1,54 @@ package nn_NO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nn_NO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nn_NO' locale func New() locales.Translator { return &nn_NO{ - locale: "nn_NO", + locale: "nn_NO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *nn_NO) Locale() string { - return l.locale +func (t *nn_NO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nn_NO' +func (t *nn_NO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nn_NO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nn_NO' +func (t *nn_NO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nnh/nnh.go b/resources/locales/nnh/nnh.go index 8a4be2f..da7ff0c 100644 --- a/resources/locales/nnh/nnh.go +++ b/resources/locales/nnh/nnh.go @@ -1,36 +1,54 @@ package nnh import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nnh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nnh' locale func New() locales.Translator { return &nnh{ - locale: "nnh", + locale: "nnh", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{0x25}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nnh) Locale() string { - return l.locale +func (t *nnh) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nnh' +func (t *nnh) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nnh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nnh' +func (t *nnh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nnh_CM/nnh_CM.go b/resources/locales/nnh_CM/nnh_CM.go index 0f1959a..08c9ef5 100644 --- a/resources/locales/nnh_CM/nnh_CM.go +++ b/resources/locales/nnh_CM/nnh_CM.go @@ -1,36 +1,54 @@ package nnh_CM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nnh_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nnh_CM' locale func New() locales.Translator { return &nnh_CM{ - locale: "nnh_CM", + locale: "nnh_CM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nnh_CM) Locale() string { - return l.locale +func (t *nnh_CM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nnh_CM' +func (t *nnh_CM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nnh_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nnh_CM' +func (t *nnh_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nus/nus.go b/resources/locales/nus/nus.go index ea0733f..b21e874 100644 --- a/resources/locales/nus/nus.go +++ b/resources/locales/nus/nus.go @@ -1,26 +1,43 @@ package nus -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type nus struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nus' locale func New() locales.Translator { return &nus{ - locale: "nus", + locale: "nus", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nus) Locale() string { - return l.locale +func (t *nus) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nus) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nus' +func (t *nus) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nus' +func (t *nus) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/nus_SS/nus_SS.go b/resources/locales/nus_SS/nus_SS.go index 46b8768..df3c96f 100644 --- a/resources/locales/nus_SS/nus_SS.go +++ b/resources/locales/nus_SS/nus_SS.go @@ -1,26 +1,43 @@ package nus_SS -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type nus_SS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nus_SS' locale func New() locales.Translator { return &nus_SS{ - locale: "nus_SS", + locale: "nus_SS", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *nus_SS) Locale() string { - return l.locale +func (t *nus_SS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nus_SS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'nus_SS' +func (t *nus_SS) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nus_SS' +func (t *nus_SS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/nyn/nyn.go b/resources/locales/nyn/nyn.go index 8fa8e6a..89ca0d7 100644 --- a/resources/locales/nyn/nyn.go +++ b/resources/locales/nyn/nyn.go @@ -1,36 +1,54 @@ package nyn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nyn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nyn' locale func New() locales.Translator { return &nyn{ - locale: "nyn", + locale: "nyn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nyn) Locale() string { - return l.locale +func (t *nyn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nyn' +func (t *nyn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nyn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nyn' +func (t *nyn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/nyn_UG/nyn_UG.go b/resources/locales/nyn_UG/nyn_UG.go index d8773e3..13a9229 100644 --- a/resources/locales/nyn_UG/nyn_UG.go +++ b/resources/locales/nyn_UG/nyn_UG.go @@ -1,36 +1,54 @@ package nyn_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type nyn_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'nyn_UG' locale func New() locales.Translator { return &nyn_UG{ - locale: "nyn_UG", + locale: "nyn_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *nyn_UG) Locale() string { - return l.locale +func (t *nyn_UG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'nyn_UG' +func (t *nyn_UG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *nyn_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'nyn_UG' +func (t *nyn_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/om/om.go b/resources/locales/om/om.go index 15d676e..5b819f7 100644 --- a/resources/locales/om/om.go +++ b/resources/locales/om/om.go @@ -1,36 +1,54 @@ package om import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type om struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'om' locale func New() locales.Translator { return &om{ - locale: "om", + locale: "om", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *om) Locale() string { - return l.locale +func (t *om) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'om' +func (t *om) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *om) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'om' +func (t *om) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/om_ET/om_ET.go b/resources/locales/om_ET/om_ET.go index 1cf46be..2722165 100644 --- a/resources/locales/om_ET/om_ET.go +++ b/resources/locales/om_ET/om_ET.go @@ -1,36 +1,54 @@ package om_ET import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type om_ET struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'om_ET' locale func New() locales.Translator { return &om_ET{ - locale: "om_ET", + locale: "om_ET", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *om_ET) Locale() string { - return l.locale +func (t *om_ET) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'om_ET' +func (t *om_ET) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *om_ET) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'om_ET' +func (t *om_ET) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/om_KE/om_KE.go b/resources/locales/om_KE/om_KE.go index 3f9e273..5aaf404 100644 --- a/resources/locales/om_KE/om_KE.go +++ b/resources/locales/om_KE/om_KE.go @@ -1,36 +1,54 @@ package om_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type om_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'om_KE' locale func New() locales.Translator { return &om_KE{ - locale: "om_KE", + locale: "om_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *om_KE) Locale() string { - return l.locale +func (t *om_KE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'om_KE' +func (t *om_KE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *om_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'om_KE' +func (t *om_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/or/or.go b/resources/locales/or/or.go index ef1ffbb..79e686b 100644 --- a/resources/locales/or/or.go +++ b/resources/locales/or/or.go @@ -1,36 +1,54 @@ package or import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type or struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'or' locale func New() locales.Translator { return &or{ - locale: "or", + locale: "or", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *or) Locale() string { - return l.locale +func (t *or) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'or' +func (t *or) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *or) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'or' +func (t *or) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/or_IN/or_IN.go b/resources/locales/or_IN/or_IN.go index 3d0f036..9ee4ad1 100644 --- a/resources/locales/or_IN/or_IN.go +++ b/resources/locales/or_IN/or_IN.go @@ -1,36 +1,54 @@ package or_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type or_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'or_IN' locale func New() locales.Translator { return &or_IN{ - locale: "or_IN", + locale: "or_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *or_IN) Locale() string { - return l.locale +func (t *or_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'or_IN' +func (t *or_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *or_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'or_IN' +func (t *or_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/os/os.go b/resources/locales/os/os.go index f2fe987..4234662 100644 --- a/resources/locales/os/os.go +++ b/resources/locales/os/os.go @@ -1,36 +1,54 @@ package os import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type os struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'os' locale func New() locales.Translator { return &os{ - locale: "os", + locale: "os", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *os) Locale() string { - return l.locale +func (t *os) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'os' +func (t *os) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *os) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'os' +func (t *os) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/os_GE/os_GE.go b/resources/locales/os_GE/os_GE.go index d653a1b..74c38b5 100644 --- a/resources/locales/os_GE/os_GE.go +++ b/resources/locales/os_GE/os_GE.go @@ -1,36 +1,54 @@ package os_GE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type os_GE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'os_GE' locale func New() locales.Translator { return &os_GE{ - locale: "os_GE", + locale: "os_GE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *os_GE) Locale() string { - return l.locale +func (t *os_GE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'os_GE' +func (t *os_GE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *os_GE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'os_GE' +func (t *os_GE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/os_RU/os_RU.go b/resources/locales/os_RU/os_RU.go index 4f3dfac..c796ccc 100644 --- a/resources/locales/os_RU/os_RU.go +++ b/resources/locales/os_RU/os_RU.go @@ -1,36 +1,54 @@ package os_RU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type os_RU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'os_RU' locale func New() locales.Translator { return &os_RU{ - locale: "os_RU", + locale: "os_RU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *os_RU) Locale() string { - return l.locale +func (t *os_RU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'os_RU' +func (t *os_RU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *os_RU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'os_RU' +func (t *os_RU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pa/pa.go b/resources/locales/pa/pa.go index e07b21f..ab1ea7f 100644 --- a/resources/locales/pa/pa.go +++ b/resources/locales/pa/pa.go @@ -1,36 +1,54 @@ package pa import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pa struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pa' locale func New() locales.Translator { return &pa{ - locale: "pa", + locale: "pa", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *pa) Locale() string { - return l.locale +func (t *pa) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pa' +func (t *pa) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pa) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pa' +func (t *pa) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pa_Arab/pa_Arab.go b/resources/locales/pa_Arab/pa_Arab.go index cd8af11..19ff876 100644 --- a/resources/locales/pa_Arab/pa_Arab.go +++ b/resources/locales/pa_Arab/pa_Arab.go @@ -1,36 +1,54 @@ package pa_Arab import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pa_Arab struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pa_Arab' locale func New() locales.Translator { return &pa_Arab{ - locale: "pa_Arab", + locale: "pa_Arab", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0xe2, 0x80, 0x8e, 0x2d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pa_Arab) Locale() string { - return l.locale +func (t *pa_Arab) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pa_Arab' +func (t *pa_Arab) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pa_Arab) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab' +func (t *pa_Arab) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pa_Arab_PK/pa_Arab_PK.go b/resources/locales/pa_Arab_PK/pa_Arab_PK.go index 87bdf5a..8ee84ee 100644 --- a/resources/locales/pa_Arab_PK/pa_Arab_PK.go +++ b/resources/locales/pa_Arab_PK/pa_Arab_PK.go @@ -1,36 +1,54 @@ package pa_Arab_PK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pa_Arab_PK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pa_Arab_PK' locale func New() locales.Translator { return &pa_Arab_PK{ - locale: "pa_Arab_PK", + locale: "pa_Arab_PK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pa_Arab_PK) Locale() string { - return l.locale +func (t *pa_Arab_PK) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pa_Arab_PK' +func (t *pa_Arab_PK) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pa_Arab_PK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab_PK' +func (t *pa_Arab_PK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pa_Guru/pa_Guru.go b/resources/locales/pa_Guru/pa_Guru.go index 6058654..2863fd9 100644 --- a/resources/locales/pa_Guru/pa_Guru.go +++ b/resources/locales/pa_Guru/pa_Guru.go @@ -1,36 +1,54 @@ package pa_Guru import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pa_Guru struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pa_Guru' locale func New() locales.Translator { return &pa_Guru{ - locale: "pa_Guru", + locale: "pa_Guru", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pa_Guru) Locale() string { - return l.locale +func (t *pa_Guru) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pa_Guru' +func (t *pa_Guru) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pa_Guru) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru' +func (t *pa_Guru) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pa_Guru_IN/pa_Guru_IN.go b/resources/locales/pa_Guru_IN/pa_Guru_IN.go index 31885ee..f42b9ed 100644 --- a/resources/locales/pa_Guru_IN/pa_Guru_IN.go +++ b/resources/locales/pa_Guru_IN/pa_Guru_IN.go @@ -1,36 +1,54 @@ package pa_Guru_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pa_Guru_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pa_Guru_IN' locale func New() locales.Translator { return &pa_Guru_IN{ - locale: "pa_Guru_IN", + locale: "pa_Guru_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pa_Guru_IN) Locale() string { - return l.locale +func (t *pa_Guru_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pa_Guru_IN' +func (t *pa_Guru_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pa_Guru_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru_IN' +func (t *pa_Guru_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pl/pl.go b/resources/locales/pl/pl.go index 0c2544f..9298834 100644 --- a/resources/locales/pl/pl.go +++ b/resources/locales/pl/pl.go @@ -1,42 +1,59 @@ package pl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pl' locale func New() locales.Translator { return &pl{ - locale: "pl", + locale: "pl", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *pl) Locale() string { - return l.locale +func (t *pl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'pl' +func (t *pl) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pl' +func (t *pl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i != 1 && i%10 >= 0 && i%10 <= 1) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 12 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pl_PL/pl_PL.go b/resources/locales/pl_PL/pl_PL.go index 920b4ce..3da09fa 100644 --- a/resources/locales/pl_PL/pl_PL.go +++ b/resources/locales/pl_PL/pl_PL.go @@ -1,42 +1,59 @@ package pl_PL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pl_PL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pl_PL' locale func New() locales.Translator { return &pl_PL{ - locale: "pl_PL", + locale: "pl_PL", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pl_PL) Locale() string { - return l.locale +func (t *pl_PL) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pl_PL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'pl_PL' +func (t *pl_PL) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pl_PL' +func (t *pl_PL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i != 1 && i%10 >= 0 && i%10 <= 1) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 12 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/prg/prg.go b/resources/locales/prg/prg.go index 606b050..e507398 100644 --- a/resources/locales/prg/prg.go +++ b/resources/locales/prg/prg.go @@ -1,45 +1,57 @@ package prg import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type prg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'prg' locale func New() locales.Translator { return &prg{ - locale: "prg", + locale: "prg", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *prg) Locale() string { - return l.locale +func (t *prg) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *prg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'prg' +func (t *prg) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'prg' +func (t *prg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if (n%10 == 0) || (n%100 >= 11 && n%100 <= 19) || (v == 2 && f%100 >= 11 && f%100 <= 19) { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (n%10 == 1 && n%100 != 11) || (v == 2 && f%10 == 1 && f%100 != 11) || (v != 2 && f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/prg_001/prg_001.go b/resources/locales/prg_001/prg_001.go index b996b71..29df343 100644 --- a/resources/locales/prg_001/prg_001.go +++ b/resources/locales/prg_001/prg_001.go @@ -1,45 +1,57 @@ package prg_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type prg_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'prg_001' locale func New() locales.Translator { return &prg_001{ - locale: "prg_001", + locale: "prg_001", + plurals: []locales.PluralRule{1, 2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *prg_001) Locale() string { - return l.locale +func (t *prg_001) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *prg_001) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'prg_001' +func (t *prg_001) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'prg_001' +func (t *prg_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + f := locales.F(n, v) if (n%10 == 0) || (n%100 >= 11 && n%100 <= 19) || (v == 2 && f%100 >= 11 && f%100 <= 19) { - return locales.PluralRuleZero, nil + return locales.PluralRuleZero } else if (n%10 == 1 && n%100 != 11) || (v == 2 && f%10 == 1 && f%100 != 11) || (v != 2 && f%10 == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ps/ps.go b/resources/locales/ps/ps.go index d6fe630..9afa038 100644 --- a/resources/locales/ps/ps.go +++ b/resources/locales/ps/ps.go @@ -1,36 +1,54 @@ package ps import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ps struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ps' locale func New() locales.Translator { return &ps{ - locale: "ps", + locale: "ps", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ps) Locale() string { - return l.locale +func (t *ps) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ps' +func (t *ps) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ps) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ps' +func (t *ps) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ps_AF/ps_AF.go b/resources/locales/ps_AF/ps_AF.go index f9f902b..74d2d5d 100644 --- a/resources/locales/ps_AF/ps_AF.go +++ b/resources/locales/ps_AF/ps_AF.go @@ -1,36 +1,54 @@ package ps_AF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ps_AF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ps_AF' locale func New() locales.Translator { return &ps_AF{ - locale: "ps_AF", + locale: "ps_AF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ps_AF) Locale() string { - return l.locale +func (t *ps_AF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ps_AF' +func (t *ps_AF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ps_AF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ps_AF' +func (t *ps_AF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt/pt.go b/resources/locales/pt/pt.go index 1ba2334..ddc4387 100644 --- a/resources/locales/pt/pt.go +++ b/resources/locales/pt/pt.go @@ -1,36 +1,54 @@ package pt import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt' locale func New() locales.Translator { return &pt{ - locale: "pt", + locale: "pt", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *pt) Locale() string { - return l.locale +func (t *pt) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt' +func (t *pt) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt' +func (t *pt) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_AO/pt_AO.go b/resources/locales/pt_AO/pt_AO.go index b848a36..b9dba19 100644 --- a/resources/locales/pt_AO/pt_AO.go +++ b/resources/locales/pt_AO/pt_AO.go @@ -1,36 +1,54 @@ package pt_AO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_AO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_AO' locale func New() locales.Translator { return &pt_AO{ - locale: "pt_AO", + locale: "pt_AO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_AO) Locale() string { - return l.locale +func (t *pt_AO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_AO' +func (t *pt_AO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_AO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_AO' +func (t *pt_AO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_BR/pt_BR.go b/resources/locales/pt_BR/pt_BR.go index 397d65c..a6a9bb0 100644 --- a/resources/locales/pt_BR/pt_BR.go +++ b/resources/locales/pt_BR/pt_BR.go @@ -1,36 +1,54 @@ package pt_BR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_BR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_BR' locale func New() locales.Translator { return &pt_BR{ - locale: "pt_BR", + locale: "pt_BR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_BR) Locale() string { - return l.locale +func (t *pt_BR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_BR' +func (t *pt_BR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_BR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_BR' +func (t *pt_BR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_CH/pt_CH.go b/resources/locales/pt_CH/pt_CH.go index 797e9cc..594ecef 100644 --- a/resources/locales/pt_CH/pt_CH.go +++ b/resources/locales/pt_CH/pt_CH.go @@ -1,36 +1,54 @@ package pt_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_CH' locale func New() locales.Translator { return &pt_CH{ - locale: "pt_CH", + locale: "pt_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_CH) Locale() string { - return l.locale +func (t *pt_CH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_CH' +func (t *pt_CH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_CH' +func (t *pt_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_CV/pt_CV.go b/resources/locales/pt_CV/pt_CV.go index c9e5c29..017ef78 100644 --- a/resources/locales/pt_CV/pt_CV.go +++ b/resources/locales/pt_CV/pt_CV.go @@ -1,36 +1,54 @@ package pt_CV import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_CV struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_CV' locale func New() locales.Translator { return &pt_CV{ - locale: "pt_CV", + locale: "pt_CV", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_CV) Locale() string { - return l.locale +func (t *pt_CV) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_CV' +func (t *pt_CV) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_CV) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_CV' +func (t *pt_CV) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_GQ/pt_GQ.go b/resources/locales/pt_GQ/pt_GQ.go index 353e7f9..401eb36 100644 --- a/resources/locales/pt_GQ/pt_GQ.go +++ b/resources/locales/pt_GQ/pt_GQ.go @@ -1,36 +1,54 @@ package pt_GQ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_GQ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_GQ' locale func New() locales.Translator { return &pt_GQ{ - locale: "pt_GQ", + locale: "pt_GQ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_GQ) Locale() string { - return l.locale +func (t *pt_GQ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_GQ' +func (t *pt_GQ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_GQ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_GQ' +func (t *pt_GQ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_GW/pt_GW.go b/resources/locales/pt_GW/pt_GW.go index 8ffcfaf..e61658f 100644 --- a/resources/locales/pt_GW/pt_GW.go +++ b/resources/locales/pt_GW/pt_GW.go @@ -1,36 +1,54 @@ package pt_GW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_GW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_GW' locale func New() locales.Translator { return &pt_GW{ - locale: "pt_GW", + locale: "pt_GW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_GW) Locale() string { - return l.locale +func (t *pt_GW) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_GW' +func (t *pt_GW) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_GW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_GW' +func (t *pt_GW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_LU/pt_LU.go b/resources/locales/pt_LU/pt_LU.go index f3d5b5d..c5bc6db 100644 --- a/resources/locales/pt_LU/pt_LU.go +++ b/resources/locales/pt_LU/pt_LU.go @@ -1,36 +1,54 @@ package pt_LU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_LU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_LU' locale func New() locales.Translator { return &pt_LU{ - locale: "pt_LU", + locale: "pt_LU", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_LU) Locale() string { - return l.locale +func (t *pt_LU) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_LU' +func (t *pt_LU) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_LU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_LU' +func (t *pt_LU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_MO/pt_MO.go b/resources/locales/pt_MO/pt_MO.go index c232731..5e4b44f 100644 --- a/resources/locales/pt_MO/pt_MO.go +++ b/resources/locales/pt_MO/pt_MO.go @@ -1,36 +1,54 @@ package pt_MO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_MO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_MO' locale func New() locales.Translator { return &pt_MO{ - locale: "pt_MO", + locale: "pt_MO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_MO) Locale() string { - return l.locale +func (t *pt_MO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_MO' +func (t *pt_MO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_MO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_MO' +func (t *pt_MO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_MZ/pt_MZ.go b/resources/locales/pt_MZ/pt_MZ.go index 9fc6361..2f8b210 100644 --- a/resources/locales/pt_MZ/pt_MZ.go +++ b/resources/locales/pt_MZ/pt_MZ.go @@ -1,36 +1,54 @@ package pt_MZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_MZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_MZ' locale func New() locales.Translator { return &pt_MZ{ - locale: "pt_MZ", + locale: "pt_MZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *pt_MZ) Locale() string { - return l.locale +func (t *pt_MZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_MZ' +func (t *pt_MZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_MZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_MZ' +func (t *pt_MZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_PT/pt_PT.go b/resources/locales/pt_PT/pt_PT.go index 0f3e25b..a13a3d0 100644 --- a/resources/locales/pt_PT/pt_PT.go +++ b/resources/locales/pt_PT/pt_PT.go @@ -1,36 +1,54 @@ package pt_PT import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_PT struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_PT' locale func New() locales.Translator { return &pt_PT{ - locale: "pt_PT", + locale: "pt_PT", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_PT) Locale() string { - return l.locale +func (t *pt_PT) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_PT' +func (t *pt_PT) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_PT) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_PT' +func (t *pt_PT) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_ST/pt_ST.go b/resources/locales/pt_ST/pt_ST.go index 7d63078..2771c6c 100644 --- a/resources/locales/pt_ST/pt_ST.go +++ b/resources/locales/pt_ST/pt_ST.go @@ -1,36 +1,54 @@ package pt_ST import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_ST struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_ST' locale func New() locales.Translator { return &pt_ST{ - locale: "pt_ST", + locale: "pt_ST", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *pt_ST) Locale() string { - return l.locale +func (t *pt_ST) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_ST' +func (t *pt_ST) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_ST) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_ST' +func (t *pt_ST) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/pt_TL/pt_TL.go b/resources/locales/pt_TL/pt_TL.go index 7d1961a..756fbb1 100644 --- a/resources/locales/pt_TL/pt_TL.go +++ b/resources/locales/pt_TL/pt_TL.go @@ -1,36 +1,54 @@ package pt_TL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type pt_TL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'pt_TL' locale func New() locales.Translator { return &pt_TL{ - locale: "pt_TL", + locale: "pt_TL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *pt_TL) Locale() string { - return l.locale +func (t *pt_TL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'pt_TL' +func (t *pt_TL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *pt_TL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'pt_TL' +func (t *pt_TL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 2 && n != 2 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/qu/qu.go b/resources/locales/qu/qu.go index 5b4fa7b..1e788a1 100644 --- a/resources/locales/qu/qu.go +++ b/resources/locales/qu/qu.go @@ -1,26 +1,43 @@ package qu -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type qu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'qu' locale func New() locales.Translator { return &qu{ - locale: "qu", + locale: "qu", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *qu) Locale() string { - return l.locale +func (t *qu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *qu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'qu' +func (t *qu) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'qu' +func (t *qu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/qu_BO/qu_BO.go b/resources/locales/qu_BO/qu_BO.go index cdd8a4a..abc93e2 100644 --- a/resources/locales/qu_BO/qu_BO.go +++ b/resources/locales/qu_BO/qu_BO.go @@ -1,26 +1,43 @@ package qu_BO -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type qu_BO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'qu_BO' locale func New() locales.Translator { return &qu_BO{ - locale: "qu_BO", + locale: "qu_BO", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *qu_BO) Locale() string { - return l.locale +func (t *qu_BO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *qu_BO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'qu_BO' +func (t *qu_BO) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'qu_BO' +func (t *qu_BO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/qu_EC/qu_EC.go b/resources/locales/qu_EC/qu_EC.go index 519f07f..75f83a2 100644 --- a/resources/locales/qu_EC/qu_EC.go +++ b/resources/locales/qu_EC/qu_EC.go @@ -1,26 +1,43 @@ package qu_EC -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type qu_EC struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'qu_EC' locale func New() locales.Translator { return &qu_EC{ - locale: "qu_EC", + locale: "qu_EC", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *qu_EC) Locale() string { - return l.locale +func (t *qu_EC) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *qu_EC) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'qu_EC' +func (t *qu_EC) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'qu_EC' +func (t *qu_EC) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/qu_PE/qu_PE.go b/resources/locales/qu_PE/qu_PE.go index 966c81c..36b4de5 100644 --- a/resources/locales/qu_PE/qu_PE.go +++ b/resources/locales/qu_PE/qu_PE.go @@ -1,26 +1,43 @@ package qu_PE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type qu_PE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'qu_PE' locale func New() locales.Translator { return &qu_PE{ - locale: "qu_PE", + locale: "qu_PE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *qu_PE) Locale() string { - return l.locale +func (t *qu_PE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *qu_PE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'qu_PE' +func (t *qu_PE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'qu_PE' +func (t *qu_PE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/rm/rm.go b/resources/locales/rm/rm.go index 9849092..178eaf4 100644 --- a/resources/locales/rm/rm.go +++ b/resources/locales/rm/rm.go @@ -1,36 +1,54 @@ package rm import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rm struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rm' locale func New() locales.Translator { return &rm{ - locale: "rm", + locale: "rm", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0xe2, 0x80, 0x99}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *rm) Locale() string { - return l.locale +func (t *rm) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rm' +func (t *rm) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rm) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rm' +func (t *rm) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rm_CH/rm_CH.go b/resources/locales/rm_CH/rm_CH.go index 6e4ecee..1a99981 100644 --- a/resources/locales/rm_CH/rm_CH.go +++ b/resources/locales/rm_CH/rm_CH.go @@ -1,36 +1,54 @@ package rm_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rm_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rm_CH' locale func New() locales.Translator { return &rm_CH{ - locale: "rm_CH", + locale: "rm_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x39, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *rm_CH) Locale() string { - return l.locale +func (t *rm_CH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rm_CH' +func (t *rm_CH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rm_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rm_CH' +func (t *rm_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rn/rn.go b/resources/locales/rn/rn.go index 6d160e5..62843ea 100644 --- a/resources/locales/rn/rn.go +++ b/resources/locales/rn/rn.go @@ -1,26 +1,43 @@ package rn -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type rn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rn' locale func New() locales.Translator { return &rn{ - locale: "rn", + locale: "rn", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *rn) Locale() string { - return l.locale +func (t *rn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'rn' +func (t *rn) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rn' +func (t *rn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/rn_BI/rn_BI.go b/resources/locales/rn_BI/rn_BI.go index 4a43a2b..01f984d 100644 --- a/resources/locales/rn_BI/rn_BI.go +++ b/resources/locales/rn_BI/rn_BI.go @@ -1,26 +1,43 @@ package rn_BI -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type rn_BI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rn_BI' locale func New() locales.Translator { return &rn_BI{ - locale: "rn_BI", + locale: "rn_BI", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *rn_BI) Locale() string { - return l.locale +func (t *rn_BI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rn_BI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'rn_BI' +func (t *rn_BI) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rn_BI' +func (t *rn_BI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/ro/ro.go b/resources/locales/ro/ro.go index 49e25be..3594771 100644 --- a/resources/locales/ro/ro.go +++ b/resources/locales/ro/ro.go @@ -1,45 +1,57 @@ package ro import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ro struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ro' locale func New() locales.Translator { return &ro{ - locale: "ro", + locale: "ro", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ro) Locale() string { - return l.locale +func (t *ro) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ro) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'ro' +func (t *ro) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ro' +func (t *ro) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v != 0) || (n == 0) || (n != 1 && n%100 >= 1 && n%100 <= 19) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ro_MD/ro_MD.go b/resources/locales/ro_MD/ro_MD.go index c7845e9..6af7a02 100644 --- a/resources/locales/ro_MD/ro_MD.go +++ b/resources/locales/ro_MD/ro_MD.go @@ -1,45 +1,57 @@ package ro_MD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ro_MD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ro_MD' locale func New() locales.Translator { return &ro_MD{ - locale: "ro_MD", + locale: "ro_MD", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ro_MD) Locale() string { - return l.locale +func (t *ro_MD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ro_MD) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'ro_MD' +func (t *ro_MD) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ro_MD' +func (t *ro_MD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v != 0) || (n == 0) || (n != 1 && n%100 >= 1 && n%100 <= 19) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ro_RO/ro_RO.go b/resources/locales/ro_RO/ro_RO.go index bb1e0d7..a9c1588 100644 --- a/resources/locales/ro_RO/ro_RO.go +++ b/resources/locales/ro_RO/ro_RO.go @@ -1,45 +1,57 @@ package ro_RO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ro_RO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ro_RO' locale func New() locales.Translator { return &ro_RO{ - locale: "ro_RO", + locale: "ro_RO", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ro_RO) Locale() string { - return l.locale +func (t *ro_RO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ro_RO) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'ro_RO' +func (t *ro_RO) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ro_RO' +func (t *ro_RO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v != 0) || (n == 0) || (n != 1 && n%100 >= 1 && n%100 <= 19) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rof/rof.go b/resources/locales/rof/rof.go index dea50ca..8c5f424 100644 --- a/resources/locales/rof/rof.go +++ b/resources/locales/rof/rof.go @@ -1,36 +1,54 @@ package rof import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rof struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rof' locale func New() locales.Translator { return &rof{ - locale: "rof", + locale: "rof", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *rof) Locale() string { - return l.locale +func (t *rof) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rof' +func (t *rof) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rof) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rof' +func (t *rof) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rof_TZ/rof_TZ.go b/resources/locales/rof_TZ/rof_TZ.go index 1122c33..cf9c205 100644 --- a/resources/locales/rof_TZ/rof_TZ.go +++ b/resources/locales/rof_TZ/rof_TZ.go @@ -1,36 +1,54 @@ package rof_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rof_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rof_TZ' locale func New() locales.Translator { return &rof_TZ{ - locale: "rof_TZ", + locale: "rof_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *rof_TZ) Locale() string { - return l.locale +func (t *rof_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rof_TZ' +func (t *rof_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rof_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rof_TZ' +func (t *rof_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/root/root.go b/resources/locales/root/root.go index ccdfc13..f1632eb 100644 --- a/resources/locales/root/root.go +++ b/resources/locales/root/root.go @@ -1,27 +1,43 @@ package root -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type root struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'root' locale func New() locales.Translator { return &root{ - locale: "root", + locale: "root", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *root) Locale() string { - return l.locale +func (t *root) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *root) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'root' +func (t *root) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'root' +func (t *root) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ru/ru.go b/resources/locales/ru/ru.go index d839df5..b331b0b 100644 --- a/resources/locales/ru/ru.go +++ b/resources/locales/ru/ru.go @@ -1,42 +1,59 @@ package ru import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru' locale func New() locales.Translator { return &ru{ - locale: "ru", + locale: "ru", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru) Locale() string { - return l.locale +func (t *ru) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru' +func (t *ru) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru' +func (t *ru) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_BY/ru_BY.go b/resources/locales/ru_BY/ru_BY.go index 06a292c..758fea0 100644 --- a/resources/locales/ru_BY/ru_BY.go +++ b/resources/locales/ru_BY/ru_BY.go @@ -1,42 +1,59 @@ package ru_BY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_BY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_BY' locale func New() locales.Translator { return &ru_BY{ - locale: "ru_BY", + locale: "ru_BY", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_BY) Locale() string { - return l.locale +func (t *ru_BY) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_BY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_BY' +func (t *ru_BY) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_BY' +func (t *ru_BY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_KG/ru_KG.go b/resources/locales/ru_KG/ru_KG.go index 84f8970..be92dba 100644 --- a/resources/locales/ru_KG/ru_KG.go +++ b/resources/locales/ru_KG/ru_KG.go @@ -1,42 +1,59 @@ package ru_KG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_KG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_KG' locale func New() locales.Translator { return &ru_KG{ - locale: "ru_KG", + locale: "ru_KG", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_KG) Locale() string { - return l.locale +func (t *ru_KG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_KG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_KG' +func (t *ru_KG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_KG' +func (t *ru_KG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_KZ/ru_KZ.go b/resources/locales/ru_KZ/ru_KZ.go index 1a19e09..79aa3ca 100644 --- a/resources/locales/ru_KZ/ru_KZ.go +++ b/resources/locales/ru_KZ/ru_KZ.go @@ -1,42 +1,59 @@ package ru_KZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_KZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_KZ' locale func New() locales.Translator { return &ru_KZ{ - locale: "ru_KZ", + locale: "ru_KZ", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_KZ) Locale() string { - return l.locale +func (t *ru_KZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_KZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_KZ' +func (t *ru_KZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_KZ' +func (t *ru_KZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_MD/ru_MD.go b/resources/locales/ru_MD/ru_MD.go index eb78149..4ddf91c 100644 --- a/resources/locales/ru_MD/ru_MD.go +++ b/resources/locales/ru_MD/ru_MD.go @@ -1,42 +1,59 @@ package ru_MD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_MD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_MD' locale func New() locales.Translator { return &ru_MD{ - locale: "ru_MD", + locale: "ru_MD", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_MD) Locale() string { - return l.locale +func (t *ru_MD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_MD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_MD' +func (t *ru_MD) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_MD' +func (t *ru_MD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_RU/ru_RU.go b/resources/locales/ru_RU/ru_RU.go index 5b65935..6d81e27 100644 --- a/resources/locales/ru_RU/ru_RU.go +++ b/resources/locales/ru_RU/ru_RU.go @@ -1,42 +1,59 @@ package ru_RU import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_RU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_RU' locale func New() locales.Translator { return &ru_RU{ - locale: "ru_RU", + locale: "ru_RU", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_RU) Locale() string { - return l.locale +func (t *ru_RU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_RU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_RU' +func (t *ru_RU) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_RU' +func (t *ru_RU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ru_UA/ru_UA.go b/resources/locales/ru_UA/ru_UA.go index 466f5bc..00c0e79 100644 --- a/resources/locales/ru_UA/ru_UA.go +++ b/resources/locales/ru_UA/ru_UA.go @@ -1,42 +1,59 @@ package ru_UA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ru_UA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ru_UA' locale func New() locales.Translator { return &ru_UA{ - locale: "ru_UA", + locale: "ru_UA", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ru_UA) Locale() string { - return l.locale +func (t *ru_UA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ru_UA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ru_UA' +func (t *ru_UA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ru_UA' +func (t *ru_UA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rw/rw.go b/resources/locales/rw/rw.go index 6fbd92b..52e5add 100644 --- a/resources/locales/rw/rw.go +++ b/resources/locales/rw/rw.go @@ -1,26 +1,43 @@ package rw -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type rw struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rw' locale func New() locales.Translator { return &rw{ - locale: "rw", + locale: "rw", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *rw) Locale() string { - return l.locale +func (t *rw) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rw) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'rw' +func (t *rw) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rw' +func (t *rw) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/rw_RW/rw_RW.go b/resources/locales/rw_RW/rw_RW.go index b763673..7475d28 100644 --- a/resources/locales/rw_RW/rw_RW.go +++ b/resources/locales/rw_RW/rw_RW.go @@ -1,26 +1,43 @@ package rw_RW -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type rw_RW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rw_RW' locale func New() locales.Translator { return &rw_RW{ - locale: "rw_RW", + locale: "rw_RW", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *rw_RW) Locale() string { - return l.locale +func (t *rw_RW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rw_RW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'rw_RW' +func (t *rw_RW) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rw_RW' +func (t *rw_RW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/rwk/rwk.go b/resources/locales/rwk/rwk.go index a4f3ea0..d267a89 100644 --- a/resources/locales/rwk/rwk.go +++ b/resources/locales/rwk/rwk.go @@ -1,36 +1,54 @@ package rwk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rwk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rwk' locale func New() locales.Translator { return &rwk{ - locale: "rwk", + locale: "rwk", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *rwk) Locale() string { - return l.locale +func (t *rwk) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rwk' +func (t *rwk) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rwk) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rwk' +func (t *rwk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/rwk_TZ/rwk_TZ.go b/resources/locales/rwk_TZ/rwk_TZ.go index 678e2bf..5911112 100644 --- a/resources/locales/rwk_TZ/rwk_TZ.go +++ b/resources/locales/rwk_TZ/rwk_TZ.go @@ -1,36 +1,54 @@ package rwk_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type rwk_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'rwk_TZ' locale func New() locales.Translator { return &rwk_TZ{ - locale: "rwk_TZ", + locale: "rwk_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *rwk_TZ) Locale() string { - return l.locale +func (t *rwk_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'rwk_TZ' +func (t *rwk_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *rwk_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'rwk_TZ' +func (t *rwk_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sah/sah.go b/resources/locales/sah/sah.go index 38e8a1c..a3723ba 100644 --- a/resources/locales/sah/sah.go +++ b/resources/locales/sah/sah.go @@ -1,27 +1,43 @@ package sah -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sah struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sah' locale func New() locales.Translator { return &sah{ - locale: "sah", + locale: "sah", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sah) Locale() string { - return l.locale +func (t *sah) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sah) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sah' +func (t *sah) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sah' +func (t *sah) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/sah_RU/sah_RU.go b/resources/locales/sah_RU/sah_RU.go index 973afd2..9f631ef 100644 --- a/resources/locales/sah_RU/sah_RU.go +++ b/resources/locales/sah_RU/sah_RU.go @@ -1,27 +1,43 @@ package sah_RU -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sah_RU struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sah_RU' locale func New() locales.Translator { return &sah_RU{ - locale: "sah_RU", + locale: "sah_RU", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sah_RU) Locale() string { - return l.locale +func (t *sah_RU) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sah_RU) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sah_RU' +func (t *sah_RU) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sah_RU' +func (t *sah_RU) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/saq/saq.go b/resources/locales/saq/saq.go index 2b09e26..cfca641 100644 --- a/resources/locales/saq/saq.go +++ b/resources/locales/saq/saq.go @@ -1,36 +1,54 @@ package saq import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type saq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'saq' locale func New() locales.Translator { return &saq{ - locale: "saq", + locale: "saq", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *saq) Locale() string { - return l.locale +func (t *saq) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'saq' +func (t *saq) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *saq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'saq' +func (t *saq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/saq_KE/saq_KE.go b/resources/locales/saq_KE/saq_KE.go index 480d790..84346b1 100644 --- a/resources/locales/saq_KE/saq_KE.go +++ b/resources/locales/saq_KE/saq_KE.go @@ -1,36 +1,54 @@ package saq_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type saq_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'saq_KE' locale func New() locales.Translator { return &saq_KE{ - locale: "saq_KE", + locale: "saq_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *saq_KE) Locale() string { - return l.locale +func (t *saq_KE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'saq_KE' +func (t *saq_KE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *saq_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'saq_KE' +func (t *saq_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sbp/sbp.go b/resources/locales/sbp/sbp.go index 95766d2..85f0884 100644 --- a/resources/locales/sbp/sbp.go +++ b/resources/locales/sbp/sbp.go @@ -1,26 +1,43 @@ package sbp -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sbp struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sbp' locale func New() locales.Translator { return &sbp{ - locale: "sbp", + locale: "sbp", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sbp) Locale() string { - return l.locale +func (t *sbp) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sbp) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sbp' +func (t *sbp) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sbp' +func (t *sbp) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/sbp_TZ/sbp_TZ.go b/resources/locales/sbp_TZ/sbp_TZ.go index 6271188..7ef8c86 100644 --- a/resources/locales/sbp_TZ/sbp_TZ.go +++ b/resources/locales/sbp_TZ/sbp_TZ.go @@ -1,26 +1,43 @@ package sbp_TZ -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sbp_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sbp_TZ' locale func New() locales.Translator { return &sbp_TZ{ - locale: "sbp_TZ", + locale: "sbp_TZ", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sbp_TZ) Locale() string { - return l.locale +func (t *sbp_TZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sbp_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sbp_TZ' +func (t *sbp_TZ) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sbp_TZ' +func (t *sbp_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/se/se.go b/resources/locales/se/se.go index 38f2c96..0576569 100644 --- a/resources/locales/se/se.go +++ b/resources/locales/se/se.go @@ -1,38 +1,56 @@ package se import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type se struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'se' locale func New() locales.Translator { return &se{ - locale: "se", + locale: "se", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0xe2, 0x88, 0x92}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *se) Locale() string { - return l.locale +func (t *se) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'se' +func (t *se) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *se) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'se' +func (t *se) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/se_FI/se_FI.go b/resources/locales/se_FI/se_FI.go index a876802..bdf89dd 100644 --- a/resources/locales/se_FI/se_FI.go +++ b/resources/locales/se_FI/se_FI.go @@ -1,38 +1,56 @@ package se_FI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type se_FI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'se_FI' locale func New() locales.Translator { return &se_FI{ - locale: "se_FI", + locale: "se_FI", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *se_FI) Locale() string { - return l.locale +func (t *se_FI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'se_FI' +func (t *se_FI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *se_FI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'se_FI' +func (t *se_FI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/se_NO/se_NO.go b/resources/locales/se_NO/se_NO.go index e5d3ad8..10026ac 100644 --- a/resources/locales/se_NO/se_NO.go +++ b/resources/locales/se_NO/se_NO.go @@ -1,38 +1,56 @@ package se_NO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type se_NO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'se_NO' locale func New() locales.Translator { return &se_NO{ - locale: "se_NO", + locale: "se_NO", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *se_NO) Locale() string { - return l.locale +func (t *se_NO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'se_NO' +func (t *se_NO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *se_NO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'se_NO' +func (t *se_NO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/se_SE/se_SE.go b/resources/locales/se_SE/se_SE.go index 7100d67..a27341e 100644 --- a/resources/locales/se_SE/se_SE.go +++ b/resources/locales/se_SE/se_SE.go @@ -1,38 +1,56 @@ package se_SE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type se_SE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'se_SE' locale func New() locales.Translator { return &se_SE{ - locale: "se_SE", + locale: "se_SE", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *se_SE) Locale() string { - return l.locale +func (t *se_SE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'se_SE' +func (t *se_SE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *se_SE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'se_SE' +func (t *se_SE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/seh/seh.go b/resources/locales/seh/seh.go index 0cbf8fc..a2ce0f8 100644 --- a/resources/locales/seh/seh.go +++ b/resources/locales/seh/seh.go @@ -1,36 +1,54 @@ package seh import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type seh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'seh' locale func New() locales.Translator { return &seh{ - locale: "seh", + locale: "seh", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *seh) Locale() string { - return l.locale +func (t *seh) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'seh' +func (t *seh) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *seh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'seh' +func (t *seh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/seh_MZ/seh_MZ.go b/resources/locales/seh_MZ/seh_MZ.go index baadfd5..416faa0 100644 --- a/resources/locales/seh_MZ/seh_MZ.go +++ b/resources/locales/seh_MZ/seh_MZ.go @@ -1,36 +1,54 @@ package seh_MZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type seh_MZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'seh_MZ' locale func New() locales.Translator { return &seh_MZ{ - locale: "seh_MZ", + locale: "seh_MZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *seh_MZ) Locale() string { - return l.locale +func (t *seh_MZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'seh_MZ' +func (t *seh_MZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *seh_MZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'seh_MZ' +func (t *seh_MZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ses/ses.go b/resources/locales/ses/ses.go index 16496ba..c8f3801 100644 --- a/resources/locales/ses/ses.go +++ b/resources/locales/ses/ses.go @@ -1,27 +1,43 @@ package ses -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ses struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ses' locale func New() locales.Translator { return &ses{ - locale: "ses", + locale: "ses", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ses) Locale() string { - return l.locale +func (t *ses) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ses) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ses' +func (t *ses) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ses' +func (t *ses) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ses_ML/ses_ML.go b/resources/locales/ses_ML/ses_ML.go index d5285ab..34aa67c 100644 --- a/resources/locales/ses_ML/ses_ML.go +++ b/resources/locales/ses_ML/ses_ML.go @@ -1,27 +1,43 @@ package ses_ML -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type ses_ML struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ses_ML' locale func New() locales.Translator { return &ses_ML{ - locale: "ses_ML", + locale: "ses_ML", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ses_ML) Locale() string { - return l.locale +func (t *ses_ML) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ses_ML) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ses_ML' +func (t *ses_ML) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ses_ML' +func (t *ses_ML) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/sg/sg.go b/resources/locales/sg/sg.go index a46b2ab..043a392 100644 --- a/resources/locales/sg/sg.go +++ b/resources/locales/sg/sg.go @@ -1,27 +1,43 @@ package sg -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sg struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sg' locale func New() locales.Translator { return &sg{ - locale: "sg", + locale: "sg", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sg) Locale() string { - return l.locale +func (t *sg) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sg) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sg' +func (t *sg) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sg' +func (t *sg) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/sg_CF/sg_CF.go b/resources/locales/sg_CF/sg_CF.go index e114e05..0123212 100644 --- a/resources/locales/sg_CF/sg_CF.go +++ b/resources/locales/sg_CF/sg_CF.go @@ -1,27 +1,43 @@ package sg_CF -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type sg_CF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sg_CF' locale func New() locales.Translator { return &sg_CF{ - locale: "sg_CF", + locale: "sg_CF", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sg_CF) Locale() string { - return l.locale +func (t *sg_CF) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sg_CF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sg_CF' +func (t *sg_CF) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sg_CF' +func (t *sg_CF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/shi/shi.go b/resources/locales/shi/shi.go index b011c8f..9f8c64d 100644 --- a/resources/locales/shi/shi.go +++ b/resources/locales/shi/shi.go @@ -1,43 +1,57 @@ package shi import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type shi struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'shi' locale func New() locales.Translator { return &shi{ - locale: "shi", + locale: "shi", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *shi) Locale() string { - return l.locale +func (t *shi) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *shi) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'shi' +func (t *shi) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'shi' +func (t *shi) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n >= 2 && n <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/shi_Latn/shi_Latn.go b/resources/locales/shi_Latn/shi_Latn.go index 8a60d42..7e6ab84 100644 --- a/resources/locales/shi_Latn/shi_Latn.go +++ b/resources/locales/shi_Latn/shi_Latn.go @@ -1,43 +1,57 @@ package shi_Latn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type shi_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'shi_Latn' locale func New() locales.Translator { return &shi_Latn{ - locale: "shi_Latn", + locale: "shi_Latn", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *shi_Latn) Locale() string { - return l.locale +func (t *shi_Latn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *shi_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'shi_Latn' +func (t *shi_Latn) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn' +func (t *shi_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n >= 2 && n <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/shi_Latn_MA/shi_Latn_MA.go b/resources/locales/shi_Latn_MA/shi_Latn_MA.go index d37165f..eabeb14 100644 --- a/resources/locales/shi_Latn_MA/shi_Latn_MA.go +++ b/resources/locales/shi_Latn_MA/shi_Latn_MA.go @@ -1,43 +1,57 @@ package shi_Latn_MA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type shi_Latn_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'shi_Latn_MA' locale func New() locales.Translator { return &shi_Latn_MA{ - locale: "shi_Latn_MA", + locale: "shi_Latn_MA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *shi_Latn_MA) Locale() string { - return l.locale +func (t *shi_Latn_MA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *shi_Latn_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'shi_Latn_MA' +func (t *shi_Latn_MA) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn_MA' +func (t *shi_Latn_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n >= 2 && n <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/shi_Tfng/shi_Tfng.go b/resources/locales/shi_Tfng/shi_Tfng.go index d89e2a0..5264965 100644 --- a/resources/locales/shi_Tfng/shi_Tfng.go +++ b/resources/locales/shi_Tfng/shi_Tfng.go @@ -1,43 +1,57 @@ package shi_Tfng import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type shi_Tfng struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'shi_Tfng' locale func New() locales.Translator { return &shi_Tfng{ - locale: "shi_Tfng", + locale: "shi_Tfng", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *shi_Tfng) Locale() string { - return l.locale +func (t *shi_Tfng) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *shi_Tfng) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'shi_Tfng' +func (t *shi_Tfng) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng' +func (t *shi_Tfng) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n >= 2 && n <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/shi_Tfng_MA/shi_Tfng_MA.go b/resources/locales/shi_Tfng_MA/shi_Tfng_MA.go index f5c4ae7..69100ca 100644 --- a/resources/locales/shi_Tfng_MA/shi_Tfng_MA.go +++ b/resources/locales/shi_Tfng_MA/shi_Tfng_MA.go @@ -1,43 +1,57 @@ package shi_Tfng_MA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type shi_Tfng_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'shi_Tfng_MA' locale func New() locales.Translator { return &shi_Tfng_MA{ - locale: "shi_Tfng_MA", + locale: "shi_Tfng_MA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *shi_Tfng_MA) Locale() string { - return l.locale +func (t *shi_Tfng_MA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *shi_Tfng_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'shi_Tfng_MA' +func (t *shi_Tfng_MA) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng_MA' +func (t *shi_Tfng_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n >= 2 && n <= 10 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/si/si.go b/resources/locales/si/si.go index 5c8a966..237f8ff 100644 --- a/resources/locales/si/si.go +++ b/resources/locales/si/si.go @@ -1,46 +1,56 @@ package si import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type si struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'si' locale func New() locales.Translator { return &si{ - locale: "si", + locale: "si", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *si) Locale() string { - return l.locale +func (t *si) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *si) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'si' +func (t *si) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'si' +func (t *si) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (n == 0 || n == 1) || (i == 0 && f == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/si_LK/si_LK.go b/resources/locales/si_LK/si_LK.go index fe2aee7..4a48391 100644 --- a/resources/locales/si_LK/si_LK.go +++ b/resources/locales/si_LK/si_LK.go @@ -1,46 +1,56 @@ package si_LK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type si_LK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'si_LK' locale func New() locales.Translator { return &si_LK{ - locale: "si_LK", + locale: "si_LK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *si_LK) Locale() string { - return l.locale +func (t *si_LK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *si_LK) CardinalPluralRule(num string) (locales.PluralRule, error) { - - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'si_LK' +func (t *si_LK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'si_LK' +func (t *si_LK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (n == 0 || n == 1) || (i == 0 && f == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sk/sk.go b/resources/locales/sk/sk.go index 1734c59..e2dc143 100644 --- a/resources/locales/sk/sk.go +++ b/resources/locales/sk/sk.go @@ -1,42 +1,59 @@ package sk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sk' locale func New() locales.Translator { return &sk{ - locale: "sk", + locale: "sk", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sk) Locale() string { - return l.locale +func (t *sk) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sk) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sk' +func (t *sk) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sk' +func (t *sk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i >= 2 && i <= 4 && v == 0 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sk_SK/sk_SK.go b/resources/locales/sk_SK/sk_SK.go index 851739e..aec87c6 100644 --- a/resources/locales/sk_SK/sk_SK.go +++ b/resources/locales/sk_SK/sk_SK.go @@ -1,42 +1,59 @@ package sk_SK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sk_SK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sk_SK' locale func New() locales.Translator { return &sk_SK{ - locale: "sk_SK", + locale: "sk_SK", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sk_SK) Locale() string { - return l.locale +func (t *sk_SK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sk_SK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sk_SK' +func (t *sk_SK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sk_SK' +func (t *sk_SK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if i >= 2 && i <= 4 && v == 0 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if v != 0 { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sl/sl.go b/resources/locales/sl/sl.go index 37faad5..41f7044 100644 --- a/resources/locales/sl/sl.go +++ b/resources/locales/sl/sl.go @@ -1,42 +1,59 @@ package sl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sl' locale func New() locales.Translator { return &sl{ - locale: "sl", + locale: "sl", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sl) Locale() string { - return l.locale +func (t *sl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sl' +func (t *sl) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sl' +func (t *sl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%100 == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%100 == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (v != 0) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sl_SI/sl_SI.go b/resources/locales/sl_SI/sl_SI.go index fedc1a5..14f739c 100644 --- a/resources/locales/sl_SI/sl_SI.go +++ b/resources/locales/sl_SI/sl_SI.go @@ -1,42 +1,59 @@ package sl_SI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sl_SI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sl_SI' locale func New() locales.Translator { return &sl_SI{ - locale: "sl_SI", + locale: "sl_SI", + plurals: []locales.PluralRule{2, 3, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sl_SI) Locale() string { - return l.locale +func (t *sl_SI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sl_SI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sl_SI' +func (t *sl_SI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sl_SI' +func (t *sl_SI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%100 == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%100 == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } else if (v == 0 && i%100 >= 3 && i%100 <= 4) || (v != 0) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/smn/smn.go b/resources/locales/smn/smn.go index e2a2469..a3e8862 100644 --- a/resources/locales/smn/smn.go +++ b/resources/locales/smn/smn.go @@ -1,38 +1,56 @@ package smn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type smn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'smn' locale func New() locales.Translator { return &smn{ - locale: "smn", + locale: "smn", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *smn) Locale() string { - return l.locale +func (t *smn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'smn' +func (t *smn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *smn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'smn' +func (t *smn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/smn_FI/smn_FI.go b/resources/locales/smn_FI/smn_FI.go index 25e55ee..a2d586d 100644 --- a/resources/locales/smn_FI/smn_FI.go +++ b/resources/locales/smn_FI/smn_FI.go @@ -1,38 +1,56 @@ package smn_FI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type smn_FI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'smn_FI' locale func New() locales.Translator { return &smn_FI{ - locale: "smn_FI", + locale: "smn_FI", + plurals: []locales.PluralRule{2, 3, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *smn_FI) Locale() string { - return l.locale +func (t *smn_FI) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'smn_FI' +func (t *smn_FI) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *smn_FI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'smn_FI' +func (t *smn_FI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if n == 2 { - return locales.PluralRuleTwo, nil + return locales.PluralRuleTwo } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sn/sn.go b/resources/locales/sn/sn.go index f3331a5..08d32a7 100644 --- a/resources/locales/sn/sn.go +++ b/resources/locales/sn/sn.go @@ -1,36 +1,54 @@ package sn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sn' locale func New() locales.Translator { return &sn{ - locale: "sn", + locale: "sn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sn) Locale() string { - return l.locale +func (t *sn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sn' +func (t *sn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sn' +func (t *sn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sn_ZW/sn_ZW.go b/resources/locales/sn_ZW/sn_ZW.go index 9fef1ab..e5b4668 100644 --- a/resources/locales/sn_ZW/sn_ZW.go +++ b/resources/locales/sn_ZW/sn_ZW.go @@ -1,36 +1,54 @@ package sn_ZW import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sn_ZW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sn_ZW' locale func New() locales.Translator { return &sn_ZW{ - locale: "sn_ZW", + locale: "sn_ZW", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sn_ZW) Locale() string { - return l.locale +func (t *sn_ZW) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sn_ZW' +func (t *sn_ZW) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sn_ZW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sn_ZW' +func (t *sn_ZW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/so/so.go b/resources/locales/so/so.go index 4a6bf7a..b8976fc 100644 --- a/resources/locales/so/so.go +++ b/resources/locales/so/so.go @@ -1,36 +1,54 @@ package so import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type so struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'so' locale func New() locales.Translator { return &so{ - locale: "so", + locale: "so", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *so) Locale() string { - return l.locale +func (t *so) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'so' +func (t *so) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *so) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'so' +func (t *so) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/so_DJ/so_DJ.go b/resources/locales/so_DJ/so_DJ.go index dba0389..50b7655 100644 --- a/resources/locales/so_DJ/so_DJ.go +++ b/resources/locales/so_DJ/so_DJ.go @@ -1,36 +1,54 @@ package so_DJ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type so_DJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'so_DJ' locale func New() locales.Translator { return &so_DJ{ - locale: "so_DJ", + locale: "so_DJ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *so_DJ) Locale() string { - return l.locale +func (t *so_DJ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'so_DJ' +func (t *so_DJ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *so_DJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'so_DJ' +func (t *so_DJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/so_ET/so_ET.go b/resources/locales/so_ET/so_ET.go index f2b7710..65dd07d 100644 --- a/resources/locales/so_ET/so_ET.go +++ b/resources/locales/so_ET/so_ET.go @@ -1,36 +1,54 @@ package so_ET import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type so_ET struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'so_ET' locale func New() locales.Translator { return &so_ET{ - locale: "so_ET", + locale: "so_ET", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *so_ET) Locale() string { - return l.locale +func (t *so_ET) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'so_ET' +func (t *so_ET) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *so_ET) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'so_ET' +func (t *so_ET) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/so_KE/so_KE.go b/resources/locales/so_KE/so_KE.go index e2041da..e10eeda 100644 --- a/resources/locales/so_KE/so_KE.go +++ b/resources/locales/so_KE/so_KE.go @@ -1,36 +1,54 @@ package so_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type so_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'so_KE' locale func New() locales.Translator { return &so_KE{ - locale: "so_KE", + locale: "so_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *so_KE) Locale() string { - return l.locale +func (t *so_KE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'so_KE' +func (t *so_KE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *so_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'so_KE' +func (t *so_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/so_SO/so_SO.go b/resources/locales/so_SO/so_SO.go index b55f03a..bc349c1 100644 --- a/resources/locales/so_SO/so_SO.go +++ b/resources/locales/so_SO/so_SO.go @@ -1,36 +1,54 @@ package so_SO import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type so_SO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'so_SO' locale func New() locales.Translator { return &so_SO{ - locale: "so_SO", + locale: "so_SO", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *so_SO) Locale() string { - return l.locale +func (t *so_SO) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'so_SO' +func (t *so_SO) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *so_SO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'so_SO' +func (t *so_SO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sq/sq.go b/resources/locales/sq/sq.go index ba305f7..9f9b3d9 100644 --- a/resources/locales/sq/sq.go +++ b/resources/locales/sq/sq.go @@ -1,36 +1,54 @@ package sq import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sq' locale func New() locales.Translator { return &sq{ - locale: "sq", + locale: "sq", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sq) Locale() string { - return l.locale +func (t *sq) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sq' +func (t *sq) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sq' +func (t *sq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sq_AL/sq_AL.go b/resources/locales/sq_AL/sq_AL.go index 557ba3f..2e176a5 100644 --- a/resources/locales/sq_AL/sq_AL.go +++ b/resources/locales/sq_AL/sq_AL.go @@ -1,36 +1,54 @@ package sq_AL import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sq_AL struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sq_AL' locale func New() locales.Translator { return &sq_AL{ - locale: "sq_AL", + locale: "sq_AL", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sq_AL) Locale() string { - return l.locale +func (t *sq_AL) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sq_AL' +func (t *sq_AL) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sq_AL) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sq_AL' +func (t *sq_AL) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sq_MK/sq_MK.go b/resources/locales/sq_MK/sq_MK.go index 5aa038a..fce0ff3 100644 --- a/resources/locales/sq_MK/sq_MK.go +++ b/resources/locales/sq_MK/sq_MK.go @@ -1,36 +1,54 @@ package sq_MK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sq_MK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sq_MK' locale func New() locales.Translator { return &sq_MK{ - locale: "sq_MK", + locale: "sq_MK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sq_MK) Locale() string { - return l.locale +func (t *sq_MK) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sq_MK' +func (t *sq_MK) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sq_MK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sq_MK' +func (t *sq_MK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sq_XK/sq_XK.go b/resources/locales/sq_XK/sq_XK.go index af31fb3..f4343de 100644 --- a/resources/locales/sq_XK/sq_XK.go +++ b/resources/locales/sq_XK/sq_XK.go @@ -1,36 +1,54 @@ package sq_XK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sq_XK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sq_XK' locale func New() locales.Translator { return &sq_XK{ - locale: "sq_XK", + locale: "sq_XK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sq_XK) Locale() string { - return l.locale +func (t *sq_XK) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'sq_XK' +func (t *sq_XK) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sq_XK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sq_XK' +func (t *sq_XK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr/sr.go b/resources/locales/sr/sr.go index f1173e9..737e496 100644 --- a/resources/locales/sr/sr.go +++ b/resources/locales/sr/sr.go @@ -1,45 +1,58 @@ package sr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr' locale func New() locales.Translator { return &sr{ - locale: "sr", + locale: "sr", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr) Locale() string { - return l.locale +func (t *sr) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr' +func (t *sr) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr' +func (t *sr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Cyrl/sr_Cyrl.go b/resources/locales/sr_Cyrl/sr_Cyrl.go index 1fbe112..b83a489 100644 --- a/resources/locales/sr_Cyrl/sr_Cyrl.go +++ b/resources/locales/sr_Cyrl/sr_Cyrl.go @@ -1,45 +1,58 @@ package sr_Cyrl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Cyrl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Cyrl' locale func New() locales.Translator { return &sr_Cyrl{ - locale: "sr_Cyrl", + locale: "sr_Cyrl", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sr_Cyrl) Locale() string { - return l.locale +func (t *sr_Cyrl) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Cyrl) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Cyrl' +func (t *sr_Cyrl) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl' +func (t *sr_Cyrl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Cyrl_BA/sr_Cyrl_BA.go b/resources/locales/sr_Cyrl_BA/sr_Cyrl_BA.go index 01faecd..cdb88ef 100644 --- a/resources/locales/sr_Cyrl_BA/sr_Cyrl_BA.go +++ b/resources/locales/sr_Cyrl_BA/sr_Cyrl_BA.go @@ -1,45 +1,58 @@ package sr_Cyrl_BA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Cyrl_BA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Cyrl_BA' locale func New() locales.Translator { return &sr_Cyrl_BA{ - locale: "sr_Cyrl_BA", + locale: "sr_Cyrl_BA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sr_Cyrl_BA) Locale() string { - return l.locale +func (t *sr_Cyrl_BA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Cyrl_BA) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Cyrl_BA' +func (t *sr_Cyrl_BA) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_BA' +func (t *sr_Cyrl_BA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Cyrl_ME/sr_Cyrl_ME.go b/resources/locales/sr_Cyrl_ME/sr_Cyrl_ME.go index 967bba1..7036a7b 100644 --- a/resources/locales/sr_Cyrl_ME/sr_Cyrl_ME.go +++ b/resources/locales/sr_Cyrl_ME/sr_Cyrl_ME.go @@ -1,45 +1,58 @@ package sr_Cyrl_ME import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Cyrl_ME struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Cyrl_ME' locale func New() locales.Translator { return &sr_Cyrl_ME{ - locale: "sr_Cyrl_ME", + locale: "sr_Cyrl_ME", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr_Cyrl_ME) Locale() string { - return l.locale +func (t *sr_Cyrl_ME) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Cyrl_ME) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Cyrl_ME' +func (t *sr_Cyrl_ME) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_ME' +func (t *sr_Cyrl_ME) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Cyrl_RS/sr_Cyrl_RS.go b/resources/locales/sr_Cyrl_RS/sr_Cyrl_RS.go index af9bb2c..52185c8 100644 --- a/resources/locales/sr_Cyrl_RS/sr_Cyrl_RS.go +++ b/resources/locales/sr_Cyrl_RS/sr_Cyrl_RS.go @@ -1,45 +1,58 @@ package sr_Cyrl_RS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Cyrl_RS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Cyrl_RS' locale func New() locales.Translator { return &sr_Cyrl_RS{ - locale: "sr_Cyrl_RS", + locale: "sr_Cyrl_RS", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sr_Cyrl_RS) Locale() string { - return l.locale +func (t *sr_Cyrl_RS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Cyrl_RS) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sr_Cyrl_RS' +func (t *sr_Cyrl_RS) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_RS' +func (t *sr_Cyrl_RS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Cyrl_XK/sr_Cyrl_XK.go b/resources/locales/sr_Cyrl_XK/sr_Cyrl_XK.go index ce93b97..16dd3e6 100644 --- a/resources/locales/sr_Cyrl_XK/sr_Cyrl_XK.go +++ b/resources/locales/sr_Cyrl_XK/sr_Cyrl_XK.go @@ -1,45 +1,58 @@ package sr_Cyrl_XK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Cyrl_XK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Cyrl_XK' locale func New() locales.Translator { return &sr_Cyrl_XK{ - locale: "sr_Cyrl_XK", + locale: "sr_Cyrl_XK", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sr_Cyrl_XK) Locale() string { - return l.locale +func (t *sr_Cyrl_XK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Cyrl_XK) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Cyrl_XK' +func (t *sr_Cyrl_XK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_XK' +func (t *sr_Cyrl_XK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Latn/sr_Latn.go b/resources/locales/sr_Latn/sr_Latn.go index c00050e..b09d5e0 100644 --- a/resources/locales/sr_Latn/sr_Latn.go +++ b/resources/locales/sr_Latn/sr_Latn.go @@ -1,45 +1,58 @@ package sr_Latn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Latn' locale func New() locales.Translator { return &sr_Latn{ - locale: "sr_Latn", + locale: "sr_Latn", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr_Latn) Locale() string { - return l.locale +func (t *sr_Latn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Latn' +func (t *sr_Latn) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn' +func (t *sr_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Latn_BA/sr_Latn_BA.go b/resources/locales/sr_Latn_BA/sr_Latn_BA.go index 18df95c..295b321 100644 --- a/resources/locales/sr_Latn_BA/sr_Latn_BA.go +++ b/resources/locales/sr_Latn_BA/sr_Latn_BA.go @@ -1,45 +1,58 @@ package sr_Latn_BA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Latn_BA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Latn_BA' locale func New() locales.Translator { return &sr_Latn_BA{ - locale: "sr_Latn_BA", + locale: "sr_Latn_BA", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sr_Latn_BA) Locale() string { - return l.locale +func (t *sr_Latn_BA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Latn_BA) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Latn_BA' +func (t *sr_Latn_BA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_BA' +func (t *sr_Latn_BA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Latn_ME/sr_Latn_ME.go b/resources/locales/sr_Latn_ME/sr_Latn_ME.go index d0d93d6..594d2e8 100644 --- a/resources/locales/sr_Latn_ME/sr_Latn_ME.go +++ b/resources/locales/sr_Latn_ME/sr_Latn_ME.go @@ -1,45 +1,58 @@ package sr_Latn_ME import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Latn_ME struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Latn_ME' locale func New() locales.Translator { return &sr_Latn_ME{ - locale: "sr_Latn_ME", + locale: "sr_Latn_ME", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr_Latn_ME) Locale() string { - return l.locale +func (t *sr_Latn_ME) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Latn_ME) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Latn_ME' +func (t *sr_Latn_ME) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_ME' +func (t *sr_Latn_ME) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Latn_RS/sr_Latn_RS.go b/resources/locales/sr_Latn_RS/sr_Latn_RS.go index 86bbf3b..f7e0661 100644 --- a/resources/locales/sr_Latn_RS/sr_Latn_RS.go +++ b/resources/locales/sr_Latn_RS/sr_Latn_RS.go @@ -1,45 +1,58 @@ package sr_Latn_RS import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Latn_RS struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Latn_RS' locale func New() locales.Translator { return &sr_Latn_RS{ - locale: "sr_Latn_RS", + locale: "sr_Latn_RS", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr_Latn_RS) Locale() string { - return l.locale +func (t *sr_Latn_RS) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Latn_RS) CardinalPluralRule(num string) (locales.PluralRule, error) { - - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Latn_RS' +func (t *sr_Latn_RS) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_RS' +func (t *sr_Latn_RS) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sr_Latn_XK/sr_Latn_XK.go b/resources/locales/sr_Latn_XK/sr_Latn_XK.go index ca7fa80..0e8d8a3 100644 --- a/resources/locales/sr_Latn_XK/sr_Latn_XK.go +++ b/resources/locales/sr_Latn_XK/sr_Latn_XK.go @@ -1,45 +1,58 @@ package sr_Latn_XK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sr_Latn_XK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sr_Latn_XK' locale func New() locales.Translator { return &sr_Latn_XK{ - locale: "sr_Latn_XK", + locale: "sr_Latn_XK", + plurals: []locales.PluralRule{2, 4, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sr_Latn_XK) Locale() string { - return l.locale +func (t *sr_Latn_XK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sr_Latn_XK) CardinalPluralRule(num string) (locales.PluralRule, error) { - - f, err := locales.F(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// Plurals returns the list of plurals associated with 'sr_Latn_XK' +func (t *sr_Latn_XK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_XK' +func (t *sr_Latn_XK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) if (v == 0 && i%10 == 1 && i%100 != 11) || (f%10 == 1 && f%100 != 11) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if (v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14) || (f%10 >= 2 && f%10 <= 4 && f%100 < 12 && f%100 > 14) { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sv/sv.go b/resources/locales/sv/sv.go index 8e4ce0d..c0a3c96 100644 --- a/resources/locales/sv/sv.go +++ b/resources/locales/sv/sv.go @@ -1,38 +1,55 @@ package sv import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sv struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sv' locale func New() locales.Translator { return &sv{ - locale: "sv", + locale: "sv", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0xe2, 0x80, 0x8f, 0xe2, 0x88, 0x92}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sv) Locale() string { - return l.locale +func (t *sv) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sv) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sv' +func (t *sv) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sv' +func (t *sv) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sv_AX/sv_AX.go b/resources/locales/sv_AX/sv_AX.go index a70b939..8322467 100644 --- a/resources/locales/sv_AX/sv_AX.go +++ b/resources/locales/sv_AX/sv_AX.go @@ -1,38 +1,55 @@ package sv_AX import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sv_AX struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sv_AX' locale func New() locales.Translator { return &sv_AX{ - locale: "sv_AX", + locale: "sv_AX", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sv_AX) Locale() string { - return l.locale +func (t *sv_AX) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sv_AX) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sv_AX' +func (t *sv_AX) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sv_AX' +func (t *sv_AX) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sv_FI/sv_FI.go b/resources/locales/sv_FI/sv_FI.go index 0b3e0f9..569a9c7 100644 --- a/resources/locales/sv_FI/sv_FI.go +++ b/resources/locales/sv_FI/sv_FI.go @@ -1,38 +1,55 @@ package sv_FI import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sv_FI struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sv_FI' locale func New() locales.Translator { return &sv_FI{ - locale: "sv_FI", + locale: "sv_FI", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sv_FI) Locale() string { - return l.locale +func (t *sv_FI) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sv_FI) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sv_FI' +func (t *sv_FI) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sv_FI' +func (t *sv_FI) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sv_SE/sv_SE.go b/resources/locales/sv_SE/sv_SE.go index dcc41a2..f25f4f7 100644 --- a/resources/locales/sv_SE/sv_SE.go +++ b/resources/locales/sv_SE/sv_SE.go @@ -1,38 +1,55 @@ package sv_SE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sv_SE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sv_SE' locale func New() locales.Translator { return &sv_SE{ - locale: "sv_SE", + locale: "sv_SE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x66, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x32, 0x7d}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sv_SE) Locale() string { - return l.locale +func (t *sv_SE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sv_SE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sv_SE' +func (t *sv_SE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sv_SE' +func (t *sv_SE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sw/sw.go b/resources/locales/sw/sw.go index e53d5e9..e536878 100644 --- a/resources/locales/sw/sw.go +++ b/resources/locales/sw/sw.go @@ -1,38 +1,55 @@ package sw import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sw struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sw' locale func New() locales.Translator { return &sw{ - locale: "sw", + locale: "sw", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sw) Locale() string { - return l.locale +func (t *sw) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sw) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sw' +func (t *sw) Plurals() []locales.PluralRule { + return t.plurals +} - v := locales.V(num) +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sw' +func (t *sw) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sw_CD/sw_CD.go b/resources/locales/sw_CD/sw_CD.go index 16f7071..f4a5712 100644 --- a/resources/locales/sw_CD/sw_CD.go +++ b/resources/locales/sw_CD/sw_CD.go @@ -1,38 +1,55 @@ package sw_CD import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sw_CD struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sw_CD' locale func New() locales.Translator { return &sw_CD{ - locale: "sw_CD", + locale: "sw_CD", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sw_CD) Locale() string { - return l.locale +func (t *sw_CD) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sw_CD) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sw_CD' +func (t *sw_CD) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sw_CD' +func (t *sw_CD) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sw_KE/sw_KE.go b/resources/locales/sw_KE/sw_KE.go index f122737..43f91e8 100644 --- a/resources/locales/sw_KE/sw_KE.go +++ b/resources/locales/sw_KE/sw_KE.go @@ -1,38 +1,55 @@ package sw_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sw_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sw_KE' locale func New() locales.Translator { return &sw_KE{ - locale: "sw_KE", + locale: "sw_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sw_KE) Locale() string { - return l.locale +func (t *sw_KE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sw_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sw_KE' +func (t *sw_KE) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sw_KE' +func (t *sw_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sw_TZ/sw_TZ.go b/resources/locales/sw_TZ/sw_TZ.go index fbd15ad..f1b90b6 100644 --- a/resources/locales/sw_TZ/sw_TZ.go +++ b/resources/locales/sw_TZ/sw_TZ.go @@ -1,38 +1,55 @@ package sw_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sw_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sw_TZ' locale func New() locales.Translator { return &sw_TZ{ - locale: "sw_TZ", + locale: "sw_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *sw_TZ) Locale() string { - return l.locale +func (t *sw_TZ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sw_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sw_TZ' +func (t *sw_TZ) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sw_TZ' +func (t *sw_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/sw_UG/sw_UG.go b/resources/locales/sw_UG/sw_UG.go index 5185517..fa3c03c 100644 --- a/resources/locales/sw_UG/sw_UG.go +++ b/resources/locales/sw_UG/sw_UG.go @@ -1,38 +1,55 @@ package sw_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type sw_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'sw_UG' locale func New() locales.Translator { return &sw_UG{ - locale: "sw_UG", + locale: "sw_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *sw_UG) Locale() string { - return l.locale +func (t *sw_UG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *sw_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'sw_UG' +func (t *sw_UG) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'sw_UG' +func (t *sw_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ta/ta.go b/resources/locales/ta/ta.go index a6913fe..2f09d80 100644 --- a/resources/locales/ta/ta.go +++ b/resources/locales/ta/ta.go @@ -1,36 +1,54 @@ package ta import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ta struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ta' locale func New() locales.Translator { return &ta{ - locale: "ta", + locale: "ta", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ta) Locale() string { - return l.locale +func (t *ta) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ta' +func (t *ta) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ta) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ta' +func (t *ta) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ta_IN/ta_IN.go b/resources/locales/ta_IN/ta_IN.go index c9c2cb0..55692ed 100644 --- a/resources/locales/ta_IN/ta_IN.go +++ b/resources/locales/ta_IN/ta_IN.go @@ -1,36 +1,54 @@ package ta_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ta_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ta_IN' locale func New() locales.Translator { return &ta_IN{ - locale: "ta_IN", + locale: "ta_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ta_IN) Locale() string { - return l.locale +func (t *ta_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ta_IN' +func (t *ta_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ta_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ta_IN' +func (t *ta_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ta_LK/ta_LK.go b/resources/locales/ta_LK/ta_LK.go index 3a90096..01d192d 100644 --- a/resources/locales/ta_LK/ta_LK.go +++ b/resources/locales/ta_LK/ta_LK.go @@ -1,36 +1,54 @@ package ta_LK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ta_LK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ta_LK' locale func New() locales.Translator { return &ta_LK{ - locale: "ta_LK", + locale: "ta_LK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ta_LK) Locale() string { - return l.locale +func (t *ta_LK) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ta_LK' +func (t *ta_LK) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ta_LK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ta_LK' +func (t *ta_LK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ta_MY/ta_MY.go b/resources/locales/ta_MY/ta_MY.go index dc145ac..2c70072 100644 --- a/resources/locales/ta_MY/ta_MY.go +++ b/resources/locales/ta_MY/ta_MY.go @@ -1,36 +1,54 @@ package ta_MY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ta_MY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ta_MY' locale func New() locales.Translator { return &ta_MY{ - locale: "ta_MY", + locale: "ta_MY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ta_MY) Locale() string { - return l.locale +func (t *ta_MY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ta_MY' +func (t *ta_MY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ta_MY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ta_MY' +func (t *ta_MY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ta_SG/ta_SG.go b/resources/locales/ta_SG/ta_SG.go index 1314e61..67ad6e9 100644 --- a/resources/locales/ta_SG/ta_SG.go +++ b/resources/locales/ta_SG/ta_SG.go @@ -1,36 +1,54 @@ package ta_SG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ta_SG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ta_SG' locale func New() locales.Translator { return &ta_SG{ - locale: "ta_SG", + locale: "ta_SG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ta_SG) Locale() string { - return l.locale +func (t *ta_SG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ta_SG' +func (t *ta_SG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ta_SG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ta_SG' +func (t *ta_SG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/te/te.go b/resources/locales/te/te.go index b25e9af..bb87645 100644 --- a/resources/locales/te/te.go +++ b/resources/locales/te/te.go @@ -1,36 +1,54 @@ package te import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type te struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'te' locale func New() locales.Translator { return &te{ - locale: "te", + locale: "te", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *te) Locale() string { - return l.locale +func (t *te) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'te' +func (t *te) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *te) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'te' +func (t *te) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/te_IN/te_IN.go b/resources/locales/te_IN/te_IN.go index 9ce4721..5396bd9 100644 --- a/resources/locales/te_IN/te_IN.go +++ b/resources/locales/te_IN/te_IN.go @@ -1,36 +1,54 @@ package te_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type te_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'te_IN' locale func New() locales.Translator { return &te_IN{ - locale: "te_IN", + locale: "te_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *te_IN) Locale() string { - return l.locale +func (t *te_IN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'te_IN' +func (t *te_IN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *te_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'te_IN' +func (t *te_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/teo/teo.go b/resources/locales/teo/teo.go index 01043ac..868e855 100644 --- a/resources/locales/teo/teo.go +++ b/resources/locales/teo/teo.go @@ -1,36 +1,54 @@ package teo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type teo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'teo' locale func New() locales.Translator { return &teo{ - locale: "teo", + locale: "teo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *teo) Locale() string { - return l.locale +func (t *teo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'teo' +func (t *teo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *teo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'teo' +func (t *teo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/teo_KE/teo_KE.go b/resources/locales/teo_KE/teo_KE.go index 4ced716..617ac09 100644 --- a/resources/locales/teo_KE/teo_KE.go +++ b/resources/locales/teo_KE/teo_KE.go @@ -1,36 +1,54 @@ package teo_KE import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type teo_KE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'teo_KE' locale func New() locales.Translator { return &teo_KE{ - locale: "teo_KE", + locale: "teo_KE", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *teo_KE) Locale() string { - return l.locale +func (t *teo_KE) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'teo_KE' +func (t *teo_KE) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *teo_KE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'teo_KE' +func (t *teo_KE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/teo_UG/teo_UG.go b/resources/locales/teo_UG/teo_UG.go index 135ee45..e97f6aa 100644 --- a/resources/locales/teo_UG/teo_UG.go +++ b/resources/locales/teo_UG/teo_UG.go @@ -1,36 +1,54 @@ package teo_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type teo_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'teo_UG' locale func New() locales.Translator { return &teo_UG{ - locale: "teo_UG", + locale: "teo_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *teo_UG) Locale() string { - return l.locale +func (t *teo_UG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'teo_UG' +func (t *teo_UG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *teo_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'teo_UG' +func (t *teo_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/th/th.go b/resources/locales/th/th.go index bb06932..f6e0d39 100644 --- a/resources/locales/th/th.go +++ b/resources/locales/th/th.go @@ -1,27 +1,43 @@ package th -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type th struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'th' locale func New() locales.Translator { return &th{ - locale: "th", + locale: "th", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *th) Locale() string { - return l.locale +func (t *th) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *th) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'th' +func (t *th) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'th' +func (t *th) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/th_TH/th_TH.go b/resources/locales/th_TH/th_TH.go index 2fa78f6..719fdca 100644 --- a/resources/locales/th_TH/th_TH.go +++ b/resources/locales/th_TH/th_TH.go @@ -1,27 +1,43 @@ package th_TH -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type th_TH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'th_TH' locale func New() locales.Translator { return &th_TH{ - locale: "th_TH", + locale: "th_TH", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *th_TH) Locale() string { - return l.locale +func (t *th_TH) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *th_TH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'th_TH' +func (t *th_TH) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'th_TH' +func (t *th_TH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/ti/ti.go b/resources/locales/ti/ti.go index 522c0ff..0747f17 100644 --- a/resources/locales/ti/ti.go +++ b/resources/locales/ti/ti.go @@ -1,36 +1,54 @@ package ti import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ti struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ti' locale func New() locales.Translator { return &ti{ - locale: "ti", + locale: "ti", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ti) Locale() string { - return l.locale +func (t *ti) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ti' +func (t *ti) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ti) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ti' +func (t *ti) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ti_ER/ti_ER.go b/resources/locales/ti_ER/ti_ER.go index 67fe65a..a957f2d 100644 --- a/resources/locales/ti_ER/ti_ER.go +++ b/resources/locales/ti_ER/ti_ER.go @@ -1,36 +1,54 @@ package ti_ER import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ti_ER struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ti_ER' locale func New() locales.Translator { return &ti_ER{ - locale: "ti_ER", + locale: "ti_ER", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ti_ER) Locale() string { - return l.locale +func (t *ti_ER) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ti_ER' +func (t *ti_ER) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ti_ER) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ti_ER' +func (t *ti_ER) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ti_ET/ti_ET.go b/resources/locales/ti_ET/ti_ET.go index fcd95ee..8691bb0 100644 --- a/resources/locales/ti_ET/ti_ET.go +++ b/resources/locales/ti_ET/ti_ET.go @@ -1,36 +1,54 @@ package ti_ET import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ti_ET struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ti_ET' locale func New() locales.Translator { return &ti_ET{ - locale: "ti_ET", + locale: "ti_ET", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ti_ET) Locale() string { - return l.locale +func (t *ti_ET) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ti_ET' +func (t *ti_ET) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ti_ET) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ti_ET' +func (t *ti_ET) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n >= 0 && n <= 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/tk/tk.go b/resources/locales/tk/tk.go index 09e94fb..2835f47 100644 --- a/resources/locales/tk/tk.go +++ b/resources/locales/tk/tk.go @@ -1,36 +1,54 @@ package tk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tk' locale func New() locales.Translator { return &tk{ - locale: "tk", + locale: "tk", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *tk) Locale() string { - return l.locale +func (t *tk) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tk' +func (t *tk) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tk) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tk' +func (t *tk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/tk_TM/tk_TM.go b/resources/locales/tk_TM/tk_TM.go index 5baf325..476c345 100644 --- a/resources/locales/tk_TM/tk_TM.go +++ b/resources/locales/tk_TM/tk_TM.go @@ -1,36 +1,54 @@ package tk_TM import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tk_TM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tk_TM' locale func New() locales.Translator { return &tk_TM{ - locale: "tk_TM", + locale: "tk_TM", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *tk_TM) Locale() string { - return l.locale +func (t *tk_TM) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tk_TM' +func (t *tk_TM) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tk_TM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tk_TM' +func (t *tk_TM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/to/to.go b/resources/locales/to/to.go index 33991f1..0b71d65 100644 --- a/resources/locales/to/to.go +++ b/resources/locales/to/to.go @@ -1,27 +1,43 @@ package to -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type to struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'to' locale func New() locales.Translator { return &to{ - locale: "to", + locale: "to", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *to) Locale() string { - return l.locale +func (t *to) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *to) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'to' +func (t *to) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'to' +func (t *to) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/to_TO/to_TO.go b/resources/locales/to_TO/to_TO.go index bc3d12e..45bda84 100644 --- a/resources/locales/to_TO/to_TO.go +++ b/resources/locales/to_TO/to_TO.go @@ -1,27 +1,43 @@ package to_TO -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type to_TO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'to_TO' locale func New() locales.Translator { return &to_TO{ - locale: "to_TO", + locale: "to_TO", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *to_TO) Locale() string { - return l.locale +func (t *to_TO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *to_TO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'to_TO' +func (t *to_TO) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'to_TO' +func (t *to_TO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/tr/tr.go b/resources/locales/tr/tr.go index 3d6ad46..d9d6be2 100644 --- a/resources/locales/tr/tr.go +++ b/resources/locales/tr/tr.go @@ -1,36 +1,54 @@ package tr import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tr struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tr' locale func New() locales.Translator { return &tr{ - locale: "tr", + locale: "tr", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *tr) Locale() string { - return l.locale +func (t *tr) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tr' +func (t *tr) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tr) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tr' +func (t *tr) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/tr_CY/tr_CY.go b/resources/locales/tr_CY/tr_CY.go index 9caa140..8e9b50c 100644 --- a/resources/locales/tr_CY/tr_CY.go +++ b/resources/locales/tr_CY/tr_CY.go @@ -1,36 +1,54 @@ package tr_CY import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tr_CY struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tr_CY' locale func New() locales.Translator { return &tr_CY{ - locale: "tr_CY", + locale: "tr_CY", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *tr_CY) Locale() string { - return l.locale +func (t *tr_CY) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tr_CY' +func (t *tr_CY) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tr_CY) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tr_CY' +func (t *tr_CY) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/tr_TR/tr_TR.go b/resources/locales/tr_TR/tr_TR.go index adfeceb..b2351ee 100644 --- a/resources/locales/tr_TR/tr_TR.go +++ b/resources/locales/tr_TR/tr_TR.go @@ -1,36 +1,54 @@ package tr_TR import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tr_TR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tr_TR' locale func New() locales.Translator { return &tr_TR{ - locale: "tr_TR", + locale: "tr_TR", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *tr_TR) Locale() string { - return l.locale +func (t *tr_TR) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tr_TR' +func (t *tr_TR) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tr_TR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tr_TR' +func (t *tr_TR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/twq/twq.go b/resources/locales/twq/twq.go index eac3f7b..7a45c68 100644 --- a/resources/locales/twq/twq.go +++ b/resources/locales/twq/twq.go @@ -1,26 +1,43 @@ package twq -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type twq struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'twq' locale func New() locales.Translator { return &twq{ - locale: "twq", + locale: "twq", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *twq) Locale() string { - return l.locale +func (t *twq) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *twq) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'twq' +func (t *twq) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'twq' +func (t *twq) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/twq_NE/twq_NE.go b/resources/locales/twq_NE/twq_NE.go index b6de844..106aa28 100644 --- a/resources/locales/twq_NE/twq_NE.go +++ b/resources/locales/twq_NE/twq_NE.go @@ -1,26 +1,43 @@ package twq_NE -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type twq_NE struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'twq_NE' locale func New() locales.Translator { return &twq_NE{ - locale: "twq_NE", + locale: "twq_NE", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *twq_NE) Locale() string { - return l.locale +func (t *twq_NE) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *twq_NE) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'twq_NE' +func (t *twq_NE) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'twq_NE' +func (t *twq_NE) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/tzm/tzm.go b/resources/locales/tzm/tzm.go index 9aa62e0..4a73f32 100644 --- a/resources/locales/tzm/tzm.go +++ b/resources/locales/tzm/tzm.go @@ -1,36 +1,54 @@ package tzm import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tzm struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tzm' locale func New() locales.Translator { return &tzm{ - locale: "tzm", + locale: "tzm", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *tzm) Locale() string { - return l.locale +func (t *tzm) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tzm' +func (t *tzm) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tzm) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tzm' +func (t *tzm) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if (n >= 0 && n <= 1) || (n >= 11 && n <= 99) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/tzm_MA/tzm_MA.go b/resources/locales/tzm_MA/tzm_MA.go index 53de933..4044e30 100644 --- a/resources/locales/tzm_MA/tzm_MA.go +++ b/resources/locales/tzm_MA/tzm_MA.go @@ -1,36 +1,54 @@ package tzm_MA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type tzm_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'tzm_MA' locale func New() locales.Translator { return &tzm_MA{ - locale: "tzm_MA", + locale: "tzm_MA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *tzm_MA) Locale() string { - return l.locale +func (t *tzm_MA) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'tzm_MA' +func (t *tzm_MA) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *tzm_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'tzm_MA' +func (t *tzm_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if (n >= 0 && n <= 1) || (n >= 11 && n <= 99) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ug/ug.go b/resources/locales/ug/ug.go index 6fdcd88..b735676 100644 --- a/resources/locales/ug/ug.go +++ b/resources/locales/ug/ug.go @@ -1,36 +1,54 @@ package ug import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ug struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ug' locale func New() locales.Translator { return &ug{ - locale: "ug", + locale: "ug", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ug) Locale() string { - return l.locale +func (t *ug) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ug' +func (t *ug) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ug) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ug' +func (t *ug) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ug_CN/ug_CN.go b/resources/locales/ug_CN/ug_CN.go index c0c755e..ba52fae 100644 --- a/resources/locales/ug_CN/ug_CN.go +++ b/resources/locales/ug_CN/ug_CN.go @@ -1,36 +1,54 @@ package ug_CN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ug_CN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ug_CN' locale func New() locales.Translator { return &ug_CN{ - locale: "ug_CN", + locale: "ug_CN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *ug_CN) Locale() string { - return l.locale +func (t *ug_CN) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'ug_CN' +func (t *ug_CN) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ug_CN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ug_CN' +func (t *ug_CN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uk/uk.go b/resources/locales/uk/uk.go index 17a8034..571064b 100644 --- a/resources/locales/uk/uk.go +++ b/resources/locales/uk/uk.go @@ -1,42 +1,59 @@ package uk import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uk struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uk' locale func New() locales.Translator { return &uk{ - locale: "uk", + locale: "uk", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uk) Locale() string { - return l.locale +func (t *uk) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uk) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'uk' +func (t *uk) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uk' +func (t *uk) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uk_UA/uk_UA.go b/resources/locales/uk_UA/uk_UA.go index 16fc14a..f8d6739 100644 --- a/resources/locales/uk_UA/uk_UA.go +++ b/resources/locales/uk_UA/uk_UA.go @@ -1,42 +1,59 @@ package uk_UA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uk_UA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uk_UA' locale func New() locales.Translator { return &uk_UA{ - locale: "uk_UA", + locale: "uk_UA", + plurals: []locales.PluralRule{2, 4, 5, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uk_UA) Locale() string { - return l.locale +func (t *uk_UA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uk_UA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'uk_UA' +func (t *uk_UA) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uk_UA' +func (t *uk_UA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if v == 0 && i%10 == 1 && i%100 != 11 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } else if v == 0 && i%10 >= 2 && i%10 <= 4 && i%100 < 12 && i%100 > 14 { - return locales.PluralRuleFew, nil + return locales.PluralRuleFew } else if (v == 0 && i%10 == 0) || (v == 0 && i%10 >= 5 && i%10 <= 9) || (v == 0 && i%100 >= 11 && i%100 <= 14) { - return locales.PluralRuleMany, nil + return locales.PluralRuleMany } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ur/ur.go b/resources/locales/ur/ur.go index 7546bf9..c4b14ab 100644 --- a/resources/locales/ur/ur.go +++ b/resources/locales/ur/ur.go @@ -1,38 +1,55 @@ package ur import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ur struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ur' locale func New() locales.Translator { return &ur{ - locale: "ur", + locale: "ur", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0xe2, 0x80, 0x8e, 0x2d, 0xe2, 0x80, 0x8e}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ur) Locale() string { - return l.locale +func (t *ur) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ur) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ur' +func (t *ur) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ur' +func (t *ur) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ur_IN/ur_IN.go b/resources/locales/ur_IN/ur_IN.go index 5208820..e852c61 100644 --- a/resources/locales/ur_IN/ur_IN.go +++ b/resources/locales/ur_IN/ur_IN.go @@ -1,38 +1,55 @@ package ur_IN import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ur_IN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ur_IN' locale func New() locales.Translator { return &ur_IN{ - locale: "ur_IN", + locale: "ur_IN", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ur_IN) Locale() string { - return l.locale +func (t *ur_IN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ur_IN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ur_IN' +func (t *ur_IN) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ur_IN' +func (t *ur_IN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/ur_PK/ur_PK.go b/resources/locales/ur_PK/ur_PK.go index 3c5b472..4db4ca0 100644 --- a/resources/locales/ur_PK/ur_PK.go +++ b/resources/locales/ur_PK/ur_PK.go @@ -1,38 +1,55 @@ package ur_PK import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type ur_PK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'ur_PK' locale func New() locales.Translator { return &ur_PK{ - locale: "ur_PK", + locale: "ur_PK", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x2c, 0x20, 0x30, 0x78, 0x32, 0x64, 0x2c, 0x20, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x65, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *ur_PK) Locale() string { - return l.locale +func (t *ur_PK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *ur_PK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'ur_PK' +func (t *ur_PK) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'ur_PK' +func (t *ur_PK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz/uz.go b/resources/locales/uz/uz.go index 674b29f..d036b17 100644 --- a/resources/locales/uz/uz.go +++ b/resources/locales/uz/uz.go @@ -1,36 +1,54 @@ package uz import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz' locale func New() locales.Translator { return &uz{ - locale: "uz", + locale: "uz", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz) Locale() string { - return l.locale +func (t *uz) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz' +func (t *uz) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz' +func (t *uz) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Arab/uz_Arab.go b/resources/locales/uz_Arab/uz_Arab.go index 8551e44..69618ba 100644 --- a/resources/locales/uz_Arab/uz_Arab.go +++ b/resources/locales/uz_Arab/uz_Arab.go @@ -1,36 +1,54 @@ package uz_Arab import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Arab struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Arab' locale func New() locales.Translator { return &uz_Arab{ - locale: "uz_Arab", + locale: "uz_Arab", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz_Arab) Locale() string { - return l.locale +func (t *uz_Arab) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Arab' +func (t *uz_Arab) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Arab) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab' +func (t *uz_Arab) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Arab_AF/uz_Arab_AF.go b/resources/locales/uz_Arab_AF/uz_Arab_AF.go index 7bc5425..3cc5194 100644 --- a/resources/locales/uz_Arab_AF/uz_Arab_AF.go +++ b/resources/locales/uz_Arab_AF/uz_Arab_AF.go @@ -1,36 +1,54 @@ package uz_Arab_AF import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Arab_AF struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Arab_AF' locale func New() locales.Translator { return &uz_Arab_AF{ - locale: "uz_Arab_AF", + locale: "uz_Arab_AF", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz_Arab_AF) Locale() string { - return l.locale +func (t *uz_Arab_AF) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Arab_AF' +func (t *uz_Arab_AF) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Arab_AF) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab_AF' +func (t *uz_Arab_AF) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Cyrl/uz_Cyrl.go b/resources/locales/uz_Cyrl/uz_Cyrl.go index 2d9a0d5..5b60e71 100644 --- a/resources/locales/uz_Cyrl/uz_Cyrl.go +++ b/resources/locales/uz_Cyrl/uz_Cyrl.go @@ -1,36 +1,54 @@ package uz_Cyrl import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Cyrl struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Cyrl' locale func New() locales.Translator { return &uz_Cyrl{ - locale: "uz_Cyrl", + locale: "uz_Cyrl", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0xd9, 0xab}, + group: []byte{0xd9, 0xac}, + minus: []byte{0x2d}, + percent: []byte{0xd9, 0xaa}, + perMille: []byte{0xd8, 0x89}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz_Cyrl) Locale() string { - return l.locale +func (t *uz_Cyrl) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Cyrl' +func (t *uz_Cyrl) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Cyrl) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl' +func (t *uz_Cyrl) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go b/resources/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go index 7673a51..7cb1276 100644 --- a/resources/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go +++ b/resources/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go @@ -1,36 +1,54 @@ package uz_Cyrl_UZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Cyrl_UZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Cyrl_UZ' locale func New() locales.Translator { return &uz_Cyrl_UZ{ - locale: "uz_Cyrl_UZ", + locale: "uz_Cyrl_UZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *uz_Cyrl_UZ) Locale() string { - return l.locale +func (t *uz_Cyrl_UZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Cyrl_UZ' +func (t *uz_Cyrl_UZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Cyrl_UZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl_UZ' +func (t *uz_Cyrl_UZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Latn/uz_Latn.go b/resources/locales/uz_Latn/uz_Latn.go index 93f776f..873f8d5 100644 --- a/resources/locales/uz_Latn/uz_Latn.go +++ b/resources/locales/uz_Latn/uz_Latn.go @@ -1,36 +1,54 @@ package uz_Latn import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Latn' locale func New() locales.Translator { return &uz_Latn{ - locale: "uz_Latn", + locale: "uz_Latn", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz_Latn) Locale() string { - return l.locale +func (t *uz_Latn) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Latn' +func (t *uz_Latn) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn' +func (t *uz_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/uz_Latn_UZ/uz_Latn_UZ.go b/resources/locales/uz_Latn_UZ/uz_Latn_UZ.go index 814d166..65f9d6b 100644 --- a/resources/locales/uz_Latn_UZ/uz_Latn_UZ.go +++ b/resources/locales/uz_Latn_UZ/uz_Latn_UZ.go @@ -1,36 +1,54 @@ package uz_Latn_UZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type uz_Latn_UZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'uz_Latn_UZ' locale func New() locales.Translator { return &uz_Latn_UZ{ - locale: "uz_Latn_UZ", + locale: "uz_Latn_UZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x62, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x39, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x61, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x64, 0x38, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x39, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *uz_Latn_UZ) Locale() string { - return l.locale +func (t *uz_Latn_UZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'uz_Latn_UZ' +func (t *uz_Latn_UZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *uz_Latn_UZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn_UZ' +func (t *uz_Latn_UZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/vai/vai.go b/resources/locales/vai/vai.go index 48eb5b3..691f7cd 100644 --- a/resources/locales/vai/vai.go +++ b/resources/locales/vai/vai.go @@ -1,26 +1,43 @@ package vai -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vai struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vai' locale func New() locales.Translator { return &vai{ - locale: "vai", + locale: "vai", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vai) Locale() string { - return l.locale +func (t *vai) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vai) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vai' +func (t *vai) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vai' +func (t *vai) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/vai_Latn/vai_Latn.go b/resources/locales/vai_Latn/vai_Latn.go index 324b144..c4cadc1 100644 --- a/resources/locales/vai_Latn/vai_Latn.go +++ b/resources/locales/vai_Latn/vai_Latn.go @@ -1,26 +1,43 @@ package vai_Latn -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vai_Latn struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vai_Latn' locale func New() locales.Translator { return &vai_Latn{ - locale: "vai_Latn", + locale: "vai_Latn", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vai_Latn) Locale() string { - return l.locale +func (t *vai_Latn) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vai_Latn) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vai_Latn' +func (t *vai_Latn) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn' +func (t *vai_Latn) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/vai_Latn_LR/vai_Latn_LR.go b/resources/locales/vai_Latn_LR/vai_Latn_LR.go index e1c5137..62380b5 100644 --- a/resources/locales/vai_Latn_LR/vai_Latn_LR.go +++ b/resources/locales/vai_Latn_LR/vai_Latn_LR.go @@ -1,26 +1,43 @@ package vai_Latn_LR -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vai_Latn_LR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vai_Latn_LR' locale func New() locales.Translator { return &vai_Latn_LR{ - locale: "vai_Latn_LR", + locale: "vai_Latn_LR", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *vai_Latn_LR) Locale() string { - return l.locale +func (t *vai_Latn_LR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vai_Latn_LR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vai_Latn_LR' +func (t *vai_Latn_LR) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn_LR' +func (t *vai_Latn_LR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/vai_Vaii/vai_Vaii.go b/resources/locales/vai_Vaii/vai_Vaii.go index 104d372..21dcd3a 100644 --- a/resources/locales/vai_Vaii/vai_Vaii.go +++ b/resources/locales/vai_Vaii/vai_Vaii.go @@ -1,26 +1,43 @@ package vai_Vaii -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vai_Vaii struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vai_Vaii' locale func New() locales.Translator { return &vai_Vaii{ - locale: "vai_Vaii", + locale: "vai_Vaii", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *vai_Vaii) Locale() string { - return l.locale +func (t *vai_Vaii) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vai_Vaii) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vai_Vaii' +func (t *vai_Vaii) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii' +func (t *vai_Vaii) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/vai_Vaii_LR/vai_Vaii_LR.go b/resources/locales/vai_Vaii_LR/vai_Vaii_LR.go index 34d9f55..4e97d48 100644 --- a/resources/locales/vai_Vaii_LR/vai_Vaii_LR.go +++ b/resources/locales/vai_Vaii_LR/vai_Vaii_LR.go @@ -1,26 +1,43 @@ package vai_Vaii_LR -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vai_Vaii_LR struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vai_Vaii_LR' locale func New() locales.Translator { return &vai_Vaii_LR{ - locale: "vai_Vaii_LR", + locale: "vai_Vaii_LR", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vai_Vaii_LR) Locale() string { - return l.locale +func (t *vai_Vaii_LR) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vai_Vaii_LR) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vai_Vaii_LR' +func (t *vai_Vaii_LR) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii_LR' +func (t *vai_Vaii_LR) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/vi/vi.go b/resources/locales/vi/vi.go index 052c3f2..634f312 100644 --- a/resources/locales/vi/vi.go +++ b/resources/locales/vi/vi.go @@ -1,27 +1,43 @@ package vi -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vi struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vi' locale func New() locales.Translator { return &vi{ - locale: "vi", + locale: "vi", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2c}, + group: []byte{0x2e}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vi) Locale() string { - return l.locale +func (t *vi) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vi) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vi' +func (t *vi) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vi' +func (t *vi) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/vi_VN/vi_VN.go b/resources/locales/vi_VN/vi_VN.go index 58095ee..33ace8a 100644 --- a/resources/locales/vi_VN/vi_VN.go +++ b/resources/locales/vi_VN/vi_VN.go @@ -1,27 +1,43 @@ package vi_VN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type vi_VN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vi_VN' locale func New() locales.Translator { return &vi_VN{ - locale: "vi_VN", + locale: "vi_VN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *vi_VN) Locale() string { - return l.locale +func (t *vi_VN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vi_VN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'vi_VN' +func (t *vi_VN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vi_VN' +func (t *vi_VN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/vo/vo.go b/resources/locales/vo/vo.go index cfc563d..7dce2ae 100644 --- a/resources/locales/vo/vo.go +++ b/resources/locales/vo/vo.go @@ -1,36 +1,54 @@ package vo import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type vo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vo' locale func New() locales.Translator { return &vo{ - locale: "vo", + locale: "vo", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vo) Locale() string { - return l.locale +func (t *vo) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'vo' +func (t *vo) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vo' +func (t *vo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/vo_001/vo_001.go b/resources/locales/vo_001/vo_001.go index 04a1fa4..8822906 100644 --- a/resources/locales/vo_001/vo_001.go +++ b/resources/locales/vo_001/vo_001.go @@ -1,36 +1,54 @@ package vo_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type vo_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vo_001' locale func New() locales.Translator { return &vo_001{ - locale: "vo_001", + locale: "vo_001", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vo_001) Locale() string { - return l.locale +func (t *vo_001) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'vo_001' +func (t *vo_001) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vo_001) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vo_001' +func (t *vo_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/vun/vun.go b/resources/locales/vun/vun.go index 6a0d44d..6f9a863 100644 --- a/resources/locales/vun/vun.go +++ b/resources/locales/vun/vun.go @@ -1,36 +1,54 @@ package vun import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type vun struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vun' locale func New() locales.Translator { return &vun{ - locale: "vun", + locale: "vun", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vun) Locale() string { - return l.locale +func (t *vun) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'vun' +func (t *vun) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vun) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vun' +func (t *vun) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/vun_TZ/vun_TZ.go b/resources/locales/vun_TZ/vun_TZ.go index c10bef8..63d9b5f 100644 --- a/resources/locales/vun_TZ/vun_TZ.go +++ b/resources/locales/vun_TZ/vun_TZ.go @@ -1,36 +1,54 @@ package vun_TZ import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type vun_TZ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'vun_TZ' locale func New() locales.Translator { return &vun_TZ{ - locale: "vun_TZ", + locale: "vun_TZ", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *vun_TZ) Locale() string { - return l.locale +func (t *vun_TZ) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'vun_TZ' +func (t *vun_TZ) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *vun_TZ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'vun_TZ' +func (t *vun_TZ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/wae/wae.go b/resources/locales/wae/wae.go index 9967c6a..f02612f 100644 --- a/resources/locales/wae/wae.go +++ b/resources/locales/wae/wae.go @@ -1,36 +1,54 @@ package wae import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type wae struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'wae' locale func New() locales.Translator { return &wae{ - locale: "wae", + locale: "wae", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2c}, + group: []byte{0xe2, 0x80, 0x99}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *wae) Locale() string { - return l.locale +func (t *wae) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'wae' +func (t *wae) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *wae) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'wae' +func (t *wae) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/wae_CH/wae_CH.go b/resources/locales/wae_CH/wae_CH.go index c50324f..6d11897 100644 --- a/resources/locales/wae_CH/wae_CH.go +++ b/resources/locales/wae_CH/wae_CH.go @@ -1,36 +1,54 @@ package wae_CH import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type wae_CH struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'wae_CH' locale func New() locales.Translator { return &wae_CH{ - locale: "wae_CH", + locale: "wae_CH", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x39, 0x39, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *wae_CH) Locale() string { - return l.locale +func (t *wae_CH) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'wae_CH' +func (t *wae_CH) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *wae_CH) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'wae_CH' +func (t *wae_CH) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/xog/xog.go b/resources/locales/xog/xog.go index eb961e1..5108533 100644 --- a/resources/locales/xog/xog.go +++ b/resources/locales/xog/xog.go @@ -1,36 +1,54 @@ package xog import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type xog struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'xog' locale func New() locales.Translator { return &xog{ - locale: "xog", + locale: "xog", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *xog) Locale() string { - return l.locale +func (t *xog) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'xog' +func (t *xog) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *xog) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'xog' +func (t *xog) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/xog_UG/xog_UG.go b/resources/locales/xog_UG/xog_UG.go index c881fa7..d768928 100644 --- a/resources/locales/xog_UG/xog_UG.go +++ b/resources/locales/xog_UG/xog_UG.go @@ -1,36 +1,54 @@ package xog_UG import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type xog_UG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'xog_UG' locale func New() locales.Translator { return &xog_UG{ - locale: "xog_UG", + locale: "xog_UG", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *xog_UG) Locale() string { - return l.locale +func (t *xog_UG) Locale() string { + return t.locale +} + +// Plurals returns the list of plurals associated with 'xog_UG' +func (t *xog_UG) Plurals() []locales.PluralRule { + return t.plurals } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *xog_UG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'xog_UG' +func (t *xog_UG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) if n == 1 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/yav/yav.go b/resources/locales/yav/yav.go index 0c5d9c2..a6a4962 100644 --- a/resources/locales/yav/yav.go +++ b/resources/locales/yav/yav.go @@ -1,26 +1,43 @@ package yav -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yav struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yav' locale func New() locales.Translator { return &yav{ - locale: "yav", + locale: "yav", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yav) Locale() string { - return l.locale +func (t *yav) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yav) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yav' +func (t *yav) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yav' +func (t *yav) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/yav_CM/yav_CM.go b/resources/locales/yav_CM/yav_CM.go index 357c1c6..7d100ad 100644 --- a/resources/locales/yav_CM/yav_CM.go +++ b/resources/locales/yav_CM/yav_CM.go @@ -1,26 +1,43 @@ package yav_CM -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yav_CM struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yav_CM' locale func New() locales.Translator { return &yav_CM{ - locale: "yav_CM", + locale: "yav_CM", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yav_CM) Locale() string { - return l.locale +func (t *yav_CM) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yav_CM) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yav_CM' +func (t *yav_CM) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yav_CM' +func (t *yav_CM) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/yi/yi.go b/resources/locales/yi/yi.go index c058e0e..b944ca0 100644 --- a/resources/locales/yi/yi.go +++ b/resources/locales/yi/yi.go @@ -1,38 +1,55 @@ package yi import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type yi struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yi' locale func New() locales.Translator { return &yi{ - locale: "yi", + locale: "yi", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yi) Locale() string { - return l.locale +func (t *yi) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yi) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yi' +func (t *yi) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yi' +func (t *yi) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/yi_001/yi_001.go b/resources/locales/yi_001/yi_001.go index 4302c38..7600125 100644 --- a/resources/locales/yi_001/yi_001.go +++ b/resources/locales/yi_001/yi_001.go @@ -1,38 +1,55 @@ package yi_001 import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type yi_001 struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yi_001' locale func New() locales.Translator { return &yi_001{ - locale: "yi_001", + locale: "yi_001", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yi_001) Locale() string { - return l.locale +func (t *yi_001) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yi_001) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yi_001' +func (t *yi_001) Plurals() []locales.PluralRule { + return t.plurals +} - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yi_001' +func (t *yi_001) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - v := locales.V(num) + n := math.Abs(num) + i := int64(n) if i == 1 && v == 0 { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/yo/yo.go b/resources/locales/yo/yo.go index efe5fd1..0faa3fb 100644 --- a/resources/locales/yo/yo.go +++ b/resources/locales/yo/yo.go @@ -1,27 +1,43 @@ package yo -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yo struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yo' locale func New() locales.Translator { return &yo{ - locale: "yo", + locale: "yo", + plurals: []locales.PluralRule{6}, + decimal: []byte{}, + group: []byte{}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yo) Locale() string { - return l.locale +func (t *yo) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yo) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yo' +func (t *yo) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yo' +func (t *yo) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/yo_BJ/yo_BJ.go b/resources/locales/yo_BJ/yo_BJ.go index e4a7819..6023074 100644 --- a/resources/locales/yo_BJ/yo_BJ.go +++ b/resources/locales/yo_BJ/yo_BJ.go @@ -1,27 +1,43 @@ package yo_BJ -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yo_BJ struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yo_BJ' locale func New() locales.Translator { return &yo_BJ{ - locale: "yo_BJ", + locale: "yo_BJ", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *yo_BJ) Locale() string { - return l.locale +func (t *yo_BJ) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yo_BJ) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yo_BJ' +func (t *yo_BJ) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yo_BJ' +func (t *yo_BJ) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/yo_NG/yo_NG.go b/resources/locales/yo_NG/yo_NG.go index 4e5d776..fa7f200 100644 --- a/resources/locales/yo_NG/yo_NG.go +++ b/resources/locales/yo_NG/yo_NG.go @@ -1,27 +1,43 @@ package yo_NG -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yo_NG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yo_NG' locale func New() locales.Translator { return &yo_NG{ - locale: "yo_NG", + locale: "yo_NG", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *yo_NG) Locale() string { - return l.locale +func (t *yo_NG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yo_NG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yo_NG' +func (t *yo_NG) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yo_NG' +func (t *yo_NG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/yue/yue.go b/resources/locales/yue/yue.go index d96fdd5..d936cf9 100644 --- a/resources/locales/yue/yue.go +++ b/resources/locales/yue/yue.go @@ -1,26 +1,43 @@ package yue -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yue struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yue' locale func New() locales.Translator { return &yue{ - locale: "yue", + locale: "yue", + plurals: nil, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yue) Locale() string { - return l.locale +func (t *yue) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yue) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yue' +func (t *yue) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yue' +func (t *yue) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/yue_HK/yue_HK.go b/resources/locales/yue_HK/yue_HK.go index a8405ea..a7de3c7 100644 --- a/resources/locales/yue_HK/yue_HK.go +++ b/resources/locales/yue_HK/yue_HK.go @@ -1,26 +1,43 @@ package yue_HK -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type yue_HK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'yue_HK' locale func New() locales.Translator { return &yue_HK{ - locale: "yue_HK", + locale: "yue_HK", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *yue_HK) Locale() string { - return l.locale +func (t *yue_HK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *yue_HK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'yue_HK' +func (t *yue_HK) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'yue_HK' +func (t *yue_HK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/zgh/zgh.go b/resources/locales/zgh/zgh.go index 4c5b1ca..dc5ec99 100644 --- a/resources/locales/zgh/zgh.go +++ b/resources/locales/zgh/zgh.go @@ -1,26 +1,43 @@ package zgh -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zgh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zgh' locale func New() locales.Translator { return &zgh{ - locale: "zgh", + locale: "zgh", + plurals: nil, + decimal: []byte{0x2c}, + group: []byte{0xc2, 0xa0}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zgh) Locale() string { - return l.locale +func (t *zgh) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zgh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zgh' +func (t *zgh) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zgh' +func (t *zgh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/zgh_MA/zgh_MA.go b/resources/locales/zgh_MA/zgh_MA.go index 2b58a81..9b44ded 100644 --- a/resources/locales/zgh_MA/zgh_MA.go +++ b/resources/locales/zgh_MA/zgh_MA.go @@ -1,26 +1,43 @@ package zgh_MA -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zgh_MA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zgh_MA' locale func New() locales.Translator { return &zgh_MA{ - locale: "zgh_MA", + locale: "zgh_MA", + plurals: nil, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x63, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x61, 0x30, 0x7d}, + minus: []byte{}, + percent: []byte{}, + perMille: []byte{}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zgh_MA) Locale() string { - return l.locale +func (t *zgh_MA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zgh_MA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zgh_MA' +func (t *zgh_MA) Plurals() []locales.PluralRule { + return t.plurals +} +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zgh_MA' +func (t *zgh_MA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown } diff --git a/resources/locales/zh/zh.go b/resources/locales/zh/zh.go index 8e5c8a1..0889734 100644 --- a/resources/locales/zh/zh.go +++ b/resources/locales/zh/zh.go @@ -1,27 +1,43 @@ package zh -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh' locale func New() locales.Translator { return &zh{ - locale: "zh", + locale: "zh", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh) Locale() string { - return l.locale +func (t *zh) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh' +func (t *zh) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh' +func (t *zh) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hans/zh_Hans.go b/resources/locales/zh_Hans/zh_Hans.go index 018667e..c3a5582 100644 --- a/resources/locales/zh_Hans/zh_Hans.go +++ b/resources/locales/zh_Hans/zh_Hans.go @@ -1,27 +1,43 @@ package zh_Hans -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hans struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hans' locale func New() locales.Translator { return &zh_Hans{ - locale: "zh_Hans", + locale: "zh_Hans", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hans) Locale() string { - return l.locale +func (t *zh_Hans) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hans) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hans' +func (t *zh_Hans) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans' +func (t *zh_Hans) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hans_CN/zh_Hans_CN.go b/resources/locales/zh_Hans_CN/zh_Hans_CN.go index c30a111..43018d2 100644 --- a/resources/locales/zh_Hans_CN/zh_Hans_CN.go +++ b/resources/locales/zh_Hans_CN/zh_Hans_CN.go @@ -1,27 +1,43 @@ package zh_Hans_CN -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hans_CN struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hans_CN' locale func New() locales.Translator { return &zh_Hans_CN{ - locale: "zh_Hans_CN", + locale: "zh_Hans_CN", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hans_CN) Locale() string { - return l.locale +func (t *zh_Hans_CN) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hans_CN) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hans_CN' +func (t *zh_Hans_CN) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_CN' +func (t *zh_Hans_CN) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hans_HK/zh_Hans_HK.go b/resources/locales/zh_Hans_HK/zh_Hans_HK.go index c047360..a6ab092 100644 --- a/resources/locales/zh_Hans_HK/zh_Hans_HK.go +++ b/resources/locales/zh_Hans_HK/zh_Hans_HK.go @@ -1,27 +1,43 @@ package zh_Hans_HK -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hans_HK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hans_HK' locale func New() locales.Translator { return &zh_Hans_HK{ - locale: "zh_Hans_HK", + locale: "zh_Hans_HK", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hans_HK) Locale() string { - return l.locale +func (t *zh_Hans_HK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hans_HK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hans_HK' +func (t *zh_Hans_HK) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_HK' +func (t *zh_Hans_HK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hans_MO/zh_Hans_MO.go b/resources/locales/zh_Hans_MO/zh_Hans_MO.go index 354f1db..f4a849b 100644 --- a/resources/locales/zh_Hans_MO/zh_Hans_MO.go +++ b/resources/locales/zh_Hans_MO/zh_Hans_MO.go @@ -1,27 +1,43 @@ package zh_Hans_MO -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hans_MO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hans_MO' locale func New() locales.Translator { return &zh_Hans_MO{ - locale: "zh_Hans_MO", + locale: "zh_Hans_MO", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hans_MO) Locale() string { - return l.locale +func (t *zh_Hans_MO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hans_MO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hans_MO' +func (t *zh_Hans_MO) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_MO' +func (t *zh_Hans_MO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hans_SG/zh_Hans_SG.go b/resources/locales/zh_Hans_SG/zh_Hans_SG.go index 9b3e91a..2a66795 100644 --- a/resources/locales/zh_Hans_SG/zh_Hans_SG.go +++ b/resources/locales/zh_Hans_SG/zh_Hans_SG.go @@ -1,27 +1,43 @@ package zh_Hans_SG -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hans_SG struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hans_SG' locale func New() locales.Translator { return &zh_Hans_SG{ - locale: "zh_Hans_SG", + locale: "zh_Hans_SG", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hans_SG) Locale() string { - return l.locale +func (t *zh_Hans_SG) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hans_SG) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hans_SG' +func (t *zh_Hans_SG) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_SG' +func (t *zh_Hans_SG) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hant/zh_Hant.go b/resources/locales/zh_Hant/zh_Hant.go index 46325d6..0faf1ac 100644 --- a/resources/locales/zh_Hant/zh_Hant.go +++ b/resources/locales/zh_Hant/zh_Hant.go @@ -1,27 +1,43 @@ package zh_Hant -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hant struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hant' locale func New() locales.Translator { return &zh_Hant{ - locale: "zh_Hant", + locale: "zh_Hant", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *zh_Hant) Locale() string { - return l.locale +func (t *zh_Hant) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hant) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hant' +func (t *zh_Hant) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant' +func (t *zh_Hant) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hant_HK/zh_Hant_HK.go b/resources/locales/zh_Hant_HK/zh_Hant_HK.go index a1f4897..b657ebf 100644 --- a/resources/locales/zh_Hant_HK/zh_Hant_HK.go +++ b/resources/locales/zh_Hant_HK/zh_Hant_HK.go @@ -1,27 +1,43 @@ package zh_Hant_HK -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hant_HK struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hant_HK' locale func New() locales.Translator { return &zh_Hant_HK{ - locale: "zh_Hant_HK", + locale: "zh_Hant_HK", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zh_Hant_HK) Locale() string { - return l.locale +func (t *zh_Hant_HK) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hant_HK) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hant_HK' +func (t *zh_Hant_HK) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_HK' +func (t *zh_Hant_HK) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hant_MO/zh_Hant_MO.go b/resources/locales/zh_Hant_MO/zh_Hant_MO.go index e220e45..7e8f766 100644 --- a/resources/locales/zh_Hant_MO/zh_Hant_MO.go +++ b/resources/locales/zh_Hant_MO/zh_Hant_MO.go @@ -1,27 +1,43 @@ package zh_Hant_MO -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hant_MO struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hant_MO' locale func New() locales.Translator { return &zh_Hant_MO{ - locale: "zh_Hant_MO", + locale: "zh_Hant_MO", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *zh_Hant_MO) Locale() string { - return l.locale +func (t *zh_Hant_MO) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hant_MO) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hant_MO' +func (t *zh_Hant_MO) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_MO' +func (t *zh_Hant_MO) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zh_Hant_TW/zh_Hant_TW.go b/resources/locales/zh_Hant_TW/zh_Hant_TW.go index ad91c1a..bd7a944 100644 --- a/resources/locales/zh_Hant_TW/zh_Hant_TW.go +++ b/resources/locales/zh_Hant_TW/zh_Hant_TW.go @@ -1,27 +1,43 @@ package zh_Hant_TW -import ( - "github.com/go-playground/universal-translator/resources/locales" -) +import "github.com/go-playground/universal-translator/resources/locales" type zh_Hant_TW struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zh_Hant_TW' locale func New() locales.Translator { return &zh_Hant_TW{ - locale: "zh_Hant_TW", + locale: "zh_Hant_TW", + plurals: []locales.PluralRule{6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *zh_Hant_TW) Locale() string { - return l.locale +func (t *zh_Hant_TW) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zh_Hant_TW) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zh_Hant_TW' +func (t *zh_Hant_TW) Plurals() []locales.PluralRule { + return t.plurals +} - return locales.PluralRuleOther, nil +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_TW' +func (t *zh_Hant_TW) cardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther } diff --git a/resources/locales/zu/zu.go b/resources/locales/zu/zu.go index 4aa86d4..2ce3f4c 100644 --- a/resources/locales/zu/zu.go +++ b/resources/locales/zu/zu.go @@ -1,41 +1,55 @@ package zu import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type zu struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zu' locale func New() locales.Translator { return &zu{ - locale: "zu", + locale: "zu", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x2e}, + group: []byte{0x2c}, + minus: []byte{0x2d}, + percent: []byte{0x25}, + perMille: []byte{0xe2, 0x80, 0xb0}, + symbol: []byte{}, } } // Locale returns the current translators string locale -func (l *zu) Locale() string { - return l.locale +func (t *zu) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zu) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zu' +func (t *zu) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zu' +func (t *zu) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther } diff --git a/resources/locales/zu_ZA/zu_ZA.go b/resources/locales/zu_ZA/zu_ZA.go index d44ca4e..c79c6c2 100644 --- a/resources/locales/zu_ZA/zu_ZA.go +++ b/resources/locales/zu_ZA/zu_ZA.go @@ -1,41 +1,55 @@ package zu_ZA import ( + "math" + "github.com/go-playground/universal-translator/resources/locales" ) type zu_ZA struct { - locale string + locale string + plurals []locales.PluralRule + decimal []byte + group []byte + minus []byte + percent []byte + perMille []byte + symbol []byte } // New returns a new instance of translator for the 'zu_ZA' locale func New() locales.Translator { return &zu_ZA{ - locale: "zu_ZA", + locale: "zu_ZA", + plurals: []locales.PluralRule{2, 6}, + decimal: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x65, 0x7d}, + group: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x63, 0x7d}, + minus: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x64, 0x7d}, + percent: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x32, 0x35, 0x7d}, + perMille: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x30, 0x78, 0x65, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x38, 0x30, 0x2c, 0x20, 0x30, 0x78, 0x62, 0x30, 0x7d}, + symbol: []byte{0x5b, 0x5d, 0x62, 0x79, 0x74, 0x65, 0x7b, 0x7d}, } } // Locale returns the current translators string locale -func (l *zu_ZA) Locale() string { - return l.locale +func (t *zu_ZA) Locale() string { + return t.locale } -// CardinalPluralRule returns the PluralRule given 'num' -func (l *zu_ZA) CardinalPluralRule(num string) (locales.PluralRule, error) { +// Plurals returns the list of plurals associated with 'zu_ZA' +func (t *zu_ZA) Plurals() []locales.PluralRule { + return t.plurals +} - n, err := locales.N(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } +// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for 'zu_ZA' +func (t *zu_ZA) cardinalPluralRule(num float64, v uint64) locales.PluralRule { - i, err := locales.I(num) - if err != nil { - return locales.PluralRuleUnknown, &locales.ErrBadNumberValue{NumberValue: num, InnerError: err} - } + n := math.Abs(num) + i := int64(n) if (i == 0) || (n == 1) { - return locales.PluralRuleOne, nil + return locales.PluralRuleOne } - return locales.PluralRuleOther, nil + return locales.PluralRuleOther }