8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
24 currencies []string // idx = enum of currency code
25 monthsAbbreviated []string
28 daysAbbreviated []string
32 periodsAbbreviated []string
33 periodsNarrow []string
36 erasAbbreviated []string
39 timezones map[string]string
42 // New returns a new instance of translator for the 'bez' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 6},
50 currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
51 monthsAbbreviated: []string{"", "Hut", "Vil", "Dat", "Tai", "Han", "Sit", "Sab", "Nan", "Tis", "Kum", "Kmj", "Kmb"},
52 monthsNarrow: []string{"", "H", "V", "D", "T", "H", "S", "S", "N", "T", "K", "K", "K"},
53 monthsWide: []string{"", "pa mwedzi gwa hutala", "pa mwedzi gwa wuvili", "pa mwedzi gwa wudatu", "pa mwedzi gwa wutai", "pa mwedzi gwa wuhanu", "pa mwedzi gwa sita", "pa mwedzi gwa saba", "pa mwedzi gwa nane", "pa mwedzi gwa tisa", "pa mwedzi gwa kumi", "pa mwedzi gwa kumi na moja", "pa mwedzi gwa kumi na mbili"},
54 daysAbbreviated: []string{"Mul", "Vil", "Hiv", "Hid", "Hit", "Hih", "Lem"},
55 daysNarrow: []string{"M", "J", "H", "H", "H", "W", "J"},
56 daysWide: []string{"pa mulungu", "pa shahuviluha", "pa hivili", "pa hidatu", "pa hitayi", "pa hihanu", "pa shahulembela"},
57 periodsAbbreviated: []string{"pamilau", "pamunyi"},
58 periodsWide: []string{"pamilau", "pamunyi"},
59 erasAbbreviated: []string{"KM", "BM"},
60 erasNarrow: []string{"", ""},
61 erasWide: []string{"Kabla ya Mtwaa", "Baada ya Mtwaa"},
62 timezones: map[string]string{"ChST": "ChST", "HNPM": "HNPM", "ACWDT": "ACWDT", "TMST": "TMST", "HKT": "HKT", "COT": "COT", "COST": "COST", "AKDT": "AKDT", "IST": "IST", "HNOG": "HNOG", "HEOG": "HEOG", "WAST": "WAST", "EST": "EST", "ACST": "ACST", "ECT": "ECT", "AWST": "AWST", "CLT": "CLT", "MDT": "MDT", "NZST": "NZST", "ARST": "ARST", "HKST": "HKST", "WIB": "WIB", "AWDT": "AWDT", "ACWST": "ACWST", "PST": "PST", "LHST": "LHST", "AST": "AST", "HEEG": "HEEG", "GYT": "GYT", "HEPMX": "HEPMX", "BT": "BT", "JDT": "JDT", "ACDT": "ACDT", "HEPM": "HEPM", "HADT": "HADT", "LHDT": "LHDT", "OESZ": "OESZ", "WARST": "WARST", "ART": "ART", "EDT": "EDT", "CHADT": "CHADT", "SRT": "SRT", "WITA": "WITA", "JST": "JST", "AEDT": "AEDT", "EAT": "EAT", "∅∅∅": "∅∅∅", "CAT": "CAT", "MESZ": "MESZ", "HAST": "HAST", "CHAST": "CHAST", "WIT": "WIT", "HECU": "HECU", "CDT": "CDT", "HNNOMX": "HNNOMX", "AEST": "AEST", "HNT": "HNT", "AKST": "AKST", "WESZ": "WESZ", "PDT": "PDT", "HNEG": "HNEG", "CLST": "CLST", "BOT": "BOT", "MST": "MST", "WART": "WART", "CST": "CST", "UYST": "UYST", "MEZ": "MEZ", "NZDT": "NZDT", "HAT": "HAT", "WEZ": "WEZ", "GMT": "GMT", "HNPMX": "HNPMX", "HENOMX": "HENOMX", "SAST": "SAST", "GFT": "GFT", "SGT": "SGT", "HNCU": "HNCU", "VET": "VET", "TMT": "TMT", "OEZ": "OEZ", "MYT": "MYT", "UYT": "UYT", "ADT": "ADT", "WAT": "WAT"},
66 // Locale returns the current translators string locale
67 func (bez *bez) Locale() string {
71 // PluralsCardinal returns the list of cardinal plural rules associated with 'bez'
72 func (bez *bez) PluralsCardinal() []locales.PluralRule {
73 return bez.pluralsCardinal
76 // PluralsOrdinal returns the list of ordinal plural rules associated with 'bez'
77 func (bez *bez) PluralsOrdinal() []locales.PluralRule {
78 return bez.pluralsOrdinal
81 // PluralsRange returns the list of range plural rules associated with 'bez'
82 func (bez *bez) PluralsRange() []locales.PluralRule {
83 return bez.pluralsRange
86 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bez'
87 func (bez *bez) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
92 return locales.PluralRuleOne
95 return locales.PluralRuleOther
98 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bez'
99 func (bez *bez) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
103 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bez'
104 func (bez *bez) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
105 return locales.PluralRuleUnknown
108 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
109 func (bez *bez) MonthAbbreviated(month time.Month) string {
110 return bez.monthsAbbreviated[month]
113 // MonthsAbbreviated returns the locales abbreviated months
114 func (bez *bez) MonthsAbbreviated() []string {
115 return bez.monthsAbbreviated[1:]
118 // MonthNarrow returns the locales narrow month given the 'month' provided
119 func (bez *bez) MonthNarrow(month time.Month) string {
120 return bez.monthsNarrow[month]
123 // MonthsNarrow returns the locales narrow months
124 func (bez *bez) MonthsNarrow() []string {
125 return bez.monthsNarrow[1:]
128 // MonthWide returns the locales wide month given the 'month' provided
129 func (bez *bez) MonthWide(month time.Month) string {
130 return bez.monthsWide[month]
133 // MonthsWide returns the locales wide months
134 func (bez *bez) MonthsWide() []string {
135 return bez.monthsWide[1:]
138 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
139 func (bez *bez) WeekdayAbbreviated(weekday time.Weekday) string {
140 return bez.daysAbbreviated[weekday]
143 // WeekdaysAbbreviated returns the locales abbreviated weekdays
144 func (bez *bez) WeekdaysAbbreviated() []string {
145 return bez.daysAbbreviated
148 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
149 func (bez *bez) WeekdayNarrow(weekday time.Weekday) string {
150 return bez.daysNarrow[weekday]
153 // WeekdaysNarrow returns the locales narrow weekdays
154 func (bez *bez) WeekdaysNarrow() []string {
155 return bez.daysNarrow
158 // WeekdayShort returns the locales short weekday given the 'weekday' provided
159 func (bez *bez) WeekdayShort(weekday time.Weekday) string {
160 return bez.daysShort[weekday]
163 // WeekdaysShort returns the locales short weekdays
164 func (bez *bez) WeekdaysShort() []string {
168 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
169 func (bez *bez) WeekdayWide(weekday time.Weekday) string {
170 return bez.daysWide[weekday]
173 // WeekdaysWide returns the locales wide weekdays
174 func (bez *bez) WeekdaysWide() []string {
178 // Decimal returns the decimal point of number
179 func (bez *bez) Decimal() string {
183 // Group returns the group of number
184 func (bez *bez) Group() string {
188 // Group returns the minus sign of number
189 func (bez *bez) Minus() string {
193 // FmtNumber returns 'num' with digits/precision of 'v' for 'bez' and handles both Whole and Real numbers based on 'v'
194 func (bez *bez) FmtNumber(num float64, v uint64) string {
196 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
199 // FmtPercent returns 'num' with digits/precision of 'v' for 'bez' and handles both Whole and Real numbers based on 'v'
200 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
201 func (bez *bez) FmtPercent(num float64, v uint64) string {
202 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bez'
206 func (bez *bez) FmtCurrency(num float64, v uint64, currency currency.Type) string {
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 symbol := bez.currencies[currency]
210 l := len(s) + len(symbol) + 0
213 b := make([]byte, 0, l)
215 for i := len(s) - 1; i >= 0; i-- {
218 b = append(b, bez.decimal[0])
225 b = append(b, bez.group[0])
236 b = append(b, bez.minus[0])
240 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
241 b[i], b[j] = b[j], b[i]
247 b = append(b, bez.decimal...)
250 for i := 0; i < 2-int(v); i++ {
255 b = append(b, symbol...)
260 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bez'
261 // in accounting notation.
262 func (bez *bez) FmtAccounting(num float64, v uint64, currency currency.Type) string {
264 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 symbol := bez.currencies[currency]
266 l := len(s) + len(symbol) + 0
269 b := make([]byte, 0, l)
271 for i := len(s) - 1; i >= 0; i-- {
274 b = append(b, bez.decimal[0])
281 b = append(b, bez.group[0])
293 b = append(b, bez.minus[0])
298 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
299 b[i], b[j] = b[j], b[i]
305 b = append(b, bez.decimal...)
308 for i := 0; i < 2-int(v); i++ {
314 b = append(b, symbol...)
317 b = append(b, symbol...)
323 // FmtDateShort returns the short date representation of 't' for 'bez'
324 func (bez *bez) FmtDateShort(t time.Time) string {
326 b := make([]byte, 0, 32)
332 b = strconv.AppendInt(b, int64(t.Day()), 10)
333 b = append(b, []byte{0x2f}...)
339 b = strconv.AppendInt(b, int64(t.Month()), 10)
341 b = append(b, []byte{0x2f}...)
344 b = strconv.AppendInt(b, int64(t.Year()), 10)
346 b = strconv.AppendInt(b, int64(-t.Year()), 10)
352 // FmtDateMedium returns the medium date representation of 't' for 'bez'
353 func (bez *bez) FmtDateMedium(t time.Time) string {
355 b := make([]byte, 0, 32)
357 b = strconv.AppendInt(b, int64(t.Day()), 10)
358 b = append(b, []byte{0x20}...)
359 b = append(b, bez.monthsAbbreviated[t.Month()]...)
360 b = append(b, []byte{0x20}...)
363 b = strconv.AppendInt(b, int64(t.Year()), 10)
365 b = strconv.AppendInt(b, int64(-t.Year()), 10)
371 // FmtDateLong returns the long date representation of 't' for 'bez'
372 func (bez *bez) FmtDateLong(t time.Time) string {
374 b := make([]byte, 0, 32)
376 b = strconv.AppendInt(b, int64(t.Day()), 10)
377 b = append(b, []byte{0x20}...)
378 b = append(b, bez.monthsWide[t.Month()]...)
379 b = append(b, []byte{0x20}...)
382 b = strconv.AppendInt(b, int64(t.Year()), 10)
384 b = strconv.AppendInt(b, int64(-t.Year()), 10)
390 // FmtDateFull returns the full date representation of 't' for 'bez'
391 func (bez *bez) FmtDateFull(t time.Time) string {
393 b := make([]byte, 0, 32)
395 b = append(b, bez.daysWide[t.Weekday()]...)
396 b = append(b, []byte{0x2c, 0x20}...)
397 b = strconv.AppendInt(b, int64(t.Day()), 10)
398 b = append(b, []byte{0x20}...)
399 b = append(b, bez.monthsWide[t.Month()]...)
400 b = append(b, []byte{0x20}...)
403 b = strconv.AppendInt(b, int64(t.Year()), 10)
405 b = strconv.AppendInt(b, int64(-t.Year()), 10)
411 // FmtTimeShort returns the short time representation of 't' for 'bez'
412 func (bez *bez) FmtTimeShort(t time.Time) string {
414 b := make([]byte, 0, 32)
420 b = strconv.AppendInt(b, int64(t.Hour()), 10)
421 b = append(b, bez.timeSeparator...)
427 b = strconv.AppendInt(b, int64(t.Minute()), 10)
432 // FmtTimeMedium returns the medium time representation of 't' for 'bez'
433 func (bez *bez) FmtTimeMedium(t time.Time) string {
435 b := make([]byte, 0, 32)
441 b = strconv.AppendInt(b, int64(t.Hour()), 10)
442 b = append(b, bez.timeSeparator...)
448 b = strconv.AppendInt(b, int64(t.Minute()), 10)
449 b = append(b, bez.timeSeparator...)
455 b = strconv.AppendInt(b, int64(t.Second()), 10)
460 // FmtTimeLong returns the long time representation of 't' for 'bez'
461 func (bez *bez) FmtTimeLong(t time.Time) string {
463 b := make([]byte, 0, 32)
469 b = strconv.AppendInt(b, int64(t.Hour()), 10)
470 b = append(b, bez.timeSeparator...)
476 b = strconv.AppendInt(b, int64(t.Minute()), 10)
477 b = append(b, bez.timeSeparator...)
483 b = strconv.AppendInt(b, int64(t.Second()), 10)
484 b = append(b, []byte{0x20}...)
492 // FmtTimeFull returns the full time representation of 't' for 'bez'
493 func (bez *bez) FmtTimeFull(t time.Time) string {
495 b := make([]byte, 0, 32)
501 b = strconv.AppendInt(b, int64(t.Hour()), 10)
502 b = append(b, bez.timeSeparator...)
508 b = strconv.AppendInt(b, int64(t.Minute()), 10)
509 b = append(b, bez.timeSeparator...)
515 b = strconv.AppendInt(b, int64(t.Second()), 10)
516 b = append(b, []byte{0x20}...)
520 if btz, ok := bez.timezones[tz]; ok {
521 b = append(b, btz...)