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