OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-playground / locales / kab / kab.go
1 package kab
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 kab 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         monthsAbbreviated  []string
26         monthsNarrow       []string
27         monthsWide         []string
28         daysAbbreviated    []string
29         daysNarrow         []string
30         daysShort          []string
31         daysWide           []string
32         periodsAbbreviated []string
33         periodsNarrow      []string
34         periodsShort       []string
35         periodsWide        []string
36         erasAbbreviated    []string
37         erasNarrow         []string
38         erasWide           []string
39         timezones          map[string]string
40 }
41
42 // New returns a new instance of translator for the 'kab' locale
43 func New() locales.Translator {
44         return &kab{
45                 locale:             "kab",
46                 pluralsCardinal:    []locales.PluralRule{2, 6},
47                 pluralsOrdinal:     nil,
48                 pluralsRange:       nil,
49                 decimal:            ",",
50                 group:              " ",
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", "DA", "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", "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                 monthsAbbreviated:  []string{"", "Yen", "Fur", "Meɣ", "Yeb", "May", "Yun", "Yul", "Ɣuc", "Cte", "Tub", "Nun", "Duǧ"},
54                 monthsNarrow:       []string{"", "Y", "F", "M", "Y", "M", "Y", "Y", "Ɣ", "C", "T", "N", "D"},
55                 monthsWide:         []string{"", "Yennayer", "Fuṛar", "Meɣres", "Yebrir", "Mayyu", "Yunyu", "Yulyu", "Ɣuct", "Ctembeṛ", "Tubeṛ", "Nunembeṛ", "Duǧembeṛ"},
56                 daysAbbreviated:    []string{"Yan", "San", "Kraḍ", "Kuẓ", "Sam", "Sḍis", "Say"},
57                 daysNarrow:         []string{"Y", "S", "K", "K", "S", "S", "S"},
58                 daysWide:           []string{"Yanass", "Sanass", "Kraḍass", "Kuẓass", "Samass", "Sḍisass", "Sayass"},
59                 periodsAbbreviated: []string{"n tufat", "n tmeddit"},
60                 periodsWide:        []string{"n tufat", "n tmeddit"},
61                 erasAbbreviated:    []string{"snd. T.Ɛ", "sld. T.Ɛ"},
62                 erasNarrow:         []string{"", ""},
63                 erasWide:           []string{"send talalit n Ɛisa", "seld talalit n Ɛisa"},
64                 timezones:          map[string]string{"WARST": "WARST", "ADT": "ADT", "CHAST": "CHAST", "SRT": "SRT", "WART": "WART", "HNT": "HNT", "BOT": "BOT", "MDT": "MDT", "HNEG": "HNEG", "ART": "ART", "HAT": "HAT", "WEZ": "WEZ", "HNCU": "HNCU", "CDT": "CDT", "AEST": "AEST", "PST": "PST", "COST": "COST", "TMT": "TMT", "OESZ": "OESZ", "EAT": "EAT", "AKST": "AKST", "ChST": "ChST", "HNPMX": "HNPMX", "UYST": "UYST", "WITA": "WITA", "ARST": "ARST", "CLST": "CLST", "UYT": "UYT", "VET": "VET", "HNNOMX": "HNNOMX", "ACDT": "ACDT", "∅∅∅": "∅∅∅", "SAST": "SAST", "GYT": "GYT", "CST": "CST", "LHST": "LHST", "AST": "AST", "HKT": "HKT", "EST": "EST", "WIB": "WIB", "CHADT": "CHADT", "AWST": "AWST", "CAT": "CAT", "EDT": "EDT", "SGT": "SGT", "HEPM": "HEPM", "PDT": "PDT", "MESZ": "MESZ", "HECU": "HECU", "HKST": "HKST", "ECT": "ECT", "OEZ": "OEZ", "HEOG": "HEOG", "HEEG": "HEEG", "ACWST": "ACWST", "NZST": "NZST", "JDT": "JDT", "MEZ": "MEZ", "WAT": "WAT", "AKDT": "AKDT", "GMT": "GMT", "HNPM": "HNPM", "ACST": "ACST", "HNOG": "HNOG", "COT": "COT", "HEPMX": "HEPMX", "MST": "MST", "NZDT": "NZDT", "LHDT": "LHDT", "JST": "JST", "WAST": "WAST", "CLT": "CLT", "GFT": "GFT", "MYT": "MYT", "HADT": "HADT", "TMST": "TMST", "ACWDT": "ACWDT", "HAST": "HAST", "HENOMX": "HENOMX", "IST": "IST", "AEDT": "AEDT", "BT": "BT", "AWDT": "AWDT", "WIT": "WIT", "WESZ": "WESZ"},
65         }
66 }
67
68 // Locale returns the current translators string locale
69 func (kab *kab) Locale() string {
70         return kab.locale
71 }
72
73 // PluralsCardinal returns the list of cardinal plural rules associated with 'kab'
74 func (kab *kab) PluralsCardinal() []locales.PluralRule {
75         return kab.pluralsCardinal
76 }
77
78 // PluralsOrdinal returns the list of ordinal plural rules associated with 'kab'
79 func (kab *kab) PluralsOrdinal() []locales.PluralRule {
80         return kab.pluralsOrdinal
81 }
82
83 // PluralsRange returns the list of range plural rules associated with 'kab'
84 func (kab *kab) PluralsRange() []locales.PluralRule {
85         return kab.pluralsRange
86 }
87
88 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kab'
89 func (kab *kab) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
90
91         n := math.Abs(num)
92         i := int64(n)
93
94         if i == 0 || i == 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 'kab'
102 func (kab *kab) 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 'kab'
107 func (kab *kab) 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 (kab *kab) MonthAbbreviated(month time.Month) string {
113         return kab.monthsAbbreviated[month]
114 }
115
116 // MonthsAbbreviated returns the locales abbreviated months
117 func (kab *kab) MonthsAbbreviated() []string {
118         return kab.monthsAbbreviated[1:]
119 }
120
121 // MonthNarrow returns the locales narrow month given the 'month' provided
122 func (kab *kab) MonthNarrow(month time.Month) string {
123         return kab.monthsNarrow[month]
124 }
125
126 // MonthsNarrow returns the locales narrow months
127 func (kab *kab) MonthsNarrow() []string {
128         return kab.monthsNarrow[1:]
129 }
130
131 // MonthWide returns the locales wide month given the 'month' provided
132 func (kab *kab) MonthWide(month time.Month) string {
133         return kab.monthsWide[month]
134 }
135
136 // MonthsWide returns the locales wide months
137 func (kab *kab) MonthsWide() []string {
138         return kab.monthsWide[1:]
139 }
140
141 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
142 func (kab *kab) WeekdayAbbreviated(weekday time.Weekday) string {
143         return kab.daysAbbreviated[weekday]
144 }
145
146 // WeekdaysAbbreviated returns the locales abbreviated weekdays
147 func (kab *kab) WeekdaysAbbreviated() []string {
148         return kab.daysAbbreviated
149 }
150
151 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
152 func (kab *kab) WeekdayNarrow(weekday time.Weekday) string {
153         return kab.daysNarrow[weekday]
154 }
155
156 // WeekdaysNarrow returns the locales narrow weekdays
157 func (kab *kab) WeekdaysNarrow() []string {
158         return kab.daysNarrow
159 }
160
161 // WeekdayShort returns the locales short weekday given the 'weekday' provided
162 func (kab *kab) WeekdayShort(weekday time.Weekday) string {
163         return kab.daysShort[weekday]
164 }
165
166 // WeekdaysShort returns the locales short weekdays
167 func (kab *kab) WeekdaysShort() []string {
168         return kab.daysShort
169 }
170
171 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
172 func (kab *kab) WeekdayWide(weekday time.Weekday) string {
173         return kab.daysWide[weekday]
174 }
175
176 // WeekdaysWide returns the locales wide weekdays
177 func (kab *kab) WeekdaysWide() []string {
178         return kab.daysWide
179 }
180
181 // Decimal returns the decimal point of number
182 func (kab *kab) Decimal() string {
183         return kab.decimal
184 }
185
186 // Group returns the group of number
187 func (kab *kab) Group() string {
188         return kab.group
189 }
190
191 // Group returns the minus sign of number
192 func (kab *kab) Minus() string {
193         return kab.minus
194 }
195
196 // FmtNumber returns 'num' with digits/precision of 'v' for 'kab' and handles both Whole and Real numbers based on 'v'
197 func (kab *kab) 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 'kab' 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 (kab *kab) 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 'kab'
209 func (kab *kab) FmtCurrency(num float64, v uint64, currency currency.Type) string {
210
211         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212         symbol := kab.currencies[currency]
213         l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3
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, kab.decimal[0])
222                         inWhole = true
223                         continue
224                 }
225
226                 if inWhole {
227                         if count == 3 {
228                                 for j := len(kab.group) - 1; j >= 0; j-- {
229                                         b = append(b, kab.group[j])
230                                 }
231                                 count = 1
232                         } else {
233                                 count++
234                         }
235                 }
236
237                 b = append(b, s[i])
238         }
239
240         if num < 0 {
241                 b = append(b, kab.minus[0])
242         }
243
244         // reverse
245         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
246                 b[i], b[j] = b[j], b[i]
247         }
248
249         if int(v) < 2 {
250
251                 if v == 0 {
252                         b = append(b, kab.decimal...)
253                 }
254
255                 for i := 0; i < 2-int(v); i++ {
256                         b = append(b, '0')
257                 }
258         }
259
260         b = append(b, symbol...)
261
262         return string(b)
263 }
264
265 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kab'
266 // in accounting notation.
267 func (kab *kab) FmtAccounting(num float64, v uint64, currency currency.Type) string {
268
269         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270         symbol := kab.currencies[currency]
271         l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3
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, kab.decimal[0])
280                         inWhole = true
281                         continue
282                 }
283
284                 if inWhole {
285                         if count == 3 {
286                                 for j := len(kab.group) - 1; j >= 0; j-- {
287                                         b = append(b, kab.group[j])
288                                 }
289                                 count = 1
290                         } else {
291                                 count++
292                         }
293                 }
294
295                 b = append(b, s[i])
296         }
297
298         if num < 0 {
299
300                 b = append(b, kab.minus[0])
301
302         }
303
304         // reverse
305         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
306                 b[i], b[j] = b[j], b[i]
307         }
308
309         if int(v) < 2 {
310
311                 if v == 0 {
312                         b = append(b, kab.decimal...)
313                 }
314
315                 for i := 0; i < 2-int(v); i++ {
316                         b = append(b, '0')
317                 }
318         }
319
320         if num < 0 {
321                 b = append(b, symbol...)
322         } else {
323
324                 b = append(b, symbol...)
325         }
326
327         return string(b)
328 }
329
330 // FmtDateShort returns the short date representation of 't' for 'kab'
331 func (kab *kab) FmtDateShort(t time.Time) string {
332
333         b := make([]byte, 0, 32)
334
335         b = strconv.AppendInt(b, int64(t.Day()), 10)
336         b = append(b, []byte{0x2f}...)
337         b = strconv.AppendInt(b, int64(t.Month()), 10)
338         b = append(b, []byte{0x2f}...)
339
340         if t.Year() > 0 {
341                 b = strconv.AppendInt(b, int64(t.Year()), 10)
342         } else {
343                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
344         }
345
346         return string(b)
347 }
348
349 // FmtDateMedium returns the medium date representation of 't' for 'kab'
350 func (kab *kab) FmtDateMedium(t time.Time) string {
351
352         b := make([]byte, 0, 32)
353
354         b = strconv.AppendInt(b, int64(t.Day()), 10)
355         b = append(b, []byte{0x20}...)
356         b = append(b, kab.monthsAbbreviated[t.Month()]...)
357         b = append(b, []byte{0x2c, 0x20}...)
358
359         if t.Year() > 0 {
360                 b = strconv.AppendInt(b, int64(t.Year()), 10)
361         } else {
362                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
363         }
364
365         return string(b)
366 }
367
368 // FmtDateLong returns the long date representation of 't' for 'kab'
369 func (kab *kab) FmtDateLong(t time.Time) string {
370
371         b := make([]byte, 0, 32)
372
373         b = strconv.AppendInt(b, int64(t.Day()), 10)
374         b = append(b, []byte{0x20}...)
375         b = append(b, kab.monthsWide[t.Month()]...)
376         b = append(b, []byte{0x20}...)
377
378         if t.Year() > 0 {
379                 b = strconv.AppendInt(b, int64(t.Year()), 10)
380         } else {
381                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
382         }
383
384         return string(b)
385 }
386
387 // FmtDateFull returns the full date representation of 't' for 'kab'
388 func (kab *kab) FmtDateFull(t time.Time) string {
389
390         b := make([]byte, 0, 32)
391
392         b = append(b, kab.daysWide[t.Weekday()]...)
393         b = append(b, []byte{0x20}...)
394         b = strconv.AppendInt(b, int64(t.Day()), 10)
395         b = append(b, []byte{0x20}...)
396         b = append(b, kab.monthsWide[t.Month()]...)
397         b = append(b, []byte{0x20}...)
398
399         if t.Year() > 0 {
400                 b = strconv.AppendInt(b, int64(t.Year()), 10)
401         } else {
402                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
403         }
404
405         return string(b)
406 }
407
408 // FmtTimeShort returns the short time representation of 't' for 'kab'
409 func (kab *kab) FmtTimeShort(t time.Time) string {
410
411         b := make([]byte, 0, 32)
412
413         h := t.Hour()
414
415         if h > 12 {
416                 h -= 12
417         }
418
419         b = strconv.AppendInt(b, int64(h), 10)
420         b = append(b, kab.timeSeparator...)
421
422         if t.Minute() < 10 {
423                 b = append(b, '0')
424         }
425
426         b = strconv.AppendInt(b, int64(t.Minute()), 10)
427         b = append(b, []byte{0x20}...)
428
429         if t.Hour() < 12 {
430                 b = append(b, kab.periodsAbbreviated[0]...)
431         } else {
432                 b = append(b, kab.periodsAbbreviated[1]...)
433         }
434
435         return string(b)
436 }
437
438 // FmtTimeMedium returns the medium time representation of 't' for 'kab'
439 func (kab *kab) FmtTimeMedium(t time.Time) string {
440
441         b := make([]byte, 0, 32)
442
443         h := t.Hour()
444
445         if h > 12 {
446                 h -= 12
447         }
448
449         b = strconv.AppendInt(b, int64(h), 10)
450         b = append(b, kab.timeSeparator...)
451
452         if t.Minute() < 10 {
453                 b = append(b, '0')
454         }
455
456         b = strconv.AppendInt(b, int64(t.Minute()), 10)
457         b = append(b, kab.timeSeparator...)
458
459         if t.Second() < 10 {
460                 b = append(b, '0')
461         }
462
463         b = strconv.AppendInt(b, int64(t.Second()), 10)
464         b = append(b, []byte{0x20}...)
465
466         if t.Hour() < 12 {
467                 b = append(b, kab.periodsAbbreviated[0]...)
468         } else {
469                 b = append(b, kab.periodsAbbreviated[1]...)
470         }
471
472         return string(b)
473 }
474
475 // FmtTimeLong returns the long time representation of 't' for 'kab'
476 func (kab *kab) FmtTimeLong(t time.Time) string {
477
478         b := make([]byte, 0, 32)
479
480         h := t.Hour()
481
482         if h > 12 {
483                 h -= 12
484         }
485
486         b = strconv.AppendInt(b, int64(h), 10)
487         b = append(b, kab.timeSeparator...)
488
489         if t.Minute() < 10 {
490                 b = append(b, '0')
491         }
492
493         b = strconv.AppendInt(b, int64(t.Minute()), 10)
494         b = append(b, kab.timeSeparator...)
495
496         if t.Second() < 10 {
497                 b = append(b, '0')
498         }
499
500         b = strconv.AppendInt(b, int64(t.Second()), 10)
501         b = append(b, []byte{0x20}...)
502
503         if t.Hour() < 12 {
504                 b = append(b, kab.periodsAbbreviated[0]...)
505         } else {
506                 b = append(b, kab.periodsAbbreviated[1]...)
507         }
508
509         b = append(b, []byte{0x20}...)
510
511         tz, _ := t.Zone()
512         b = append(b, tz...)
513
514         return string(b)
515 }
516
517 // FmtTimeFull returns the full time representation of 't' for 'kab'
518 func (kab *kab) FmtTimeFull(t time.Time) string {
519
520         b := make([]byte, 0, 32)
521
522         h := t.Hour()
523
524         if h > 12 {
525                 h -= 12
526         }
527
528         b = strconv.AppendInt(b, int64(h), 10)
529         b = append(b, kab.timeSeparator...)
530
531         if t.Minute() < 10 {
532                 b = append(b, '0')
533         }
534
535         b = strconv.AppendInt(b, int64(t.Minute()), 10)
536         b = append(b, kab.timeSeparator...)
537
538         if t.Second() < 10 {
539                 b = append(b, '0')
540         }
541
542         b = strconv.AppendInt(b, int64(t.Second()), 10)
543         b = append(b, []byte{0x20}...)
544
545         if t.Hour() < 12 {
546                 b = append(b, kab.periodsAbbreviated[0]...)
547         } else {
548                 b = append(b, kab.periodsAbbreviated[1]...)
549         }
550
551         b = append(b, []byte{0x20}...)
552
553         tz, _ := t.Zone()
554
555         if btz, ok := kab.timezones[tz]; ok {
556                 b = append(b, btz...)
557         } else {
558                 b = append(b, tz...)
559         }
560
561         return string(b)
562 }