1 package dua_CM
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 dua_CM 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 percentSuffix string
22 perMille string
23 timeSeparator string
24 inifinity string
25 currencies []string
26 currencyPositiveSuffix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
29 monthsNarrow []string
30 monthsWide []string
31 daysAbbreviated []string
32 daysNarrow []string
33 daysShort []string
34 daysWide []string
35 periodsAbbreviated []string
36 periodsNarrow []string
37 periodsShort []string
38 periodsWide []string
39 erasAbbreviated []string
40 erasNarrow []string
41 erasWide []string
42 timezones map[string]string
43 }
44
45
46 func New() locales.Translator {
47 return &dua_CM{
48 locale: "dua_CM",
49 pluralsCardinal: nil,
50 pluralsOrdinal: nil,
51 pluralsRange: nil,
52 decimal: ",",
53 group: " ",
54 timeSeparator: ":",
55 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"},
56 percentSuffix: " ",
57 currencyPositiveSuffix: " ",
58 currencyNegativeSuffix: " ",
59 monthsAbbreviated: []string{"", "di", "ŋgɔn", "sɔŋ", "diɓ", "emi", "esɔ", "mad", "diŋ", "nyɛt", "may", "tin", "elá"},
60 monthsNarrow: []string{"", "d", "ŋ", "s", "d", "e", "e", "m", "d", "n", "m", "t", "e"},
61 monthsWide: []string{"", "dimɔ́di", "ŋgɔndɛ", "sɔŋɛ", "diɓáɓá", "emiasele", "esɔpɛsɔpɛ", "madiɓɛ́díɓɛ́", "diŋgindi", "nyɛtɛki", "mayésɛ́", "tiníní", "eláŋgɛ́"},
62 daysAbbreviated: []string{"ét", "mɔ́s", "kwa", "muk", "ŋgi", "ɗón", "esa"},
63 daysNarrow: []string{"e", "m", "k", "m", "ŋ", "ɗ", "e"},
64 daysWide: []string{"éti", "mɔ́sú", "kwasú", "mukɔ́sú", "ŋgisú", "ɗónɛsú", "esaɓasú"},
65 periodsAbbreviated: []string{"idiɓa", "ebyámu"},
66 periodsWide: []string{"idiɓa", "ebyámu"},
67 erasAbbreviated: []string{"ɓ.Ys", "mb.Ys"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"ɓoso ɓwá yáɓe lá", "mbúsa kwédi a Yés"},
70 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", "∅∅∅": "∅∅∅"},
71 }
72 }
73
74
75 func (dua *dua_CM) Locale() string {
76 return dua.locale
77 }
78
79
80 func (dua *dua_CM) PluralsCardinal() []locales.PluralRule {
81 return dua.pluralsCardinal
82 }
83
84
85 func (dua *dua_CM) PluralsOrdinal() []locales.PluralRule {
86 return dua.pluralsOrdinal
87 }
88
89
90 func (dua *dua_CM) PluralsRange() []locales.PluralRule {
91 return dua.pluralsRange
92 }
93
94
95 func (dua *dua_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96 return locales.PluralRuleUnknown
97 }
98
99
100 func (dua *dua_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
101 return locales.PluralRuleUnknown
102 }
103
104
105 func (dua *dua_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
106 return locales.PluralRuleUnknown
107 }
108
109
110 func (dua *dua_CM) MonthAbbreviated(month time.Month) string {
111 return dua.monthsAbbreviated[month]
112 }
113
114
115 func (dua *dua_CM) MonthsAbbreviated() []string {
116 return dua.monthsAbbreviated[1:]
117 }
118
119
120 func (dua *dua_CM) MonthNarrow(month time.Month) string {
121 return dua.monthsNarrow[month]
122 }
123
124
125 func (dua *dua_CM) MonthsNarrow() []string {
126 return dua.monthsNarrow[1:]
127 }
128
129
130 func (dua *dua_CM) MonthWide(month time.Month) string {
131 return dua.monthsWide[month]
132 }
133
134
135 func (dua *dua_CM) MonthsWide() []string {
136 return dua.monthsWide[1:]
137 }
138
139
140 func (dua *dua_CM) WeekdayAbbreviated(weekday time.Weekday) string {
141 return dua.daysAbbreviated[weekday]
142 }
143
144
145 func (dua *dua_CM) WeekdaysAbbreviated() []string {
146 return dua.daysAbbreviated
147 }
148
149
150 func (dua *dua_CM) WeekdayNarrow(weekday time.Weekday) string {
151 return dua.daysNarrow[weekday]
152 }
153
154
155 func (dua *dua_CM) WeekdaysNarrow() []string {
156 return dua.daysNarrow
157 }
158
159
160 func (dua *dua_CM) WeekdayShort(weekday time.Weekday) string {
161 return dua.daysShort[weekday]
162 }
163
164
165 func (dua *dua_CM) WeekdaysShort() []string {
166 return dua.daysShort
167 }
168
169
170 func (dua *dua_CM) WeekdayWide(weekday time.Weekday) string {
171 return dua.daysWide[weekday]
172 }
173
174
175 func (dua *dua_CM) WeekdaysWide() []string {
176 return dua.daysWide
177 }
178
179
180 func (dua *dua_CM) Decimal() string {
181 return dua.decimal
182 }
183
184
185 func (dua *dua_CM) Group() string {
186 return dua.group
187 }
188
189
190 func (dua *dua_CM) Minus() string {
191 return dua.minus
192 }
193
194
195 func (dua *dua_CM) FmtNumber(num float64, v uint64) string {
196
197 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
198 l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
199 count := 0
200 inWhole := v == 0
201 b := make([]byte, 0, l)
202
203 for i := len(s) - 1; i >= 0; i-- {
204
205 if s[i] == '.' {
206 b = append(b, dua.decimal[0])
207 inWhole = true
208 continue
209 }
210
211 if inWhole {
212 if count == 3 {
213 for j := len(dua.group) - 1; j >= 0; j-- {
214 b = append(b, dua.group[j])
215 }
216 count = 1
217 } else {
218 count++
219 }
220 }
221
222 b = append(b, s[i])
223 }
224
225 if num < 0 {
226 b = append(b, dua.minus[0])
227 }
228
229
230 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
231 b[i], b[j] = b[j], b[i]
232 }
233
234 return string(b)
235 }
236
237
238
239 func (dua *dua_CM) FmtPercent(num float64, v uint64) string {
240 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
241 l := len(s) + 3
242 b := make([]byte, 0, l)
243
244 for i := len(s) - 1; i >= 0; i-- {
245
246 if s[i] == '.' {
247 b = append(b, dua.decimal[0])
248 continue
249 }
250
251 b = append(b, s[i])
252 }
253
254 if num < 0 {
255 b = append(b, dua.minus[0])
256 }
257
258
259 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
260 b[i], b[j] = b[j], b[i]
261 }
262
263 b = append(b, dua.percentSuffix...)
264
265 b = append(b, dua.percent...)
266
267 return string(b)
268 }
269
270
271 func (dua *dua_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
272
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := dua.currencies[currency]
275 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
276 count := 0
277 inWhole := v == 0
278 b := make([]byte, 0, l)
279
280 for i := len(s) - 1; i >= 0; i-- {
281
282 if s[i] == '.' {
283 b = append(b, dua.decimal[0])
284 inWhole = true
285 continue
286 }
287
288 if inWhole {
289 if count == 3 {
290 for j := len(dua.group) - 1; j >= 0; j-- {
291 b = append(b, dua.group[j])
292 }
293 count = 1
294 } else {
295 count++
296 }
297 }
298
299 b = append(b, s[i])
300 }
301
302 if num < 0 {
303 b = append(b, dua.minus[0])
304 }
305
306
307 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
308 b[i], b[j] = b[j], b[i]
309 }
310
311 if int(v) < 2 {
312
313 if v == 0 {
314 b = append(b, dua.decimal...)
315 }
316
317 for i := 0; i < 2-int(v); i++ {
318 b = append(b, '0')
319 }
320 }
321
322 b = append(b, dua.currencyPositiveSuffix...)
323
324 b = append(b, symbol...)
325
326 return string(b)
327 }
328
329
330
331 func (dua *dua_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
332
333 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
334 symbol := dua.currencies[currency]
335 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
336 count := 0
337 inWhole := v == 0
338 b := make([]byte, 0, l)
339
340 for i := len(s) - 1; i >= 0; i-- {
341
342 if s[i] == '.' {
343 b = append(b, dua.decimal[0])
344 inWhole = true
345 continue
346 }
347
348 if inWhole {
349 if count == 3 {
350 for j := len(dua.group) - 1; j >= 0; j-- {
351 b = append(b, dua.group[j])
352 }
353 count = 1
354 } else {
355 count++
356 }
357 }
358
359 b = append(b, s[i])
360 }
361
362 if num < 0 {
363
364 b = append(b, dua.minus[0])
365
366 }
367
368
369 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
370 b[i], b[j] = b[j], b[i]
371 }
372
373 if int(v) < 2 {
374
375 if v == 0 {
376 b = append(b, dua.decimal...)
377 }
378
379 for i := 0; i < 2-int(v); i++ {
380 b = append(b, '0')
381 }
382 }
383
384 if num < 0 {
385 b = append(b, dua.currencyNegativeSuffix...)
386 b = append(b, symbol...)
387 } else {
388
389 b = append(b, dua.currencyPositiveSuffix...)
390 b = append(b, symbol...)
391 }
392
393 return string(b)
394 }
395
396
397 func (dua *dua_CM) FmtDateShort(t time.Time) string {
398
399 b := make([]byte, 0, 32)
400
401 b = strconv.AppendInt(b, int64(t.Day()), 10)
402 b = append(b, []byte{0x2f}...)
403 b = strconv.AppendInt(b, int64(t.Month()), 10)
404 b = append(b, []byte{0x2f}...)
405
406 if t.Year() > 0 {
407 b = strconv.AppendInt(b, int64(t.Year()), 10)
408 } else {
409 b = strconv.AppendInt(b, int64(-t.Year()), 10)
410 }
411
412 return string(b)
413 }
414
415
416 func (dua *dua_CM) FmtDateMedium(t time.Time) string {
417
418 b := make([]byte, 0, 32)
419
420 b = strconv.AppendInt(b, int64(t.Day()), 10)
421 b = append(b, []byte{0x20}...)
422 b = append(b, dua.monthsAbbreviated[t.Month()]...)
423 b = append(b, []byte{0x20}...)
424
425 if t.Year() > 0 {
426 b = strconv.AppendInt(b, int64(t.Year()), 10)
427 } else {
428 b = strconv.AppendInt(b, int64(-t.Year()), 10)
429 }
430
431 return string(b)
432 }
433
434
435 func (dua *dua_CM) FmtDateLong(t time.Time) string {
436
437 b := make([]byte, 0, 32)
438
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x20}...)
441 b = append(b, dua.monthsWide[t.Month()]...)
442 b = append(b, []byte{0x20}...)
443
444 if t.Year() > 0 {
445 b = strconv.AppendInt(b, int64(t.Year()), 10)
446 } else {
447 b = strconv.AppendInt(b, int64(-t.Year()), 10)
448 }
449
450 return string(b)
451 }
452
453
454 func (dua *dua_CM) FmtDateFull(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 b = append(b, dua.daysWide[t.Weekday()]...)
459 b = append(b, []byte{0x20}...)
460 b = strconv.AppendInt(b, int64(t.Day()), 10)
461 b = append(b, []byte{0x20}...)
462 b = append(b, dua.monthsWide[t.Month()]...)
463 b = append(b, []byte{0x20}...)
464
465 if t.Year() > 0 {
466 b = strconv.AppendInt(b, int64(t.Year()), 10)
467 } else {
468 b = strconv.AppendInt(b, int64(-t.Year()), 10)
469 }
470
471 return string(b)
472 }
473
474
475 func (dua *dua_CM) FmtTimeShort(t time.Time) string {
476
477 b := make([]byte, 0, 32)
478
479 if t.Hour() < 10 {
480 b = append(b, '0')
481 }
482
483 b = strconv.AppendInt(b, int64(t.Hour()), 10)
484 b = append(b, dua.timeSeparator...)
485
486 if t.Minute() < 10 {
487 b = append(b, '0')
488 }
489
490 b = strconv.AppendInt(b, int64(t.Minute()), 10)
491
492 return string(b)
493 }
494
495
496 func (dua *dua_CM) FmtTimeMedium(t time.Time) string {
497
498 b := make([]byte, 0, 32)
499
500 if t.Hour() < 10 {
501 b = append(b, '0')
502 }
503
504 b = strconv.AppendInt(b, int64(t.Hour()), 10)
505 b = append(b, dua.timeSeparator...)
506
507 if t.Minute() < 10 {
508 b = append(b, '0')
509 }
510
511 b = strconv.AppendInt(b, int64(t.Minute()), 10)
512 b = append(b, dua.timeSeparator...)
513
514 if t.Second() < 10 {
515 b = append(b, '0')
516 }
517
518 b = strconv.AppendInt(b, int64(t.Second()), 10)
519
520 return string(b)
521 }
522
523
524 func (dua *dua_CM) FmtTimeLong(t time.Time) string {
525
526 b := make([]byte, 0, 32)
527
528 if t.Hour() < 10 {
529 b = append(b, '0')
530 }
531
532 b = strconv.AppendInt(b, int64(t.Hour()), 10)
533 b = append(b, dua.timeSeparator...)
534
535 if t.Minute() < 10 {
536 b = append(b, '0')
537 }
538
539 b = strconv.AppendInt(b, int64(t.Minute()), 10)
540 b = append(b, dua.timeSeparator...)
541
542 if t.Second() < 10 {
543 b = append(b, '0')
544 }
545
546 b = strconv.AppendInt(b, int64(t.Second()), 10)
547 b = append(b, []byte{0x20}...)
548
549 tz, _ := t.Zone()
550 b = append(b, tz...)
551
552 return string(b)
553 }
554
555
556 func (dua *dua_CM) FmtTimeFull(t time.Time) string {
557
558 b := make([]byte, 0, 32)
559
560 if t.Hour() < 10 {
561 b = append(b, '0')
562 }
563
564 b = strconv.AppendInt(b, int64(t.Hour()), 10)
565 b = append(b, dua.timeSeparator...)
566
567 if t.Minute() < 10 {
568 b = append(b, '0')
569 }
570
571 b = strconv.AppendInt(b, int64(t.Minute()), 10)
572 b = append(b, dua.timeSeparator...)
573
574 if t.Second() < 10 {
575 b = append(b, '0')
576 }
577
578 b = strconv.AppendInt(b, int64(t.Second()), 10)
579 b = append(b, []byte{0x20}...)
580
581 tz, _ := t.Zone()
582
583 if btz, ok := dua.timezones[tz]; ok {
584 b = append(b, btz...)
585 } else {
586 b = append(b, tz...)
587 }
588
589 return string(b)
590 }
591
View as plain text