1 package bem_ZM
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 bem_ZM 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
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
45 func New() locales.Translator {
46 return &bem_ZM{
47 locale: "bem_ZM",
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", "CNH", "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", "MRU", "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", "STN", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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{"", "Jan", "Feb", "Mac", "Epr", "Mei", "Jun", "Jul", "Oga", "Sep", "Okt", "Nov", "Dis"},
56 monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "O", "S", "O", "N", "D"},
57 monthsWide: []string{"", "Januari", "Februari", "Machi", "Epreo", "Mei", "Juni", "Julai", "Ogasti", "Septemba", "Oktoba", "Novemba", "Disemba"},
58 daysWide: []string{"Pa Mulungu", "Palichimo", "Palichibuli", "Palichitatu", "Palichine", "Palichisano", "Pachibelushi"},
59 periodsAbbreviated: []string{"uluchelo", "akasuba"},
60 periodsWide: []string{"uluchelo", "akasuba"},
61 erasAbbreviated: []string{"BC", "AD"},
62 erasNarrow: []string{"", ""},
63 erasWide: []string{"Before Yesu", "After Yesu"},
64 timezones: map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "ADT", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "AST", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT", "EST": "EST", "GFT": "GFT", "GMT": "GMT", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "IST", "JDT": "JDT", "JST": "JST", "LHDT": "LHDT", "LHST": "LHST", "MDT": "MDT", "MESZ": "MESZ", "MEZ": "MEZ", "MST": "MST", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "OESZ", "OEZ": "OEZ", "PDT": "PDT", "PST": "PST", "SAST": "SAST", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "WAST", "WAT": "WAT", "WESZ": "WESZ", "WEZ": "WEZ", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
65 }
66 }
67
68
69 func (bem *bem_ZM) Locale() string {
70 return bem.locale
71 }
72
73
74 func (bem *bem_ZM) PluralsCardinal() []locales.PluralRule {
75 return bem.pluralsCardinal
76 }
77
78
79 func (bem *bem_ZM) PluralsOrdinal() []locales.PluralRule {
80 return bem.pluralsOrdinal
81 }
82
83
84 func (bem *bem_ZM) PluralsRange() []locales.PluralRule {
85 return bem.pluralsRange
86 }
87
88
89 func (bem *bem_ZM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
90
91 n := math.Abs(num)
92
93 if n == 1 {
94 return locales.PluralRuleOne
95 }
96
97 return locales.PluralRuleOther
98 }
99
100
101 func (bem *bem_ZM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
102 return locales.PluralRuleUnknown
103 }
104
105
106 func (bem *bem_ZM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
107 return locales.PluralRuleUnknown
108 }
109
110
111 func (bem *bem_ZM) MonthAbbreviated(month time.Month) string {
112 return bem.monthsAbbreviated[month]
113 }
114
115
116 func (bem *bem_ZM) MonthsAbbreviated() []string {
117 return bem.monthsAbbreviated[1:]
118 }
119
120
121 func (bem *bem_ZM) MonthNarrow(month time.Month) string {
122 return bem.monthsNarrow[month]
123 }
124
125
126 func (bem *bem_ZM) MonthsNarrow() []string {
127 return bem.monthsNarrow[1:]
128 }
129
130
131 func (bem *bem_ZM) MonthWide(month time.Month) string {
132 return bem.monthsWide[month]
133 }
134
135
136 func (bem *bem_ZM) MonthsWide() []string {
137 return bem.monthsWide[1:]
138 }
139
140
141 func (bem *bem_ZM) WeekdayAbbreviated(weekday time.Weekday) string {
142 return bem.daysAbbreviated[weekday]
143 }
144
145
146 func (bem *bem_ZM) WeekdaysAbbreviated() []string {
147 return bem.daysAbbreviated
148 }
149
150
151 func (bem *bem_ZM) WeekdayNarrow(weekday time.Weekday) string {
152 return bem.daysNarrow[weekday]
153 }
154
155
156 func (bem *bem_ZM) WeekdaysNarrow() []string {
157 return bem.daysNarrow
158 }
159
160
161 func (bem *bem_ZM) WeekdayShort(weekday time.Weekday) string {
162 return bem.daysShort[weekday]
163 }
164
165
166 func (bem *bem_ZM) WeekdaysShort() []string {
167 return bem.daysShort
168 }
169
170
171 func (bem *bem_ZM) WeekdayWide(weekday time.Weekday) string {
172 return bem.daysWide[weekday]
173 }
174
175
176 func (bem *bem_ZM) WeekdaysWide() []string {
177 return bem.daysWide
178 }
179
180
181 func (bem *bem_ZM) Decimal() string {
182 return bem.decimal
183 }
184
185
186 func (bem *bem_ZM) Group() string {
187 return bem.group
188 }
189
190
191 func (bem *bem_ZM) Minus() string {
192 return bem.minus
193 }
194
195
196 func (bem *bem_ZM) FmtNumber(num float64, v uint64) string {
197
198 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
199 }
200
201
202
203 func (bem *bem_ZM) FmtPercent(num float64, v uint64) string {
204 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 }
206
207
208 func (bem *bem_ZM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
209
210 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211 symbol := bem.currencies[currency]
212 l := len(s) + len(symbol) + 0
213 count := 0
214 inWhole := v == 0
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, bem.decimal[0])
221 inWhole = true
222 continue
223 }
224
225 if inWhole {
226 if count == 3 {
227 b = append(b, bem.group[0])
228 count = 1
229 } else {
230 count++
231 }
232 }
233
234 b = append(b, s[i])
235 }
236
237 for j := len(symbol) - 1; j >= 0; j-- {
238 b = append(b, symbol[j])
239 }
240
241 if num < 0 {
242 b = append(b, bem.minus[0])
243 }
244
245
246 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
247 b[i], b[j] = b[j], b[i]
248 }
249
250 if int(v) < 2 {
251
252 if v == 0 {
253 b = append(b, bem.decimal...)
254 }
255
256 for i := 0; i < 2-int(v); i++ {
257 b = append(b, '0')
258 }
259 }
260
261 return string(b)
262 }
263
264
265
266 func (bem *bem_ZM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
267
268 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 symbol := bem.currencies[currency]
270 l := len(s) + len(symbol) + 2
271 count := 0
272 inWhole := v == 0
273 b := make([]byte, 0, l)
274
275 for i := len(s) - 1; i >= 0; i-- {
276
277 if s[i] == '.' {
278 b = append(b, bem.decimal[0])
279 inWhole = true
280 continue
281 }
282
283 if inWhole {
284 if count == 3 {
285 b = append(b, bem.group[0])
286 count = 1
287 } else {
288 count++
289 }
290 }
291
292 b = append(b, s[i])
293 }
294
295 if num < 0 {
296
297 for j := len(symbol) - 1; j >= 0; j-- {
298 b = append(b, symbol[j])
299 }
300
301 b = append(b, bem.currencyNegativePrefix[0])
302
303 } else {
304
305 for j := len(symbol) - 1; j >= 0; j-- {
306 b = append(b, symbol[j])
307 }
308
309 }
310
311
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
314 }
315
316 if int(v) < 2 {
317
318 if v == 0 {
319 b = append(b, bem.decimal...)
320 }
321
322 for i := 0; i < 2-int(v); i++ {
323 b = append(b, '0')
324 }
325 }
326
327 if num < 0 {
328 b = append(b, bem.currencyNegativeSuffix...)
329 }
330
331 return string(b)
332 }
333
334
335 func (bem *bem_ZM) FmtDateShort(t time.Time) string {
336
337 b := make([]byte, 0, 32)
338
339 if t.Day() < 10 {
340 b = append(b, '0')
341 }
342
343 b = strconv.AppendInt(b, int64(t.Day()), 10)
344 b = append(b, []byte{0x2f}...)
345
346 if t.Month() < 10 {
347 b = append(b, '0')
348 }
349
350 b = strconv.AppendInt(b, int64(t.Month()), 10)
351
352 b = append(b, []byte{0x2f}...)
353
354 if t.Year() > 0 {
355 b = strconv.AppendInt(b, int64(t.Year()), 10)
356 } else {
357 b = strconv.AppendInt(b, int64(-t.Year()), 10)
358 }
359
360 return string(b)
361 }
362
363
364 func (bem *bem_ZM) FmtDateMedium(t time.Time) string {
365
366 b := make([]byte, 0, 32)
367
368 b = strconv.AppendInt(b, int64(t.Day()), 10)
369 b = append(b, []byte{0x20}...)
370 b = append(b, bem.monthsAbbreviated[t.Month()]...)
371 b = append(b, []byte{0x20}...)
372
373 if t.Year() > 0 {
374 b = strconv.AppendInt(b, int64(t.Year()), 10)
375 } else {
376 b = strconv.AppendInt(b, int64(-t.Year()), 10)
377 }
378
379 return string(b)
380 }
381
382
383 func (bem *bem_ZM) FmtDateLong(t time.Time) string {
384
385 b := make([]byte, 0, 32)
386
387 b = strconv.AppendInt(b, int64(t.Day()), 10)
388 b = append(b, []byte{0x20}...)
389 b = append(b, bem.monthsWide[t.Month()]...)
390 b = append(b, []byte{0x20}...)
391
392 if t.Year() > 0 {
393 b = strconv.AppendInt(b, int64(t.Year()), 10)
394 } else {
395 b = strconv.AppendInt(b, int64(-t.Year()), 10)
396 }
397
398 return string(b)
399 }
400
401
402 func (bem *bem_ZM) FmtDateFull(t time.Time) string {
403
404 b := make([]byte, 0, 32)
405
406 b = append(b, bem.daysWide[t.Weekday()]...)
407 b = append(b, []byte{0x2c, 0x20}...)
408 b = strconv.AppendInt(b, int64(t.Day()), 10)
409 b = append(b, []byte{0x20}...)
410 b = append(b, bem.monthsWide[t.Month()]...)
411 b = append(b, []byte{0x20}...)
412
413 if t.Year() > 0 {
414 b = strconv.AppendInt(b, int64(t.Year()), 10)
415 } else {
416 b = strconv.AppendInt(b, int64(-t.Year()), 10)
417 }
418
419 return string(b)
420 }
421
422
423 func (bem *bem_ZM) FmtTimeShort(t time.Time) string {
424
425 b := make([]byte, 0, 32)
426
427 h := t.Hour()
428
429 if h > 12 {
430 h -= 12
431 }
432
433 b = strconv.AppendInt(b, int64(h), 10)
434 b = append(b, bem.timeSeparator...)
435
436 if t.Minute() < 10 {
437 b = append(b, '0')
438 }
439
440 b = strconv.AppendInt(b, int64(t.Minute()), 10)
441 b = append(b, []byte{0x20}...)
442
443 if t.Hour() < 12 {
444 b = append(b, bem.periodsAbbreviated[0]...)
445 } else {
446 b = append(b, bem.periodsAbbreviated[1]...)
447 }
448
449 return string(b)
450 }
451
452
453 func (bem *bem_ZM) FmtTimeMedium(t time.Time) string {
454
455 b := make([]byte, 0, 32)
456
457 h := t.Hour()
458
459 if h > 12 {
460 h -= 12
461 }
462
463 b = strconv.AppendInt(b, int64(h), 10)
464 b = append(b, bem.timeSeparator...)
465
466 if t.Minute() < 10 {
467 b = append(b, '0')
468 }
469
470 b = strconv.AppendInt(b, int64(t.Minute()), 10)
471 b = append(b, bem.timeSeparator...)
472
473 if t.Second() < 10 {
474 b = append(b, '0')
475 }
476
477 b = strconv.AppendInt(b, int64(t.Second()), 10)
478 b = append(b, []byte{0x20}...)
479
480 if t.Hour() < 12 {
481 b = append(b, bem.periodsAbbreviated[0]...)
482 } else {
483 b = append(b, bem.periodsAbbreviated[1]...)
484 }
485
486 return string(b)
487 }
488
489
490 func (bem *bem_ZM) FmtTimeLong(t time.Time) string {
491
492 b := make([]byte, 0, 32)
493
494 h := t.Hour()
495
496 if h > 12 {
497 h -= 12
498 }
499
500 b = strconv.AppendInt(b, int64(h), 10)
501 b = append(b, bem.timeSeparator...)
502
503 if t.Minute() < 10 {
504 b = append(b, '0')
505 }
506
507 b = strconv.AppendInt(b, int64(t.Minute()), 10)
508 b = append(b, bem.timeSeparator...)
509
510 if t.Second() < 10 {
511 b = append(b, '0')
512 }
513
514 b = strconv.AppendInt(b, int64(t.Second()), 10)
515 b = append(b, []byte{0x20}...)
516
517 if t.Hour() < 12 {
518 b = append(b, bem.periodsAbbreviated[0]...)
519 } else {
520 b = append(b, bem.periodsAbbreviated[1]...)
521 }
522
523 b = append(b, []byte{0x20}...)
524
525 tz, _ := t.Zone()
526 b = append(b, tz...)
527
528 return string(b)
529 }
530
531
532 func (bem *bem_ZM) FmtTimeFull(t time.Time) string {
533
534 b := make([]byte, 0, 32)
535
536 h := t.Hour()
537
538 if h > 12 {
539 h -= 12
540 }
541
542 b = strconv.AppendInt(b, int64(h), 10)
543 b = append(b, bem.timeSeparator...)
544
545 if t.Minute() < 10 {
546 b = append(b, '0')
547 }
548
549 b = strconv.AppendInt(b, int64(t.Minute()), 10)
550 b = append(b, bem.timeSeparator...)
551
552 if t.Second() < 10 {
553 b = append(b, '0')
554 }
555
556 b = strconv.AppendInt(b, int64(t.Second()), 10)
557 b = append(b, []byte{0x20}...)
558
559 if t.Hour() < 12 {
560 b = append(b, bem.periodsAbbreviated[0]...)
561 } else {
562 b = append(b, bem.periodsAbbreviated[1]...)
563 }
564
565 b = append(b, []byte{0x20}...)
566
567 tz, _ := t.Zone()
568
569 if btz, ok := bem.timezones[tz]; ok {
570 b = append(b, btz...)
571 } else {
572 b = append(b, tz...)
573 }
574
575 return string(b)
576 }
577
View as plain text