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