Welcome to mirror list, hosted at ThFree Co, Russian Federation.

translator.tmpl « cmd - github.com/gohugoio/locales.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bfef339a62dd7ecac45df86a38df8d1e1047d351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{{ define "translator" }}
package {{ .Locale }}

import (
	"math"

	"github.com/go-playground/locales"
)

type {{ .Locale }} struct {
	locale     string
	plurals    []locales.PluralRule
	decimal    []byte
	group      []byte
	minus      []byte
	percent    []byte
	perMille   []byte
	currencies [][]byte // idx = enum of currency code
}

// New returns a new instance of translator for the '{{ .Locale }}' locale
func New() locales.Translator {
	return &{{ .Locale }}{
		locale:   		"{{ .Locale }}",
		plurals:  		{{ .Plurals }},
		decimal:  		{{ .Decimal }},
		group:    		{{ .Group }},
		minus:    		{{ .Minus }},
		percent:  		{{ .Percent }},
		perMille:       {{ .PerMille }},
		currencies:     {{ .Currencies }},
	}
}

// Locale returns the current translators string locale
func(t *{{ .Locale }}) Locale() string {
	return t.locale
}

// PluralsCardinal returns the list of cardinal plural rules associated with '{{ .Locale }}'
func(t *{{ .Locale }}) PluralsCardinal() []locales.PluralRule {
	return t.plurals
}

// cardinalPluralRule returns the PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}'
func(t *{{ .Locale }}) cardinalPluralRule(num float64, v uint64) locales.PluralRule {
	{{ .CardinalFunc }}
}

{{ end }}