OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-playground / locales / mas / mas.go
1 package mas
2
3 import (
4         "math"
5         "strconv"
6         "time"
7
8         "github.com/go-playground/locales"
9         "github.com/go-playground/locales/currency"
10 )
11
12 type mas struct {
13         locale                 string
14         pluralsCardinal        []locales.PluralRule
15         pluralsOrdinal         []locales.PluralRule
16         pluralsRange           []locales.PluralRule
17         decimal                string
18         group                  string
19         minus                  string
20         percent                string
21         perMille               string
22         timeSeparator          string
23         inifinity              string
24         currencies             []string // idx = enum of currency code
25         currencyNegativePrefix string
26         currencyNegativeSuffix string
27         monthsAbbreviated      []string
28         monthsNarrow           []string
29         monthsWide             []string
30         daysAbbreviated        []string
31         daysNarrow             []string
32         daysShort              []string
33         daysWide               []string
34         periodsAbbreviated     []string
35         periodsNarrow          []string
36         periodsShort           []string
37         periodsWide            []string
38         erasAbbreviated        []string
39         erasNarrow             []string
40         erasWide               []string
41         timezones              map[string]string
42 }
43
44 // New returns a new instance of translator for the 'mas' locale
45 func New() locales.Translator {
46         return &mas{
47                 locale:                 "mas",
48                 pluralsCardinal:        []locales.PluralRule{2, 6},
49                 pluralsOrdinal:         nil,
50                 pluralsRange:           nil,
51                 timeSeparator:          ":",
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", "Ksh", "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", "TZS", "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{"TMT": "TMT", "TMST": "TMST", "OESZ": "OESZ", "AEST": "AEST", "HAST": "HAST", "HNNOMX": "HNNOMX", "HEOG": "HEOG", "HEPMX": "HEPMX", "PDT": "PDT", "CDT": "CDT", "HENOMX": "HENOMX", "JST": "JST", "ART": "ART", "EST": "EST", "HEPM": "HEPM", "WART": "WART", "IST": "IST", "BOT": "BOT", "AWST": "AWST", "ADT": "ADT", "COST": "COST", "MST": "MST", "ARST": "ARST", "SAST": "SAST", "ACST": "ACST", "HECU": "HECU", "CST": "CST", "ACWST": "ACWST", "MESZ": "MESZ", "MDT": "MDT", "MEZ": "MEZ", "AKST": "AKST", "WEZ": "WEZ", "MYT": "MYT", "OEZ": "OEZ", "LHDT": "LHDT", "AST": "AST", "WAST": "WAST", "CAT": "CAT", "WESZ": "WESZ", "HNCU": "HNCU", "WIT": "WIT", "SGT": "SGT", "ChST": "ChST", "CHADT": "CHADT", "SRT": "SRT", "HNT": "HNT", "HAT": "HAT", "HKT": "HKT", "PST": "PST", "UYT": "UYT", "NZDT": "NZDT", "LHST": "LHST", "WAT": "WAT", "HEEG": "HEEG", "GFT": "GFT", "ACDT": "ACDT", "HNPM": "HNPM", "BT": "BT", "HADT": "HADT", "HNOG": "HNOG", "GYT": "GYT", "AKDT": "AKDT", "HNPMX": "HNPMX", "WIB": "WIB", "ACWDT": "ACWDT", "HNEG": "HNEG", "COT": "COT", "EDT": "EDT", "ECT": "ECT", "GMT": "GMT", "∅∅∅": "∅∅∅", "NZST": "NZST", "WARST": "WARST", "VET": "VET", "JDT": "JDT", "CLT": "CLT", "CHAST": "CHAST", "UYST": "UYST", "WITA": "WITA", "AEDT": "AEDT", "EAT": "EAT", "HKST": "HKST", "CLST": "CLST", "AWDT": "AWDT"},
66         }
67 }
68
69 // Locale returns the current translators string locale
70 func (mas *mas) Locale() string {
71         return mas.locale
72 }
73
74 // PluralsCardinal returns the list of cardinal plural rules associated with 'mas'
75 func (mas *mas) PluralsCardinal() []locales.PluralRule {
76         return mas.pluralsCardinal
77 }
78
79 // PluralsOrdinal returns the list of ordinal plural rules associated with 'mas'
80 func (mas *mas) PluralsOrdinal() []locales.PluralRule {
81         return mas.pluralsOrdinal
82 }
83
84 // PluralsRange returns the list of range plural rules associated with 'mas'
85 func (mas *mas) PluralsRange() []locales.PluralRule {
86         return mas.pluralsRange
87 }
88
89 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mas'
90 func (mas *mas) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
91
92         n := math.Abs(num)
93
94         if n == 1 {
95                 return locales.PluralRuleOne
96         }
97
98         return locales.PluralRuleOther
99 }
100
101 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mas'
102 func (mas *mas) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
103         return locales.PluralRuleUnknown
104 }
105
106 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mas'
107 func (mas *mas) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
108         return locales.PluralRuleUnknown
109 }
110
111 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
112 func (mas *mas) MonthAbbreviated(month time.Month) string {
113         return mas.monthsAbbreviated[month]
114 }
115
116 // MonthsAbbreviated returns the locales abbreviated months
117 func (mas *mas) MonthsAbbreviated() []string {
118         return mas.monthsAbbreviated[1:]
119 }
120
121 // MonthNarrow returns the locales narrow month given the 'month' provided
122 func (mas *mas) MonthNarrow(month time.Month) string {
123         return mas.monthsNarrow[month]
124 }
125
126 // MonthsNarrow returns the locales narrow months
127 func (mas *mas) MonthsNarrow() []string {
128         return nil
129 }
130
131 // MonthWide returns the locales wide month given the 'month' provided
132 func (mas *mas) MonthWide(month time.Month) string {
133         return mas.monthsWide[month]
134 }
135
136 // MonthsWide returns the locales wide months
137 func (mas *mas) MonthsWide() []string {
138         return mas.monthsWide[1:]
139 }
140
141 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
142 func (mas *mas) WeekdayAbbreviated(weekday time.Weekday) string {
143         return mas.daysAbbreviated[weekday]
144 }
145
146 // WeekdaysAbbreviated returns the locales abbreviated weekdays
147 func (mas *mas) WeekdaysAbbreviated() []string {
148         return mas.daysAbbreviated
149 }
150
151 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
152 func (mas *mas) WeekdayNarrow(weekday time.Weekday) string {
153         return mas.daysNarrow[weekday]
154 }
155
156 // WeekdaysNarrow returns the locales narrow weekdays
157 func (mas *mas) WeekdaysNarrow() []string {
158         return mas.daysNarrow
159 }
160
161 // WeekdayShort returns the locales short weekday given the 'weekday' provided
162 func (mas *mas) WeekdayShort(weekday time.Weekday) string {
163         return mas.daysShort[weekday]
164 }
165
166 // WeekdaysShort returns the locales short weekdays
167 func (mas *mas) WeekdaysShort() []string {
168         return mas.daysShort
169 }
170
171 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
172 func (mas *mas) WeekdayWide(weekday time.Weekday) string {
173         return mas.daysWide[weekday]
174 }
175
176 // WeekdaysWide returns the locales wide weekdays
177 func (mas *mas) WeekdaysWide() []string {
178         return mas.daysWide
179 }
180
181 // Decimal returns the decimal point of number
182 func (mas *mas) Decimal() string {
183         return mas.decimal
184 }
185
186 // Group returns the group of number
187 func (mas *mas) Group() string {
188         return mas.group
189 }
190
191 // Group returns the minus sign of number
192 func (mas *mas) Minus() string {
193         return mas.minus
194 }
195
196 // FmtNumber returns 'num' with digits/precision of 'v' for 'mas' and handles both Whole and Real numbers based on 'v'
197 func (mas *mas) FmtNumber(num float64, v uint64) string {
198
199         return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
200 }
201
202 // FmtPercent returns 'num' with digits/precision of 'v' for 'mas' 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) FmtPercent(num float64, v uint64) string {
205         return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 }
207
208 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mas'
209 func (mas *mas) FmtCurrency(num float64, v uint64, currency currency.Type) string {
210
211         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212         symbol := mas.currencies[currency]
213         l := len(s) + len(symbol) + 0
214         count := 0
215         inWhole := v == 0
216         b := make([]byte, 0, l)
217
218         for i := len(s) - 1; i >= 0; i-- {
219
220                 if s[i] == '.' {
221                         b = append(b, mas.decimal[0])
222                         inWhole = true
223                         continue
224                 }
225
226                 if inWhole {
227                         if count == 3 {
228                                 b = append(b, mas.group[0])
229                                 count = 1
230                         } else {
231                                 count++
232                         }
233                 }
234
235                 b = append(b, s[i])
236         }
237
238         for j := len(symbol) - 1; j >= 0; j-- {
239                 b = append(b, symbol[j])
240         }
241
242         if num < 0 {
243                 b = append(b, mas.minus[0])
244         }
245
246         // reverse
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]
249         }
250
251         if int(v) < 2 {
252
253                 if v == 0 {
254                         b = append(b, mas.decimal...)
255                 }
256
257                 for i := 0; i < 2-int(v); i++ {
258                         b = append(b, '0')
259                 }
260         }
261
262         return string(b)
263 }
264
265 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mas'
266 // in accounting notation.
267 func (mas *mas) FmtAccounting(num float64, v uint64, currency currency.Type) string {
268
269         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270         symbol := mas.currencies[currency]
271         l := len(s) + len(symbol) + 2
272         count := 0
273         inWhole := v == 0
274         b := make([]byte, 0, l)
275
276         for i := len(s) - 1; i >= 0; i-- {
277
278                 if s[i] == '.' {
279                         b = append(b, mas.decimal[0])
280                         inWhole = true
281                         continue
282                 }
283
284                 if inWhole {
285                         if count == 3 {
286                                 b = append(b, mas.group[0])
287                                 count = 1
288                         } else {
289                                 count++
290                         }
291                 }
292
293                 b = append(b, s[i])
294         }
295
296         if num < 0 {
297
298                 for j := len(symbol) - 1; j >= 0; j-- {
299                         b = append(b, symbol[j])
300                 }
301
302                 b = append(b, mas.currencyNegativePrefix[0])
303
304         } else {
305
306                 for j := len(symbol) - 1; j >= 0; j-- {
307                         b = append(b, symbol[j])
308                 }
309
310         }
311
312         // reverse
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]
315         }
316
317         if int(v) < 2 {
318
319                 if v == 0 {
320                         b = append(b, mas.decimal...)
321                 }
322
323                 for i := 0; i < 2-int(v); i++ {
324                         b = append(b, '0')
325                 }
326         }
327
328         if num < 0 {
329                 b = append(b, mas.currencyNegativeSuffix...)
330         }
331
332         return string(b)
333 }
334
335 // FmtDateShort returns the short date representation of 't' for 'mas'
336 func (mas *mas) FmtDateShort(t time.Time) string {
337
338         b := make([]byte, 0, 32)
339
340         if t.Day() < 10 {
341                 b = append(b, '0')
342         }
343
344         b = strconv.AppendInt(b, int64(t.Day()), 10)
345         b = append(b, []byte{0x2f}...)
346
347         if t.Month() < 10 {
348                 b = append(b, '0')
349         }
350
351         b = strconv.AppendInt(b, int64(t.Month()), 10)
352
353         b = append(b, []byte{0x2f}...)
354
355         if t.Year() > 0 {
356                 b = strconv.AppendInt(b, int64(t.Year()), 10)
357         } else {
358                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
359         }
360
361         return string(b)
362 }
363
364 // FmtDateMedium returns the medium date representation of 't' for 'mas'
365 func (mas *mas) FmtDateMedium(t time.Time) string {
366
367         b := make([]byte, 0, 32)
368
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}...)
373
374         if t.Year() > 0 {
375                 b = strconv.AppendInt(b, int64(t.Year()), 10)
376         } else {
377                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
378         }
379
380         return string(b)
381 }
382
383 // FmtDateLong returns the long date representation of 't' for 'mas'
384 func (mas *mas) FmtDateLong(t time.Time) string {
385
386         b := make([]byte, 0, 32)
387
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}...)
392
393         if t.Year() > 0 {
394                 b = strconv.AppendInt(b, int64(t.Year()), 10)
395         } else {
396                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
397         }
398
399         return string(b)
400 }
401
402 // FmtDateFull returns the full date representation of 't' for 'mas'
403 func (mas *mas) FmtDateFull(t time.Time) string {
404
405         b := make([]byte, 0, 32)
406
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}...)
413
414         if t.Year() > 0 {
415                 b = strconv.AppendInt(b, int64(t.Year()), 10)
416         } else {
417                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
418         }
419
420         return string(b)
421 }
422
423 // FmtTimeShort returns the short time representation of 't' for 'mas'
424 func (mas *mas) FmtTimeShort(t time.Time) string {
425
426         b := make([]byte, 0, 32)
427
428         if t.Hour() < 10 {
429                 b = append(b, '0')
430         }
431
432         b = strconv.AppendInt(b, int64(t.Hour()), 10)
433         b = append(b, mas.timeSeparator...)
434
435         if t.Minute() < 10 {
436                 b = append(b, '0')
437         }
438
439         b = strconv.AppendInt(b, int64(t.Minute()), 10)
440
441         return string(b)
442 }
443
444 // FmtTimeMedium returns the medium time representation of 't' for 'mas'
445 func (mas *mas) FmtTimeMedium(t time.Time) string {
446
447         b := make([]byte, 0, 32)
448
449         if t.Hour() < 10 {
450                 b = append(b, '0')
451         }
452
453         b = strconv.AppendInt(b, int64(t.Hour()), 10)
454         b = append(b, mas.timeSeparator...)
455
456         if t.Minute() < 10 {
457                 b = append(b, '0')
458         }
459
460         b = strconv.AppendInt(b, int64(t.Minute()), 10)
461         b = append(b, mas.timeSeparator...)
462
463         if t.Second() < 10 {
464                 b = append(b, '0')
465         }
466
467         b = strconv.AppendInt(b, int64(t.Second()), 10)
468
469         return string(b)
470 }
471
472 // FmtTimeLong returns the long time representation of 't' for 'mas'
473 func (mas *mas) FmtTimeLong(t time.Time) string {
474
475         b := make([]byte, 0, 32)
476
477         if t.Hour() < 10 {
478                 b = append(b, '0')
479         }
480
481         b = strconv.AppendInt(b, int64(t.Hour()), 10)
482         b = append(b, mas.timeSeparator...)
483
484         if t.Minute() < 10 {
485                 b = append(b, '0')
486         }
487
488         b = strconv.AppendInt(b, int64(t.Minute()), 10)
489         b = append(b, mas.timeSeparator...)
490
491         if t.Second() < 10 {
492                 b = append(b, '0')
493         }
494
495         b = strconv.AppendInt(b, int64(t.Second()), 10)
496         b = append(b, []byte{0x20}...)
497
498         tz, _ := t.Zone()
499         b = append(b, tz...)
500
501         return string(b)
502 }
503
504 // FmtTimeFull returns the full time representation of 't' for 'mas'
505 func (mas *mas) FmtTimeFull(t time.Time) string {
506
507         b := make([]byte, 0, 32)
508
509         if t.Hour() < 10 {
510                 b = append(b, '0')
511         }
512
513         b = strconv.AppendInt(b, int64(t.Hour()), 10)
514         b = append(b, mas.timeSeparator...)
515
516         if t.Minute() < 10 {
517                 b = append(b, '0')
518         }
519
520         b = strconv.AppendInt(b, int64(t.Minute()), 10)
521         b = append(b, mas.timeSeparator...)
522
523         if t.Second() < 10 {
524                 b = append(b, '0')
525         }
526
527         b = strconv.AppendInt(b, int64(t.Second()), 10)
528         b = append(b, []byte{0x20}...)
529
530         tz, _ := t.Zone()
531
532         if btz, ok := mas.timezones[tz]; ok {
533                 b = append(b, btz...)
534         } else {
535                 b = append(b, tz...)
536         }
537
538         return string(b)
539 }