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 currencyNegativePrefix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'mas_TZ' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
52 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"},
53 currencyNegativePrefix: "(",
54 currencyNegativeSuffix: ")",
55 monthsAbbreviated: []string{"", "Dal", "Ará", "Ɔɛn", "Doy", "Lép", "Rok", "Sás", "Bɔ́r", "Kús", "Gís", "Shʉ́", "Ntʉ́"},
56 monthsWide: []string{"", "Oladalʉ́", "Arát", "Ɔɛnɨ́ɔɨŋɔk", "Olodoyíóríê inkókúâ", "Oloilépūnyīē inkókúâ", "Kújúɔrɔk", "Mórusásin", "Ɔlɔ́ɨ́bɔ́rárɛ", "Kúshîn", "Olgísan", "Pʉshʉ́ka", "Ntʉ́ŋʉ́s"},
57 daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"},
58 daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"},
59 daysWide: []string{"Jumapílí", "Jumatátu", "Jumane", "Jumatánɔ", "Alaámisi", "Jumáa", "Jumamósi"},
60 periodsAbbreviated: []string{"Ɛnkakɛnyá", "Ɛndámâ"},
61 periodsWide: []string{"Ɛnkakɛnyá", "Ɛndámâ"},
62 erasAbbreviated: []string{"MY", "EY"},
63 erasNarrow: []string{"", ""},
64 erasWide: []string{"Meínō Yɛ́sʉ", "Eínō Yɛ́sʉ"},
65 timezones: map[string]string{"ChST": "ChST", "HEPM": "HEPM", "ACWDT": "ACWDT", "UYST": "UYST", "VET": "VET", "JDT": "JDT", "ART": "ART", "HNCU": "HNCU", "MESZ": "MESZ", "HNT": "HNT", "∅∅∅": "∅∅∅", "EAT": "EAT", "GYT": "GYT", "LHDT": "LHDT", "AEST": "AEST", "PDT": "PDT", "WAT": "WAT", "GMT": "GMT", "IST": "IST", "COT": "COT", "HAT": "HAT", "CLT": "CLT", "HNPM": "HNPM", "SRT": "SRT", "HADT": "HADT", "HENOMX": "HENOMX", "SAST": "SAST", "HKT": "HKT", "HKST": "HKST", "ACDT": "ACDT", "CAT": "CAT", "WEZ": "WEZ", "HECU": "HECU", "NZST": "NZST", "NZDT": "NZDT", "OEZ": "OEZ", "GFT": "GFT", "CLST": "CLST", "EST": "EST", "AKDT": "AKDT", "PST": "PST", "ACWST": "ACWST", "HNOG": "HNOG", "MST": "MST", "AWST": "AWST", "WAST": "WAST", "MEZ": "MEZ", "HAST": "HAST", "WARST": "WARST", "HNNOMX": "HNNOMX", "OESZ": "OESZ", "ADT": "ADT", "ARST": "ARST", "HEEG": "HEEG", "CHADT": "CHADT", "TMT": "TMT", "WITA": "WITA", "AEDT": "AEDT", "COST": "COST", "WIB": "WIB", "HNPMX": "HNPMX", "CST": "CST", "WIT": "WIT", "WART": "WART", "JST": "JST", "LHST": "LHST", "EDT": "EDT", "AKST": "AKST", "ECT": "ECT", "CHAST": "CHAST", "BOT": "BOT", "MDT": "MDT", "AST": "AST", "ACST": "ACST", "SGT": "SGT", "HEPMX": "HEPMX", "CDT": "CDT", "UYT": "UYT", "HNEG": "HNEG", "WESZ": "WESZ", "BT": "BT", "AWDT": "AWDT", "MYT": "MYT", "TMST": "TMST", "HEOG": "HEOG"},
69 // Locale returns the current translators string locale
70 func (mas *mas_TZ) Locale() string {
74 // PluralsCardinal returns the list of cardinal plural rules associated with 'mas_TZ'
75 func (mas *mas_TZ) PluralsCardinal() []locales.PluralRule {
76 return mas.pluralsCardinal
79 // PluralsOrdinal returns the list of ordinal plural rules associated with 'mas_TZ'
80 func (mas *mas_TZ) PluralsOrdinal() []locales.PluralRule {
81 return mas.pluralsOrdinal
84 // PluralsRange returns the list of range plural rules associated with 'mas_TZ'
85 func (mas *mas_TZ) PluralsRange() []locales.PluralRule {
86 return mas.pluralsRange
89 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mas_TZ'
90 func (mas *mas_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
95 return locales.PluralRuleOne
98 return locales.PluralRuleOther
101 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mas_TZ'
102 func (mas *mas_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
103 return locales.PluralRuleUnknown
106 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mas_TZ'
107 func (mas *mas_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
108 return locales.PluralRuleUnknown
111 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
112 func (mas *mas_TZ) MonthAbbreviated(month time.Month) string {
113 return mas.monthsAbbreviated[month]
116 // MonthsAbbreviated returns the locales abbreviated months
117 func (mas *mas_TZ) MonthsAbbreviated() []string {
118 return mas.monthsAbbreviated[1:]
121 // MonthNarrow returns the locales narrow month given the 'month' provided
122 func (mas *mas_TZ) MonthNarrow(month time.Month) string {
123 return mas.monthsNarrow[month]
126 // MonthsNarrow returns the locales narrow months
127 func (mas *mas_TZ) MonthsNarrow() []string {
131 // MonthWide returns the locales wide month given the 'month' provided
132 func (mas *mas_TZ) MonthWide(month time.Month) string {
133 return mas.monthsWide[month]
136 // MonthsWide returns the locales wide months
137 func (mas *mas_TZ) MonthsWide() []string {
138 return mas.monthsWide[1:]
141 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
142 func (mas *mas_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
143 return mas.daysAbbreviated[weekday]
146 // WeekdaysAbbreviated returns the locales abbreviated weekdays
147 func (mas *mas_TZ) WeekdaysAbbreviated() []string {
148 return mas.daysAbbreviated
151 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
152 func (mas *mas_TZ) WeekdayNarrow(weekday time.Weekday) string {
153 return mas.daysNarrow[weekday]
156 // WeekdaysNarrow returns the locales narrow weekdays
157 func (mas *mas_TZ) WeekdaysNarrow() []string {
158 return mas.daysNarrow
161 // WeekdayShort returns the locales short weekday given the 'weekday' provided
162 func (mas *mas_TZ) WeekdayShort(weekday time.Weekday) string {
163 return mas.daysShort[weekday]
166 // WeekdaysShort returns the locales short weekdays
167 func (mas *mas_TZ) WeekdaysShort() []string {
171 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
172 func (mas *mas_TZ) WeekdayWide(weekday time.Weekday) string {
173 return mas.daysWide[weekday]
176 // WeekdaysWide returns the locales wide weekdays
177 func (mas *mas_TZ) WeekdaysWide() []string {
181 // Decimal returns the decimal point of number
182 func (mas *mas_TZ) Decimal() string {
186 // Group returns the group of number
187 func (mas *mas_TZ) Group() string {
191 // Group returns the minus sign of number
192 func (mas *mas_TZ) Minus() string {
196 // FmtNumber returns 'num' with digits/precision of 'v' for 'mas_TZ' and handles both Whole and Real numbers based on 'v'
197 func (mas *mas_TZ) FmtNumber(num float64, v uint64) string {
199 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 // FmtPercent returns 'num' with digits/precision of 'v' for 'mas_TZ' and handles both Whole and Real numbers based on 'v'
203 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
204 func (mas *mas_TZ) FmtPercent(num float64, v uint64) string {
205 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
208 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mas_TZ'
209 func (mas *mas_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
211 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212 symbol := mas.currencies[currency]
213 l := len(s) + len(symbol) + 0
216 b := make([]byte, 0, l)
218 for i := len(s) - 1; i >= 0; i-- {
221 b = append(b, mas.decimal[0])
228 b = append(b, mas.group[0])
238 for j := len(symbol) - 1; j >= 0; j-- {
239 b = append(b, symbol[j])
243 b = append(b, mas.minus[0])
247 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
248 b[i], b[j] = b[j], b[i]
254 b = append(b, mas.decimal...)
257 for i := 0; i < 2-int(v); i++ {
265 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mas_TZ'
266 // in accounting notation.
267 func (mas *mas_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
269 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270 symbol := mas.currencies[currency]
271 l := len(s) + len(symbol) + 2
274 b := make([]byte, 0, l)
276 for i := len(s) - 1; i >= 0; i-- {
279 b = append(b, mas.decimal[0])
286 b = append(b, mas.group[0])
298 for j := len(symbol) - 1; j >= 0; j-- {
299 b = append(b, symbol[j])
302 b = append(b, mas.currencyNegativePrefix[0])
306 for j := len(symbol) - 1; j >= 0; j-- {
307 b = append(b, symbol[j])
313 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
314 b[i], b[j] = b[j], b[i]
320 b = append(b, mas.decimal...)
323 for i := 0; i < 2-int(v); i++ {
329 b = append(b, mas.currencyNegativeSuffix...)
335 // FmtDateShort returns the short date representation of 't' for 'mas_TZ'
336 func (mas *mas_TZ) FmtDateShort(t time.Time) string {
338 b := make([]byte, 0, 32)
344 b = strconv.AppendInt(b, int64(t.Day()), 10)
345 b = append(b, []byte{0x2f}...)
351 b = strconv.AppendInt(b, int64(t.Month()), 10)
353 b = append(b, []byte{0x2f}...)
356 b = strconv.AppendInt(b, int64(t.Year()), 10)
358 b = strconv.AppendInt(b, int64(-t.Year()), 10)
364 // FmtDateMedium returns the medium date representation of 't' for 'mas_TZ'
365 func (mas *mas_TZ) FmtDateMedium(t time.Time) string {
367 b := make([]byte, 0, 32)
369 b = strconv.AppendInt(b, int64(t.Day()), 10)
370 b = append(b, []byte{0x20}...)
371 b = append(b, mas.monthsAbbreviated[t.Month()]...)
372 b = append(b, []byte{0x20}...)
375 b = strconv.AppendInt(b, int64(t.Year()), 10)
377 b = strconv.AppendInt(b, int64(-t.Year()), 10)
383 // FmtDateLong returns the long date representation of 't' for 'mas_TZ'
384 func (mas *mas_TZ) FmtDateLong(t time.Time) string {
386 b := make([]byte, 0, 32)
388 b = strconv.AppendInt(b, int64(t.Day()), 10)
389 b = append(b, []byte{0x20}...)
390 b = append(b, mas.monthsWide[t.Month()]...)
391 b = append(b, []byte{0x20}...)
394 b = strconv.AppendInt(b, int64(t.Year()), 10)
396 b = strconv.AppendInt(b, int64(-t.Year()), 10)
402 // FmtDateFull returns the full date representation of 't' for 'mas_TZ'
403 func (mas *mas_TZ) FmtDateFull(t time.Time) string {
405 b := make([]byte, 0, 32)
407 b = append(b, mas.daysWide[t.Weekday()]...)
408 b = append(b, []byte{0x2c, 0x20}...)
409 b = strconv.AppendInt(b, int64(t.Day()), 10)
410 b = append(b, []byte{0x20}...)
411 b = append(b, mas.monthsWide[t.Month()]...)
412 b = append(b, []byte{0x20}...)
415 b = strconv.AppendInt(b, int64(t.Year()), 10)
417 b = strconv.AppendInt(b, int64(-t.Year()), 10)
423 // FmtTimeShort returns the short time representation of 't' for 'mas_TZ'
424 func (mas *mas_TZ) FmtTimeShort(t time.Time) string {
426 b := make([]byte, 0, 32)
432 b = strconv.AppendInt(b, int64(t.Hour()), 10)
433 b = append(b, mas.timeSeparator...)
439 b = strconv.AppendInt(b, int64(t.Minute()), 10)
444 // FmtTimeMedium returns the medium time representation of 't' for 'mas_TZ'
445 func (mas *mas_TZ) FmtTimeMedium(t time.Time) string {
447 b := make([]byte, 0, 32)
453 b = strconv.AppendInt(b, int64(t.Hour()), 10)
454 b = append(b, mas.timeSeparator...)
460 b = strconv.AppendInt(b, int64(t.Minute()), 10)
461 b = append(b, mas.timeSeparator...)
467 b = strconv.AppendInt(b, int64(t.Second()), 10)
472 // FmtTimeLong returns the long time representation of 't' for 'mas_TZ'
473 func (mas *mas_TZ) FmtTimeLong(t time.Time) string {
475 b := make([]byte, 0, 32)
481 b = strconv.AppendInt(b, int64(t.Hour()), 10)
482 b = append(b, mas.timeSeparator...)
488 b = strconv.AppendInt(b, int64(t.Minute()), 10)
489 b = append(b, mas.timeSeparator...)
495 b = strconv.AppendInt(b, int64(t.Second()), 10)
496 b = append(b, []byte{0x20}...)
504 // FmtTimeFull returns the full time representation of 't' for 'mas_TZ'
505 func (mas *mas_TZ) FmtTimeFull(t time.Time) string {
507 b := make([]byte, 0, 32)
513 b = strconv.AppendInt(b, int64(t.Hour()), 10)
514 b = append(b, mas.timeSeparator...)
520 b = strconv.AppendInt(b, int64(t.Minute()), 10)
521 b = append(b, mas.timeSeparator...)
527 b = strconv.AppendInt(b, int64(t.Second()), 10)
528 b = append(b, []byte{0x20}...)
532 if btz, ok := mas.timezones[tz]; ok {
533 b = append(b, btz...)