-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
localen.go
181 lines (146 loc) · 5.61 KB
/
localen.go
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package localescompressed
import (
"time"
"github.com/gohugoio/locales"
"github.com/gohugoio/locales/currency"
)
// The following Functions are for overriding, debugging or developing
// with a Translator Locale
// Locale returns the string value of the translator
func (ln *localen) Locale() string {
return ln.fnLocale(ln)
}
// returns an array of cardinal plural rules associated
// with this translator
func (ln *localen) PluralsCardinal() []locales.PluralRule {
return ln.fnPluralsCardinal(ln)
}
// returns an array of ordinal plural rules associated
// with this translator
func (ln *localen) PluralsOrdinal() []locales.PluralRule {
return ln.fnPluralsOrdinal(ln)
}
// returns an array of range plural rules associated
// with this translator
func (ln *localen) PluralsRange() []locales.PluralRule {
return ln.pluralsRange
}
// returns the cardinal PluralRule given 'num' and digits/precision of 'v' for locale
func (ln *localen) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
return ln.fnCardinalPluralRule(ln, num, v)
}
// returns the ordinal PluralRule given 'num' and digits/precision of 'v' for locale
func (ln *localen) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
return ln.fnOrdinalPluralRule(ln, num, v)
}
// returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale
func (ln *localen) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
return ln.fnRangePluralRule(ln, num1, v1, num2, v2)
}
// returns the locales abbreviated month given the 'month' provided
func (ln *localen) MonthAbbreviated(month time.Month) string {
return ln.fnMonthAbbreviated(ln, month)
}
// returns the locales abbreviated months
func (ln *localen) MonthsAbbreviated() []string {
return ln.monthsAbbreviated
}
// returns the locales narrow month given the 'month' provided
func (ln *localen) MonthNarrow(month time.Month) string {
return ln.monthsNarrow[month]
}
// returns the locales narrow months
func (ln *localen) MonthsNarrow() []string {
return ln.monthsNarrow[1:]
}
// returns the locales wide month given the 'month' provided
func (ln *localen) MonthWide(month time.Month) string {
return ln.monthsWide[month]
}
// returns the locales wide months
func (ln *localen) MonthsWide() []string {
return ln.monthsWide[1:]
}
// returns the locales abbreviated weekday given the 'weekday' provided
func (ln *localen) WeekdayAbbreviated(weekday time.Weekday) string {
return ln.fnWeekdayAbbreviated(ln, weekday)
}
// returns the locales abbreviated weekdays
func (ln *localen) WeekdaysAbbreviated() []string {
return ln.daysAbbreviated
}
// returns the locales narrow weekday given the 'weekday' provided
func (ln *localen) WeekdayNarrow(weekday time.Weekday) string {
return ln.daysNarrow[weekday]
}
// WeekdaysNarrowreturns the locales narrow weekdays
func (ln *localen) WeekdaysNarrow() []string {
return ln.daysNarrow
}
// returns the locales short weekday given the 'weekday' provided
func (ln *localen) WeekdayShort(weekday time.Weekday) string {
return ln.daysShort[weekday]
}
// returns the locales short weekdays
func (ln *localen) WeekdaysShort() []string {
return ln.daysShort
}
// returns the locales wide weekday given the 'weekday' provided
func (ln *localen) WeekdayWide(weekday time.Weekday) string {
return ln.daysWide[weekday]
}
// returns the locales wide weekdays
func (ln *localen) WeekdaysWide() []string {
return ln.daysWide
}
// The following Functions are common Formatting functionsfor the Translator's Locale
// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
func (ln *localen) FmtNumber(num float64, v uint64) string {
return ln.fnFmtNumber(ln, num, v)
}
// returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
func (ln *localen) FmtPercent(num float64, v uint64) string {
return ln.fnFmtPercent(ln, num, v)
}
// returns the currency representation of 'num' with digits/precision of 'v' for locale
func (ln *localen) FmtCurrency(num float64, v uint64, currency currency.Type) string {
return ln.fnFmtCurrency(ln, num, v, currency)
}
// returns the currency representation of 'num' with digits/precision of 'v' for locale
// in accounting notation.
func (ln *localen) FmtAccounting(num float64, v uint64, currency currency.Type) string {
return ln.fnFmtAccounting(ln, num, v, currency)
}
// returns the short date representation of 't' for locale
func (ln *localen) FmtDateShort(t time.Time) string {
return ln.fnFmtDateShort(ln, t)
}
// returns the medium date representation of 't' for locale
func (ln *localen) FmtDateMedium(t time.Time) string {
return ln.fnFmtDateMedium(ln, t)
}
// returns the long date representation of 't' for locale
func (ln *localen) FmtDateLong(t time.Time) string {
return ln.fnFmtDateLong(ln, t)
}
// returns the full date representation of 't' for locale
func (ln *localen) FmtDateFull(t time.Time) string {
return ln.fnFmtDateFull(ln, t)
}
// returns the short time representation of 't' for locale
func (ln *localen) FmtTimeShort(t time.Time) string {
return ln.fnFmtTimeShort(ln, t)
}
// returns the medium time representation of 't' for locale
func (ln *localen) FmtTimeMedium(t time.Time) string {
return ln.fnFmtTimeMedium(ln, t)
}
// returns the long time representation of 't' for locale
func (ln *localen) FmtTimeLong(t time.Time) string {
return ln.fnFmtTimeLong(ln, t)
}
// returns the full time representation of 't' for locale
func (ln *localen) FmtTimeFull(t time.Time) string {
return ln.fnFmtTimeFull(ln, t)
}