1 package ksf_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 ksf_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 &ksf_CM{
47 locale: "ksf_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{"", "ŋ1", "ŋ2", "ŋ3", "ŋ4", "ŋ5", "ŋ6", "ŋ7", "ŋ8", "ŋ9", "ŋ10", "ŋ11", "ŋ12"},
58 monthsWide: []string{"", "ŋwíí a ntɔ́ntɔ", "ŋwíí akǝ bɛ́ɛ", "ŋwíí akǝ ráá", "ŋwíí akǝ nin", "ŋwíí akǝ táan", "ŋwíí akǝ táafɔk", "ŋwíí akǝ táabɛɛ", "ŋwíí akǝ táaraa", "ŋwíí akǝ táanin", "ŋwíí akǝ ntɛk", "ŋwíí akǝ ntɛk di bɔ́k", "ŋwíí akǝ ntɛk di bɛ́ɛ"},
59 daysAbbreviated: []string{"sɔ́n", "lǝn", "maa", "mɛk", "jǝǝ", "júm", "sam"},
60 daysNarrow: []string{"s", "l", "m", "m", "j", "j", "s"},
61 daysWide: []string{"sɔ́ndǝ", "lǝndí", "maadí", "mɛkrɛdí", "jǝǝdí", "júmbá", "samdí"},
62 periodsAbbreviated: []string{"sárúwá", "cɛɛ́nko"},
63 periodsWide: []string{"sárúwá", "cɛɛ́nko"},
64 erasAbbreviated: []string{"d.Y.", "k.Y."},
65 erasNarrow: []string{"", ""},
66 erasWide: []string{"di Yɛ́sus aká yálɛ", "cámɛɛn kǝ kǝbɔpka Y"},
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 (ksf *ksf_CM) Locale() string {
73 return ksf.locale
74 }
75
76
77 func (ksf *ksf_CM) PluralsCardinal() []locales.PluralRule {
78 return ksf.pluralsCardinal
79 }
80
81
82 func (ksf *ksf_CM) PluralsOrdinal() []locales.PluralRule {
83 return ksf.pluralsOrdinal
84 }
85
86
87 func (ksf *ksf_CM) PluralsRange() []locales.PluralRule {
88 return ksf.pluralsRange
89 }
90
91
92 func (ksf *ksf_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
93 return locales.PluralRuleUnknown
94 }
95
96
97 func (ksf *ksf_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
98 return locales.PluralRuleUnknown
99 }
100
101
102 func (ksf *ksf_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
103 return locales.PluralRuleUnknown
104 }
105
106
107 func (ksf *ksf_CM) MonthAbbreviated(month time.Month) string {
108 return ksf.monthsAbbreviated[month]
109 }
110
111
112 func (ksf *ksf_CM) MonthsAbbreviated() []string {
113 return ksf.monthsAbbreviated[1:]
114 }
115
116
117 func (ksf *ksf_CM) MonthNarrow(month time.Month) string {
118 return ksf.monthsNarrow[month]
119 }
120
121
122 func (ksf *ksf_CM) MonthsNarrow() []string {
123 return nil
124 }
125
126
127 func (ksf *ksf_CM) MonthWide(month time.Month) string {
128 return ksf.monthsWide[month]
129 }
130
131
132 func (ksf *ksf_CM) MonthsWide() []string {
133 return ksf.monthsWide[1:]
134 }
135
136
137 func (ksf *ksf_CM) WeekdayAbbreviated(weekday time.Weekday) string {
138 return ksf.daysAbbreviated[weekday]
139 }
140
141
142 func (ksf *ksf_CM) WeekdaysAbbreviated() []string {
143 return ksf.daysAbbreviated
144 }
145
146
147 func (ksf *ksf_CM) WeekdayNarrow(weekday time.Weekday) string {
148 return ksf.daysNarrow[weekday]
149 }
150
151
152 func (ksf *ksf_CM) WeekdaysNarrow() []string {
153 return ksf.daysNarrow
154 }
155
156
157 func (ksf *ksf_CM) WeekdayShort(weekday time.Weekday) string {
158 return ksf.daysShort[weekday]
159 }
160
161
162 func (ksf *ksf_CM) WeekdaysShort() []string {
163 return ksf.daysShort
164 }
165
166
167 func (ksf *ksf_CM) WeekdayWide(weekday time.Weekday) string {
168 return ksf.daysWide[weekday]
169 }
170
171
172 func (ksf *ksf_CM) WeekdaysWide() []string {
173 return ksf.daysWide
174 }
175
176
177 func (ksf *ksf_CM) Decimal() string {
178 return ksf.decimal
179 }
180
181
182 func (ksf *ksf_CM) Group() string {
183 return ksf.group
184 }
185
186
187 func (ksf *ksf_CM) Minus() string {
188 return ksf.minus
189 }
190
191
192 func (ksf *ksf_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, ksf.decimal[0])
204 inWhole = true
205 continue
206 }
207
208 if inWhole {
209 if count == 3 {
210 for j := len(ksf.group) - 1; j >= 0; j-- {
211 b = append(b, ksf.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, ksf.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 (ksf *ksf_CM) FmtPercent(num float64, v uint64) string {
237 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
238 }
239
240
241 func (ksf *ksf_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
242
243 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
244 symbol := ksf.currencies[currency]
245 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
246 count := 0
247 inWhole := v == 0
248 b := make([]byte, 0, l)
249
250 for i := len(s) - 1; i >= 0; i-- {
251
252 if s[i] == '.' {
253 b = append(b, ksf.decimal[0])
254 inWhole = true
255 continue
256 }
257
258 if inWhole {
259 if count == 3 {
260 for j := len(ksf.group) - 1; j >= 0; j-- {
261 b = append(b, ksf.group[j])
262 }
263 count = 1
264 } else {
265 count++
266 }
267 }
268
269 b = append(b, s[i])
270 }
271
272 if num < 0 {
273 b = append(b, ksf.minus[0])
274 }
275
276
277 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
278 b[i], b[j] = b[j], b[i]
279 }
280
281 if int(v) < 2 {
282
283 if v == 0 {
284 b = append(b, ksf.decimal...)
285 }
286
287 for i := 0; i < 2-int(v); i++ {
288 b = append(b, '0')
289 }
290 }
291
292 b = append(b, ksf.currencyPositiveSuffix...)
293
294 b = append(b, symbol...)
295
296 return string(b)
297 }
298
299
300
301 func (ksf *ksf_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
302
303 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
304 symbol := ksf.currencies[currency]
305 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
306 count := 0
307 inWhole := v == 0
308 b := make([]byte, 0, l)
309
310 for i := len(s) - 1; i >= 0; i-- {
311
312 if s[i] == '.' {
313 b = append(b, ksf.decimal[0])
314 inWhole = true
315 continue
316 }
317
318 if inWhole {
319 if count == 3 {
320 for j := len(ksf.group) - 1; j >= 0; j-- {
321 b = append(b, ksf.group[j])
322 }
323 count = 1
324 } else {
325 count++
326 }
327 }
328
329 b = append(b, s[i])
330 }
331
332 if num < 0 {
333
334 b = append(b, ksf.minus[0])
335
336 }
337
338
339 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
340 b[i], b[j] = b[j], b[i]
341 }
342
343 if int(v) < 2 {
344
345 if v == 0 {
346 b = append(b, ksf.decimal...)
347 }
348
349 for i := 0; i < 2-int(v); i++ {
350 b = append(b, '0')
351 }
352 }
353
354 if num < 0 {
355 b = append(b, ksf.currencyNegativeSuffix...)
356 b = append(b, symbol...)
357 } else {
358
359 b = append(b, ksf.currencyPositiveSuffix...)
360 b = append(b, symbol...)
361 }
362
363 return string(b)
364 }
365
366
367 func (ksf *ksf_CM) FmtDateShort(t time.Time) string {
368
369 b := make([]byte, 0, 32)
370
371 b = strconv.AppendInt(b, int64(t.Day()), 10)
372 b = append(b, []byte{0x2f}...)
373 b = strconv.AppendInt(b, int64(t.Month()), 10)
374 b = append(b, []byte{0x2f}...)
375
376 if t.Year() > 0 {
377 b = strconv.AppendInt(b, int64(t.Year()), 10)
378 } else {
379 b = strconv.AppendInt(b, int64(-t.Year()), 10)
380 }
381
382 return string(b)
383 }
384
385
386 func (ksf *ksf_CM) FmtDateMedium(t time.Time) string {
387
388 b := make([]byte, 0, 32)
389
390 b = strconv.AppendInt(b, int64(t.Day()), 10)
391 b = append(b, []byte{0x20}...)
392 b = append(b, ksf.monthsAbbreviated[t.Month()]...)
393 b = append(b, []byte{0x20}...)
394
395 if t.Year() > 0 {
396 b = strconv.AppendInt(b, int64(t.Year()), 10)
397 } else {
398 b = strconv.AppendInt(b, int64(-t.Year()), 10)
399 }
400
401 return string(b)
402 }
403
404
405 func (ksf *ksf_CM) FmtDateLong(t time.Time) string {
406
407 b := make([]byte, 0, 32)
408
409 b = strconv.AppendInt(b, int64(t.Day()), 10)
410 b = append(b, []byte{0x20}...)
411 b = append(b, ksf.monthsWide[t.Month()]...)
412 b = append(b, []byte{0x20}...)
413
414 if t.Year() > 0 {
415 b = strconv.AppendInt(b, int64(t.Year()), 10)
416 } else {
417 b = strconv.AppendInt(b, int64(-t.Year()), 10)
418 }
419
420 return string(b)
421 }
422
423
424 func (ksf *ksf_CM) FmtDateFull(t time.Time) string {
425
426 b := make([]byte, 0, 32)
427
428 b = append(b, ksf.daysWide[t.Weekday()]...)
429 b = append(b, []byte{0x20}...)
430 b = strconv.AppendInt(b, int64(t.Day()), 10)
431 b = append(b, []byte{0x20}...)
432 b = append(b, ksf.monthsWide[t.Month()]...)
433 b = append(b, []byte{0x20}...)
434
435 if t.Year() > 0 {
436 b = strconv.AppendInt(b, int64(t.Year()), 10)
437 } else {
438 b = strconv.AppendInt(b, int64(-t.Year()), 10)
439 }
440
441 return string(b)
442 }
443
444
445 func (ksf *ksf_CM) FmtTimeShort(t time.Time) string {
446
447 b := make([]byte, 0, 32)
448
449 if t.Hour() < 10 {
450 b = append(b, '0')
451 }
452
453 b = strconv.AppendInt(b, int64(t.Hour()), 10)
454 b = append(b, ksf.timeSeparator...)
455
456 if t.Minute() < 10 {
457 b = append(b, '0')
458 }
459
460 b = strconv.AppendInt(b, int64(t.Minute()), 10)
461
462 return string(b)
463 }
464
465
466 func (ksf *ksf_CM) FmtTimeMedium(t time.Time) string {
467
468 b := make([]byte, 0, 32)
469
470 if t.Hour() < 10 {
471 b = append(b, '0')
472 }
473
474 b = strconv.AppendInt(b, int64(t.Hour()), 10)
475 b = append(b, ksf.timeSeparator...)
476
477 if t.Minute() < 10 {
478 b = append(b, '0')
479 }
480
481 b = strconv.AppendInt(b, int64(t.Minute()), 10)
482 b = append(b, ksf.timeSeparator...)
483
484 if t.Second() < 10 {
485 b = append(b, '0')
486 }
487
488 b = strconv.AppendInt(b, int64(t.Second()), 10)
489
490 return string(b)
491 }
492
493
494 func (ksf *ksf_CM) FmtTimeLong(t time.Time) string {
495
496 b := make([]byte, 0, 32)
497
498 if t.Hour() < 10 {
499 b = append(b, '0')
500 }
501
502 b = strconv.AppendInt(b, int64(t.Hour()), 10)
503 b = append(b, ksf.timeSeparator...)
504
505 if t.Minute() < 10 {
506 b = append(b, '0')
507 }
508
509 b = strconv.AppendInt(b, int64(t.Minute()), 10)
510 b = append(b, ksf.timeSeparator...)
511
512 if t.Second() < 10 {
513 b = append(b, '0')
514 }
515
516 b = strconv.AppendInt(b, int64(t.Second()), 10)
517 b = append(b, []byte{0x20}...)
518
519 tz, _ := t.Zone()
520 b = append(b, tz...)
521
522 return string(b)
523 }
524
525
526 func (ksf *ksf_CM) FmtTimeFull(t time.Time) string {
527
528 b := make([]byte, 0, 32)
529
530 if t.Hour() < 10 {
531 b = append(b, '0')
532 }
533
534 b = strconv.AppendInt(b, int64(t.Hour()), 10)
535 b = append(b, ksf.timeSeparator...)
536
537 if t.Minute() < 10 {
538 b = append(b, '0')
539 }
540
541 b = strconv.AppendInt(b, int64(t.Minute()), 10)
542 b = append(b, ksf.timeSeparator...)
543
544 if t.Second() < 10 {
545 b = append(b, '0')
546 }
547
548 b = strconv.AppendInt(b, int64(t.Second()), 10)
549 b = append(b, []byte{0x20}...)
550
551 tz, _ := t.Zone()
552
553 if btz, ok := ksf.timezones[tz]; ok {
554 b = append(b, btz...)
555 } else {
556 b = append(b, tz...)
557 }
558
559 return string(b)
560 }
561
View as plain text