OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-playground / locales / mgh / mgh.go
1 package mgh
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 mgh 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         currencyPositivePrefix string
26         currencyPositiveSuffix string
27         currencyNegativePrefix string
28         currencyNegativeSuffix string
29         monthsAbbreviated      []string
30         monthsNarrow           []string
31         monthsWide             []string
32         daysAbbreviated        []string
33         daysNarrow             []string
34         daysShort              []string
35         daysWide               []string
36         periodsAbbreviated     []string
37         periodsNarrow          []string
38         periodsShort           []string
39         periodsWide            []string
40         erasAbbreviated        []string
41         erasNarrow             []string
42         erasWide               []string
43         timezones              map[string]string
44 }
45
46 // New returns a new instance of translator for the 'mgh' locale
47 func New() locales.Translator {
48         return &mgh{
49                 locale:                 "mgh",
50                 pluralsCardinal:        nil,
51                 pluralsOrdinal:         nil,
52                 pluralsRange:           nil,
53                 decimal:                ",",
54                 group:                  ".",
55                 timeSeparator:          ":",
56                 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", "MTn", "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"},
57                 currencyPositivePrefix: " ",
58                 currencyPositiveSuffix: "K",
59                 currencyNegativePrefix: " ",
60                 currencyNegativeSuffix: "K",
61                 monthsAbbreviated:      []string{"", "Kwa", "Una", "Rar", "Che", "Tha", "Moc", "Sab", "Nan", "Tis", "Kum", "Moj", "Yel"},
62                 monthsNarrow:           []string{"", "K", "U", "R", "C", "T", "M", "S", "N", "T", "K", "M", "Y"},
63                 monthsWide:             []string{"", "Mweri wo kwanza", "Mweri wo unayeli", "Mweri wo uneraru", "Mweri wo unecheshe", "Mweri wo unethanu", "Mweri wo thanu na mocha", "Mweri wo saba", "Mweri wo nane", "Mweri wo tisa", "Mweri wo kumi", "Mweri wo kumi na moja", "Mweri wo kumi na yel’li"},
64                 daysAbbreviated:        []string{"Sab", "Jtt", "Jnn", "Jtn", "Ara", "Iju", "Jmo"},
65                 daysNarrow:             []string{"S", "J", "J", "J", "A", "I", "J"},
66                 daysWide:               []string{"Sabato", "Jumatatu", "Jumanne", "Jumatano", "Arahamisi", "Ijumaa", "Jumamosi"},
67                 periodsAbbreviated:     []string{"wichishu", "mchochil’l"},
68                 periodsWide:            []string{"wichishu", "mchochil’l"},
69                 erasAbbreviated:        []string{"HY", "YY"},
70                 erasNarrow:             []string{"", ""},
71                 erasWide:               []string{"Hinapiya yesu", "Yopia yesu"},
72                 timezones:              map[string]string{"JST": "JST", "OESZ": "OESZ", "MST": "MST", "HEOG": "HEOG", "MYT": "MYT", "TMST": "TMST", "AST": "AST", "COST": "COST", "ACST": "ACST", "HNPMX": "HNPMX", "AWDT": "AWDT", "ACWST": "ACWST", "WART": "WART", "HAT": "HAT", "BT": "BT", "MDT": "MDT", "WAST": "WAST", "ChST": "ChST", "CHAST": "CHAST", "MEZ": "MEZ", "AEDT": "AEDT", "MESZ": "MESZ", "HKST": "HKST", "EDT": "EDT", "WIB": "WIB", "LHDT": "LHDT", "∅∅∅": "∅∅∅", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "ACDT": "ACDT", "CAT": "CAT", "BOT": "BOT", "CST": "CST", "LHST": "LHST", "VET": "VET", "SAST": "SAST", "WAT": "WAT", "CLST": "CLST", "SGT": "SGT", "GMT": "GMT", "TMT": "TMT", "OEZ": "OEZ", "CLT": "CLT", "ECT": "ECT", "HNCU": "HNCU", "CDT": "CDT", "UYST": "UYST", "WIT": "WIT", "ADT": "ADT", "HNOG": "HNOG", "GFT": "GFT", "GYT": "GYT", "PDT": "PDT", "UYT": "UYT", "WARST": "WARST", "ARST": "ARST", "COT": "COT", "EST": "EST", "PST": "PST", "CHADT": "CHADT", "HECU": "HECU", "NZDT": "NZDT", "AEST": "AEST", "AWST": "AWST", "HKT": "HKT", "WESZ": "WESZ", "HEPMX": "HEPMX", "HENOMX": "HENOMX", "IST": "IST", "EAT": "EAT", "AKST": "AKST", "AKDT": "AKDT", "SRT": "SRT", "ACWDT": "ACWDT", "JDT": "JDT", "HNPM": "HNPM", "HNEG": "HNEG", "HNT": "HNT", "WEZ": "WEZ", "HEPM": "HEPM", "WITA": "WITA", "ART": "ART", "NZST": "NZST", "HAST": "HAST", "HADT": "HADT"},
73         }
74 }
75
76 // Locale returns the current translators string locale
77 func (mgh *mgh) Locale() string {
78         return mgh.locale
79 }
80
81 // PluralsCardinal returns the list of cardinal plural rules associated with 'mgh'
82 func (mgh *mgh) PluralsCardinal() []locales.PluralRule {
83         return mgh.pluralsCardinal
84 }
85
86 // PluralsOrdinal returns the list of ordinal plural rules associated with 'mgh'
87 func (mgh *mgh) PluralsOrdinal() []locales.PluralRule {
88         return mgh.pluralsOrdinal
89 }
90
91 // PluralsRange returns the list of range plural rules associated with 'mgh'
92 func (mgh *mgh) PluralsRange() []locales.PluralRule {
93         return mgh.pluralsRange
94 }
95
96 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgh'
97 func (mgh *mgh) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
98         return locales.PluralRuleUnknown
99 }
100
101 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgh'
102 func (mgh *mgh) 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 'mgh'
107 func (mgh *mgh) 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 (mgh *mgh) MonthAbbreviated(month time.Month) string {
113         return mgh.monthsAbbreviated[month]
114 }
115
116 // MonthsAbbreviated returns the locales abbreviated months
117 func (mgh *mgh) MonthsAbbreviated() []string {
118         return mgh.monthsAbbreviated[1:]
119 }
120
121 // MonthNarrow returns the locales narrow month given the 'month' provided
122 func (mgh *mgh) MonthNarrow(month time.Month) string {
123         return mgh.monthsNarrow[month]
124 }
125
126 // MonthsNarrow returns the locales narrow months
127 func (mgh *mgh) MonthsNarrow() []string {
128         return mgh.monthsNarrow[1:]
129 }
130
131 // MonthWide returns the locales wide month given the 'month' provided
132 func (mgh *mgh) MonthWide(month time.Month) string {
133         return mgh.monthsWide[month]
134 }
135
136 // MonthsWide returns the locales wide months
137 func (mgh *mgh) MonthsWide() []string {
138         return mgh.monthsWide[1:]
139 }
140
141 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
142 func (mgh *mgh) WeekdayAbbreviated(weekday time.Weekday) string {
143         return mgh.daysAbbreviated[weekday]
144 }
145
146 // WeekdaysAbbreviated returns the locales abbreviated weekdays
147 func (mgh *mgh) WeekdaysAbbreviated() []string {
148         return mgh.daysAbbreviated
149 }
150
151 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
152 func (mgh *mgh) WeekdayNarrow(weekday time.Weekday) string {
153         return mgh.daysNarrow[weekday]
154 }
155
156 // WeekdaysNarrow returns the locales narrow weekdays
157 func (mgh *mgh) WeekdaysNarrow() []string {
158         return mgh.daysNarrow
159 }
160
161 // WeekdayShort returns the locales short weekday given the 'weekday' provided
162 func (mgh *mgh) WeekdayShort(weekday time.Weekday) string {
163         return mgh.daysShort[weekday]
164 }
165
166 // WeekdaysShort returns the locales short weekdays
167 func (mgh *mgh) WeekdaysShort() []string {
168         return mgh.daysShort
169 }
170
171 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
172 func (mgh *mgh) WeekdayWide(weekday time.Weekday) string {
173         return mgh.daysWide[weekday]
174 }
175
176 // WeekdaysWide returns the locales wide weekdays
177 func (mgh *mgh) WeekdaysWide() []string {
178         return mgh.daysWide
179 }
180
181 // Decimal returns the decimal point of number
182 func (mgh *mgh) Decimal() string {
183         return mgh.decimal
184 }
185
186 // Group returns the group of number
187 func (mgh *mgh) Group() string {
188         return mgh.group
189 }
190
191 // Group returns the minus sign of number
192 func (mgh *mgh) Minus() string {
193         return mgh.minus
194 }
195
196 // FmtNumber returns 'num' with digits/precision of 'v' for 'mgh' and handles both Whole and Real numbers based on 'v'
197 func (mgh *mgh) 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 'mgh' 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 (mgh *mgh) 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 'mgh'
209 func (mgh *mgh) FmtCurrency(num float64, v uint64, currency currency.Type) string {
210
211         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212         symbol := mgh.currencies[currency]
213         l := len(s) + len(symbol) + 4
214
215         b := make([]byte, 0, l)
216
217         for i := len(s) - 1; i >= 0; i-- {
218
219                 if s[i] == '.' {
220                         b = append(b, mgh.decimal[0])
221                         continue
222                 }
223
224                 b = append(b, s[i])
225         }
226
227         for j := len(symbol) - 1; j >= 0; j-- {
228                 b = append(b, symbol[j])
229         }
230
231         for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- {
232                 b = append(b, mgh.currencyPositivePrefix[j])
233         }
234
235         if num < 0 {
236                 b = append(b, mgh.minus[0])
237         }
238
239         // reverse
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]
242         }
243
244         b = append(b, mgh.currencyPositiveSuffix...)
245
246         return string(b)
247 }
248
249 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgh'
250 // in accounting notation.
251 func (mgh *mgh) FmtAccounting(num float64, v uint64, currency currency.Type) string {
252
253         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
254         symbol := mgh.currencies[currency]
255         l := len(s) + len(symbol) + 4
256
257         b := make([]byte, 0, l)
258
259         for i := len(s) - 1; i >= 0; i-- {
260
261                 if s[i] == '.' {
262                         b = append(b, mgh.decimal[0])
263                         continue
264                 }
265
266                 b = append(b, s[i])
267         }
268
269         if num < 0 {
270
271                 for j := len(symbol) - 1; j >= 0; j-- {
272                         b = append(b, symbol[j])
273                 }
274
275                 for j := len(mgh.currencyNegativePrefix) - 1; j >= 0; j-- {
276                         b = append(b, mgh.currencyNegativePrefix[j])
277                 }
278
279                 b = append(b, mgh.minus[0])
280
281         } else {
282
283                 for j := len(symbol) - 1; j >= 0; j-- {
284                         b = append(b, symbol[j])
285                 }
286
287                 for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- {
288                         b = append(b, mgh.currencyPositivePrefix[j])
289                 }
290
291         }
292
293         // reverse
294         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
295                 b[i], b[j] = b[j], b[i]
296         }
297
298         if num < 0 {
299                 b = append(b, mgh.currencyNegativeSuffix...)
300         } else {
301
302                 b = append(b, mgh.currencyPositiveSuffix...)
303         }
304
305         return string(b)
306 }
307
308 // FmtDateShort returns the short date representation of 't' for 'mgh'
309 func (mgh *mgh) FmtDateShort(t time.Time) string {
310
311         b := make([]byte, 0, 32)
312
313         if t.Day() < 10 {
314                 b = append(b, '0')
315         }
316
317         b = strconv.AppendInt(b, int64(t.Day()), 10)
318         b = append(b, []byte{0x2f}...)
319
320         if t.Month() < 10 {
321                 b = append(b, '0')
322         }
323
324         b = strconv.AppendInt(b, int64(t.Month()), 10)
325
326         b = append(b, []byte{0x2f}...)
327
328         if t.Year() > 0 {
329                 b = strconv.AppendInt(b, int64(t.Year()), 10)
330         } else {
331                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
332         }
333
334         return string(b)
335 }
336
337 // FmtDateMedium returns the medium date representation of 't' for 'mgh'
338 func (mgh *mgh) FmtDateMedium(t time.Time) string {
339
340         b := make([]byte, 0, 32)
341
342         b = strconv.AppendInt(b, int64(t.Day()), 10)
343         b = append(b, []byte{0x20}...)
344         b = append(b, mgh.monthsAbbreviated[t.Month()]...)
345         b = append(b, []byte{0x20}...)
346
347         if t.Year() > 0 {
348                 b = strconv.AppendInt(b, int64(t.Year()), 10)
349         } else {
350                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
351         }
352
353         return string(b)
354 }
355
356 // FmtDateLong returns the long date representation of 't' for 'mgh'
357 func (mgh *mgh) FmtDateLong(t time.Time) string {
358
359         b := make([]byte, 0, 32)
360
361         b = strconv.AppendInt(b, int64(t.Day()), 10)
362         b = append(b, []byte{0x20}...)
363         b = append(b, mgh.monthsWide[t.Month()]...)
364         b = append(b, []byte{0x20}...)
365
366         if t.Year() > 0 {
367                 b = strconv.AppendInt(b, int64(t.Year()), 10)
368         } else {
369                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
370         }
371
372         return string(b)
373 }
374
375 // FmtDateFull returns the full date representation of 't' for 'mgh'
376 func (mgh *mgh) FmtDateFull(t time.Time) string {
377
378         b := make([]byte, 0, 32)
379
380         b = append(b, mgh.daysWide[t.Weekday()]...)
381         b = append(b, []byte{0x2c, 0x20}...)
382         b = strconv.AppendInt(b, int64(t.Day()), 10)
383         b = append(b, []byte{0x20}...)
384         b = append(b, mgh.monthsWide[t.Month()]...)
385         b = append(b, []byte{0x20}...)
386
387         if t.Year() > 0 {
388                 b = strconv.AppendInt(b, int64(t.Year()), 10)
389         } else {
390                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
391         }
392
393         return string(b)
394 }
395
396 // FmtTimeShort returns the short time representation of 't' for 'mgh'
397 func (mgh *mgh) FmtTimeShort(t time.Time) string {
398
399         b := make([]byte, 0, 32)
400
401         if t.Hour() < 10 {
402                 b = append(b, '0')
403         }
404
405         b = strconv.AppendInt(b, int64(t.Hour()), 10)
406         b = append(b, mgh.timeSeparator...)
407
408         if t.Minute() < 10 {
409                 b = append(b, '0')
410         }
411
412         b = strconv.AppendInt(b, int64(t.Minute()), 10)
413
414         return string(b)
415 }
416
417 // FmtTimeMedium returns the medium time representation of 't' for 'mgh'
418 func (mgh *mgh) FmtTimeMedium(t time.Time) string {
419
420         b := make([]byte, 0, 32)
421
422         if t.Hour() < 10 {
423                 b = append(b, '0')
424         }
425
426         b = strconv.AppendInt(b, int64(t.Hour()), 10)
427         b = append(b, mgh.timeSeparator...)
428
429         if t.Minute() < 10 {
430                 b = append(b, '0')
431         }
432
433         b = strconv.AppendInt(b, int64(t.Minute()), 10)
434         b = append(b, mgh.timeSeparator...)
435
436         if t.Second() < 10 {
437                 b = append(b, '0')
438         }
439
440         b = strconv.AppendInt(b, int64(t.Second()), 10)
441
442         return string(b)
443 }
444
445 // FmtTimeLong returns the long time representation of 't' for 'mgh'
446 func (mgh *mgh) FmtTimeLong(t time.Time) string {
447
448         b := make([]byte, 0, 32)
449
450         if t.Hour() < 10 {
451                 b = append(b, '0')
452         }
453
454         b = strconv.AppendInt(b, int64(t.Hour()), 10)
455         b = append(b, mgh.timeSeparator...)
456
457         if t.Minute() < 10 {
458                 b = append(b, '0')
459         }
460
461         b = strconv.AppendInt(b, int64(t.Minute()), 10)
462         b = append(b, mgh.timeSeparator...)
463
464         if t.Second() < 10 {
465                 b = append(b, '0')
466         }
467
468         b = strconv.AppendInt(b, int64(t.Second()), 10)
469         b = append(b, []byte{0x20}...)
470
471         tz, _ := t.Zone()
472         b = append(b, tz...)
473
474         return string(b)
475 }
476
477 // FmtTimeFull returns the full time representation of 't' for 'mgh'
478 func (mgh *mgh) FmtTimeFull(t time.Time) string {
479
480         b := make([]byte, 0, 32)
481
482         if t.Hour() < 10 {
483                 b = append(b, '0')
484         }
485
486         b = strconv.AppendInt(b, int64(t.Hour()), 10)
487         b = append(b, mgh.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, mgh.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         tz, _ := t.Zone()
504
505         if btz, ok := mgh.timezones[tz]; ok {
506                 b = append(b, btz...)
507         } else {
508                 b = append(b, tz...)
509         }
510
511         return string(b)
512 }