1 package cgg_UG
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 cgg_UG 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 monthsAbbreviated []string
26 monthsNarrow []string
27 monthsWide []string
28 daysAbbreviated []string
29 daysNarrow []string
30 daysShort []string
31 daysWide []string
32 periodsAbbreviated []string
33 periodsNarrow []string
34 periodsShort []string
35 periodsWide []string
36 erasAbbreviated []string
37 erasNarrow []string
38 erasWide []string
39 timezones map[string]string
40 }
41
42
43 func New() locales.Translator {
44 return &cgg_UG{
45 locale: "cgg_UG",
46 pluralsCardinal: []locales.PluralRule{2, 6},
47 pluralsOrdinal: nil,
48 pluralsRange: nil,
49 timeSeparator: ":",
50 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"},
51 monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"},
52 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
53 monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"},
54 daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"},
55 daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"},
56 daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"},
57 erasAbbreviated: []string{"BC", "AD"},
58 erasNarrow: []string{"", ""},
59 erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"},
60 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", "∅∅∅": "∅∅∅"},
61 }
62 }
63
64
65 func (cgg *cgg_UG) Locale() string {
66 return cgg.locale
67 }
68
69
70 func (cgg *cgg_UG) PluralsCardinal() []locales.PluralRule {
71 return cgg.pluralsCardinal
72 }
73
74
75 func (cgg *cgg_UG) PluralsOrdinal() []locales.PluralRule {
76 return cgg.pluralsOrdinal
77 }
78
79
80 func (cgg *cgg_UG) PluralsRange() []locales.PluralRule {
81 return cgg.pluralsRange
82 }
83
84
85 func (cgg *cgg_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
86
87 n := math.Abs(num)
88
89 if n == 1 {
90 return locales.PluralRuleOne
91 }
92
93 return locales.PluralRuleOther
94 }
95
96
97 func (cgg *cgg_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
98 return locales.PluralRuleUnknown
99 }
100
101
102 func (cgg *cgg_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
103 return locales.PluralRuleUnknown
104 }
105
106
107 func (cgg *cgg_UG) MonthAbbreviated(month time.Month) string {
108 return cgg.monthsAbbreviated[month]
109 }
110
111
112 func (cgg *cgg_UG) MonthsAbbreviated() []string {
113 return cgg.monthsAbbreviated[1:]
114 }
115
116
117 func (cgg *cgg_UG) MonthNarrow(month time.Month) string {
118 return cgg.monthsNarrow[month]
119 }
120
121
122 func (cgg *cgg_UG) MonthsNarrow() []string {
123 return cgg.monthsNarrow[1:]
124 }
125
126
127 func (cgg *cgg_UG) MonthWide(month time.Month) string {
128 return cgg.monthsWide[month]
129 }
130
131
132 func (cgg *cgg_UG) MonthsWide() []string {
133 return cgg.monthsWide[1:]
134 }
135
136
137 func (cgg *cgg_UG) WeekdayAbbreviated(weekday time.Weekday) string {
138 return cgg.daysAbbreviated[weekday]
139 }
140
141
142 func (cgg *cgg_UG) WeekdaysAbbreviated() []string {
143 return cgg.daysAbbreviated
144 }
145
146
147 func (cgg *cgg_UG) WeekdayNarrow(weekday time.Weekday) string {
148 return cgg.daysNarrow[weekday]
149 }
150
151
152 func (cgg *cgg_UG) WeekdaysNarrow() []string {
153 return cgg.daysNarrow
154 }
155
156
157 func (cgg *cgg_UG) WeekdayShort(weekday time.Weekday) string {
158 return cgg.daysShort[weekday]
159 }
160
161
162 func (cgg *cgg_UG) WeekdaysShort() []string {
163 return cgg.daysShort
164 }
165
166
167 func (cgg *cgg_UG) WeekdayWide(weekday time.Weekday) string {
168 return cgg.daysWide[weekday]
169 }
170
171
172 func (cgg *cgg_UG) WeekdaysWide() []string {
173 return cgg.daysWide
174 }
175
176
177 func (cgg *cgg_UG) Decimal() string {
178 return cgg.decimal
179 }
180
181
182 func (cgg *cgg_UG) Group() string {
183 return cgg.group
184 }
185
186
187 func (cgg *cgg_UG) Minus() string {
188 return cgg.minus
189 }
190
191
192 func (cgg *cgg_UG) FmtNumber(num float64, v uint64) string {
193
194 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
195 }
196
197
198
199 func (cgg *cgg_UG) FmtPercent(num float64, v uint64) string {
200 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
201 }
202
203
204 func (cgg *cgg_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string {
205
206 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
207 symbol := cgg.currencies[currency]
208 l := len(s) + len(symbol) + 0
209 count := 0
210 inWhole := v == 0
211 b := make([]byte, 0, l)
212
213 for i := len(s) - 1; i >= 0; i-- {
214
215 if s[i] == '.' {
216 b = append(b, cgg.decimal[0])
217 inWhole = true
218 continue
219 }
220
221 if inWhole {
222 if count == 3 {
223 b = append(b, cgg.group[0])
224 count = 1
225 } else {
226 count++
227 }
228 }
229
230 b = append(b, s[i])
231 }
232
233 for j := len(symbol) - 1; j >= 0; j-- {
234 b = append(b, symbol[j])
235 }
236
237 if num < 0 {
238 b = append(b, cgg.minus[0])
239 }
240
241
242 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
243 b[i], b[j] = b[j], b[i]
244 }
245
246 if int(v) < 2 {
247
248 if v == 0 {
249 b = append(b, cgg.decimal...)
250 }
251
252 for i := 0; i < 2-int(v); i++ {
253 b = append(b, '0')
254 }
255 }
256
257 return string(b)
258 }
259
260
261
262 func (cgg *cgg_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string {
263
264 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 symbol := cgg.currencies[currency]
266 l := len(s) + len(symbol) + 0
267 count := 0
268 inWhole := v == 0
269 b := make([]byte, 0, l)
270
271 for i := len(s) - 1; i >= 0; i-- {
272
273 if s[i] == '.' {
274 b = append(b, cgg.decimal[0])
275 inWhole = true
276 continue
277 }
278
279 if inWhole {
280 if count == 3 {
281 b = append(b, cgg.group[0])
282 count = 1
283 } else {
284 count++
285 }
286 }
287
288 b = append(b, s[i])
289 }
290
291 if num < 0 {
292
293 for j := len(symbol) - 1; j >= 0; j-- {
294 b = append(b, symbol[j])
295 }
296
297 b = append(b, cgg.minus[0])
298
299 } else {
300
301 for j := len(symbol) - 1; j >= 0; j-- {
302 b = append(b, symbol[j])
303 }
304
305 }
306
307
308 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
309 b[i], b[j] = b[j], b[i]
310 }
311
312 if int(v) < 2 {
313
314 if v == 0 {
315 b = append(b, cgg.decimal...)
316 }
317
318 for i := 0; i < 2-int(v); i++ {
319 b = append(b, '0')
320 }
321 }
322
323 return string(b)
324 }
325
326
327 func (cgg *cgg_UG) FmtDateShort(t time.Time) string {
328
329 b := make([]byte, 0, 32)
330
331 if t.Day() < 10 {
332 b = append(b, '0')
333 }
334
335 b = strconv.AppendInt(b, int64(t.Day()), 10)
336 b = append(b, []byte{0x2f}...)
337
338 if t.Month() < 10 {
339 b = append(b, '0')
340 }
341
342 b = strconv.AppendInt(b, int64(t.Month()), 10)
343
344 b = append(b, []byte{0x2f}...)
345
346 if t.Year() > 0 {
347 b = strconv.AppendInt(b, int64(t.Year()), 10)
348 } else {
349 b = strconv.AppendInt(b, int64(-t.Year()), 10)
350 }
351
352 return string(b)
353 }
354
355
356 func (cgg *cgg_UG) FmtDateMedium(t time.Time) string {
357
358 b := make([]byte, 0, 32)
359
360 b = strconv.AppendInt(b, int64(t.Day()), 10)
361 b = append(b, []byte{0x20}...)
362 b = append(b, cgg.monthsAbbreviated[t.Month()]...)
363 b = append(b, []byte{0x20}...)
364
365 if t.Year() > 0 {
366 b = strconv.AppendInt(b, int64(t.Year()), 10)
367 } else {
368 b = strconv.AppendInt(b, int64(-t.Year()), 10)
369 }
370
371 return string(b)
372 }
373
374
375 func (cgg *cgg_UG) FmtDateLong(t time.Time) string {
376
377 b := make([]byte, 0, 32)
378
379 b = strconv.AppendInt(b, int64(t.Day()), 10)
380 b = append(b, []byte{0x20}...)
381 b = append(b, cgg.monthsWide[t.Month()]...)
382 b = append(b, []byte{0x20}...)
383
384 if t.Year() > 0 {
385 b = strconv.AppendInt(b, int64(t.Year()), 10)
386 } else {
387 b = strconv.AppendInt(b, int64(-t.Year()), 10)
388 }
389
390 return string(b)
391 }
392
393
394 func (cgg *cgg_UG) FmtDateFull(t time.Time) string {
395
396 b := make([]byte, 0, 32)
397
398 b = append(b, cgg.daysWide[t.Weekday()]...)
399 b = append(b, []byte{0x2c, 0x20}...)
400 b = strconv.AppendInt(b, int64(t.Day()), 10)
401 b = append(b, []byte{0x20}...)
402 b = append(b, cgg.monthsWide[t.Month()]...)
403 b = append(b, []byte{0x20}...)
404
405 if t.Year() > 0 {
406 b = strconv.AppendInt(b, int64(t.Year()), 10)
407 } else {
408 b = strconv.AppendInt(b, int64(-t.Year()), 10)
409 }
410
411 return string(b)
412 }
413
414
415 func (cgg *cgg_UG) FmtTimeShort(t time.Time) string {
416
417 b := make([]byte, 0, 32)
418
419 if t.Hour() < 10 {
420 b = append(b, '0')
421 }
422
423 b = strconv.AppendInt(b, int64(t.Hour()), 10)
424 b = append(b, cgg.timeSeparator...)
425
426 if t.Minute() < 10 {
427 b = append(b, '0')
428 }
429
430 b = strconv.AppendInt(b, int64(t.Minute()), 10)
431
432 return string(b)
433 }
434
435
436 func (cgg *cgg_UG) FmtTimeMedium(t time.Time) string {
437
438 b := make([]byte, 0, 32)
439
440 if t.Hour() < 10 {
441 b = append(b, '0')
442 }
443
444 b = strconv.AppendInt(b, int64(t.Hour()), 10)
445 b = append(b, cgg.timeSeparator...)
446
447 if t.Minute() < 10 {
448 b = append(b, '0')
449 }
450
451 b = strconv.AppendInt(b, int64(t.Minute()), 10)
452 b = append(b, cgg.timeSeparator...)
453
454 if t.Second() < 10 {
455 b = append(b, '0')
456 }
457
458 b = strconv.AppendInt(b, int64(t.Second()), 10)
459
460 return string(b)
461 }
462
463
464 func (cgg *cgg_UG) FmtTimeLong(t time.Time) string {
465
466 b := make([]byte, 0, 32)
467
468 if t.Hour() < 10 {
469 b = append(b, '0')
470 }
471
472 b = strconv.AppendInt(b, int64(t.Hour()), 10)
473 b = append(b, cgg.timeSeparator...)
474
475 if t.Minute() < 10 {
476 b = append(b, '0')
477 }
478
479 b = strconv.AppendInt(b, int64(t.Minute()), 10)
480 b = append(b, cgg.timeSeparator...)
481
482 if t.Second() < 10 {
483 b = append(b, '0')
484 }
485
486 b = strconv.AppendInt(b, int64(t.Second()), 10)
487 b = append(b, []byte{0x20}...)
488
489 tz, _ := t.Zone()
490 b = append(b, tz...)
491
492 return string(b)
493 }
494
495
496 func (cgg *cgg_UG) FmtTimeFull(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, cgg.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, cgg.timeSeparator...)
513
514 if t.Second() < 10 {
515 b = append(b, '0')
516 }
517
518 b = strconv.AppendInt(b, int64(t.Second()), 10)
519 b = append(b, []byte{0x20}...)
520
521 tz, _ := t.Zone()
522
523 if btz, ok := cgg.timezones[tz]; ok {
524 b = append(b, btz...)
525 } else {
526 b = append(b, tz...)
527 }
528
529 return string(b)
530 }
531
View as plain text