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