1 package ti_ET
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 ti_ET 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 &ti_ET{
45 locale: "ti_ET",
46 pluralsCardinal: []locales.PluralRule{2, 6},
47 pluralsOrdinal: nil,
48 pluralsRange: nil,
49 decimal: ".",
50 group: ",",
51 minus: "-",
52 percent: "%",
53 perMille: "‰",
54 timeSeparator: ":",
55 inifinity: "∞",
56 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"},
57 monthsAbbreviated: []string{"", "ጥሪ", "ለካ", "መጋ", "ሚያ", "ግን", "ሰነ", "ሓም", "ነሓ", "መስ", "ጥቅ", "ሕዳ", "ታሕ"},
58 monthsNarrow: []string{"", "ጥ", "ለ", "መ", "ሚ", "ግ", "ሰ", "ሓ", "ነ", "መ", "ጥ", "ሕ", "ታ"},
59 monthsWide: []string{"", "ጥሪ", "ለካቲት", "መጋቢት", "ሚያዝያ", "ግንቦት", "ሰነ", "ሓምለ", "ነሓሰ", "መስከረም", "ጥቅምቲ", "ሕዳር", "ታሕሳስ"},
60 daysAbbreviated: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"},
61 daysNarrow: []string{"ሰ", "ሰ", "ሰ", "ረ", "ሓ", "ዓ", "ቀ"},
62 daysShort: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"},
63 daysWide: []string{"ሰንበት", "ሰኑይ", "ሠሉስ", "ረቡዕ", "ኃሙስ", "ዓርቢ", "ቀዳም"},
64 periodsAbbreviated: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"},
65 periodsNarrow: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"},
66 periodsWide: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"},
67 erasAbbreviated: []string{"ዓ/ዓ", "ዓ/ም"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"ዓ/ዓ", "ዓመተ ምህረት"},
70 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", "∅∅∅": "∅∅∅"},
71 }
72 }
73
74
75 func (ti *ti_ET) Locale() string {
76 return ti.locale
77 }
78
79
80 func (ti *ti_ET) PluralsCardinal() []locales.PluralRule {
81 return ti.pluralsCardinal
82 }
83
84
85 func (ti *ti_ET) PluralsOrdinal() []locales.PluralRule {
86 return ti.pluralsOrdinal
87 }
88
89
90 func (ti *ti_ET) PluralsRange() []locales.PluralRule {
91 return ti.pluralsRange
92 }
93
94
95 func (ti *ti_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97 n := math.Abs(num)
98
99 if n >= 0 && n <= 1 {
100 return locales.PluralRuleOne
101 }
102
103 return locales.PluralRuleOther
104 }
105
106
107 func (ti *ti_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
108 return locales.PluralRuleUnknown
109 }
110
111
112 func (ti *ti_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
113 return locales.PluralRuleUnknown
114 }
115
116
117 func (ti *ti_ET) MonthAbbreviated(month time.Month) string {
118 return ti.monthsAbbreviated[month]
119 }
120
121
122 func (ti *ti_ET) MonthsAbbreviated() []string {
123 return ti.monthsAbbreviated[1:]
124 }
125
126
127 func (ti *ti_ET) MonthNarrow(month time.Month) string {
128 return ti.monthsNarrow[month]
129 }
130
131
132 func (ti *ti_ET) MonthsNarrow() []string {
133 return ti.monthsNarrow[1:]
134 }
135
136
137 func (ti *ti_ET) MonthWide(month time.Month) string {
138 return ti.monthsWide[month]
139 }
140
141
142 func (ti *ti_ET) MonthsWide() []string {
143 return ti.monthsWide[1:]
144 }
145
146
147 func (ti *ti_ET) WeekdayAbbreviated(weekday time.Weekday) string {
148 return ti.daysAbbreviated[weekday]
149 }
150
151
152 func (ti *ti_ET) WeekdaysAbbreviated() []string {
153 return ti.daysAbbreviated
154 }
155
156
157 func (ti *ti_ET) WeekdayNarrow(weekday time.Weekday) string {
158 return ti.daysNarrow[weekday]
159 }
160
161
162 func (ti *ti_ET) WeekdaysNarrow() []string {
163 return ti.daysNarrow
164 }
165
166
167 func (ti *ti_ET) WeekdayShort(weekday time.Weekday) string {
168 return ti.daysShort[weekday]
169 }
170
171
172 func (ti *ti_ET) WeekdaysShort() []string {
173 return ti.daysShort
174 }
175
176
177 func (ti *ti_ET) WeekdayWide(weekday time.Weekday) string {
178 return ti.daysWide[weekday]
179 }
180
181
182 func (ti *ti_ET) WeekdaysWide() []string {
183 return ti.daysWide
184 }
185
186
187 func (ti *ti_ET) Decimal() string {
188 return ti.decimal
189 }
190
191
192 func (ti *ti_ET) Group() string {
193 return ti.group
194 }
195
196
197 func (ti *ti_ET) Minus() string {
198 return ti.minus
199 }
200
201
202 func (ti *ti_ET) FmtNumber(num float64, v uint64) string {
203
204 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
206 count := 0
207 inWhole := v == 0
208 b := make([]byte, 0, l)
209
210 for i := len(s) - 1; i >= 0; i-- {
211
212 if s[i] == '.' {
213 b = append(b, ti.decimal[0])
214 inWhole = true
215 continue
216 }
217
218 if inWhole {
219 if count == 3 {
220 b = append(b, ti.group[0])
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, ti.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 (ti *ti_ET) 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, ti.decimal[0])
253 continue
254 }
255
256 b = append(b, s[i])
257 }
258
259 if num < 0 {
260 b = append(b, ti.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, ti.percent...)
269
270 return string(b)
271 }
272
273
274 func (ti *ti_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string {
275
276 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
277 symbol := ti.currencies[currency]
278 l := len(s) + len(symbol) + 2 + 1*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, ti.decimal[0])
287 inWhole = true
288 continue
289 }
290
291 if inWhole {
292 if count == 3 {
293 b = append(b, ti.group[0])
294 count = 1
295 } else {
296 count++
297 }
298 }
299
300 b = append(b, s[i])
301 }
302
303 for j := len(symbol) - 1; j >= 0; j-- {
304 b = append(b, symbol[j])
305 }
306
307 if num < 0 {
308 b = append(b, ti.minus[0])
309 }
310
311
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
314 }
315
316 if int(v) < 2 {
317
318 if v == 0 {
319 b = append(b, ti.decimal...)
320 }
321
322 for i := 0; i < 2-int(v); i++ {
323 b = append(b, '0')
324 }
325 }
326
327 return string(b)
328 }
329
330
331
332 func (ti *ti_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string {
333
334 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
335 symbol := ti.currencies[currency]
336 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
337 count := 0
338 inWhole := v == 0
339 b := make([]byte, 0, l)
340
341 for i := len(s) - 1; i >= 0; i-- {
342
343 if s[i] == '.' {
344 b = append(b, ti.decimal[0])
345 inWhole = true
346 continue
347 }
348
349 if inWhole {
350 if count == 3 {
351 b = append(b, ti.group[0])
352 count = 1
353 } else {
354 count++
355 }
356 }
357
358 b = append(b, s[i])
359 }
360
361 if num < 0 {
362
363 for j := len(symbol) - 1; j >= 0; j-- {
364 b = append(b, symbol[j])
365 }
366
367 b = append(b, ti.minus[0])
368
369 } else {
370
371 for j := len(symbol) - 1; j >= 0; j-- {
372 b = append(b, symbol[j])
373 }
374
375 }
376
377
378 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
379 b[i], b[j] = b[j], b[i]
380 }
381
382 if int(v) < 2 {
383
384 if v == 0 {
385 b = append(b, ti.decimal...)
386 }
387
388 for i := 0; i < 2-int(v); i++ {
389 b = append(b, '0')
390 }
391 }
392
393 return string(b)
394 }
395
396
397 func (ti *ti_ET) FmtDateShort(t time.Time) string {
398
399 b := make([]byte, 0, 32)
400
401 if t.Day() < 10 {
402 b = append(b, '0')
403 }
404
405 b = strconv.AppendInt(b, int64(t.Day()), 10)
406 b = append(b, []byte{0x2f}...)
407
408 if t.Month() < 10 {
409 b = append(b, '0')
410 }
411
412 b = strconv.AppendInt(b, int64(t.Month()), 10)
413
414 b = append(b, []byte{0x2f}...)
415
416 if t.Year() > 9 {
417 b = append(b, strconv.Itoa(t.Year())[2:]...)
418 } else {
419 b = append(b, strconv.Itoa(t.Year())[1:]...)
420 }
421
422 return string(b)
423 }
424
425
426 func (ti *ti_ET) FmtDateMedium(t time.Time) string {
427
428 b := make([]byte, 0, 32)
429
430 if t.Day() < 10 {
431 b = append(b, '0')
432 }
433
434 b = strconv.AppendInt(b, int64(t.Day()), 10)
435 b = append(b, []byte{0x2d}...)
436 b = append(b, ti.monthsAbbreviated[t.Month()]...)
437 b = append(b, []byte{0x2d}...)
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 (ti *ti_ET) FmtDateLong(t time.Time) string {
450
451 b := make([]byte, 0, 32)
452
453 if t.Day() < 10 {
454 b = append(b, '0')
455 }
456
457 b = strconv.AppendInt(b, int64(t.Day()), 10)
458 b = append(b, []byte{0x20}...)
459 b = append(b, ti.monthsWide[t.Month()]...)
460 b = append(b, []byte{0x20}...)
461
462 if t.Year() > 0 {
463 b = strconv.AppendInt(b, int64(t.Year()), 10)
464 } else {
465 b = strconv.AppendInt(b, int64(-t.Year()), 10)
466 }
467
468 return string(b)
469 }
470
471
472 func (ti *ti_ET) FmtDateFull(t time.Time) string {
473
474 b := make([]byte, 0, 32)
475
476 b = append(b, ti.daysWide[t.Weekday()]...)
477 b = append(b, []byte{0xe1, 0x8d, 0xa3, 0x20}...)
478
479 if t.Day() < 10 {
480 b = append(b, '0')
481 }
482
483 b = strconv.AppendInt(b, int64(t.Day()), 10)
484 b = append(b, []byte{0x20}...)
485 b = append(b, ti.monthsWide[t.Month()]...)
486 b = append(b, []byte{0x20, 0xe1, 0x88, 0x98, 0xe1, 0x8b, 0x93, 0xe1, 0x88, 0x8d, 0xe1, 0x89, 0xb2, 0x20}...)
487
488 if t.Year() > 0 {
489 b = strconv.AppendInt(b, int64(t.Year()), 10)
490 } else {
491 b = strconv.AppendInt(b, int64(-t.Year()), 10)
492 }
493
494 b = append(b, []byte{0x20}...)
495
496 if t.Year() < 0 {
497 b = append(b, ti.erasWide[0]...)
498 } else {
499 b = append(b, ti.erasWide[1]...)
500 }
501
502 return string(b)
503 }
504
505
506 func (ti *ti_ET) FmtTimeShort(t time.Time) string {
507
508 b := make([]byte, 0, 32)
509
510 h := t.Hour()
511
512 if h > 12 {
513 h -= 12
514 }
515
516 b = strconv.AppendInt(b, int64(h), 10)
517 b = append(b, ti.timeSeparator...)
518
519 if t.Minute() < 10 {
520 b = append(b, '0')
521 }
522
523 b = strconv.AppendInt(b, int64(t.Minute()), 10)
524 b = append(b, []byte{0x20}...)
525
526 if t.Hour() < 12 {
527 b = append(b, ti.periodsAbbreviated[0]...)
528 } else {
529 b = append(b, ti.periodsAbbreviated[1]...)
530 }
531
532 return string(b)
533 }
534
535
536 func (ti *ti_ET) FmtTimeMedium(t time.Time) string {
537
538 b := make([]byte, 0, 32)
539
540 h := t.Hour()
541
542 if h > 12 {
543 h -= 12
544 }
545
546 b = strconv.AppendInt(b, int64(h), 10)
547 b = append(b, ti.timeSeparator...)
548
549 if t.Minute() < 10 {
550 b = append(b, '0')
551 }
552
553 b = strconv.AppendInt(b, int64(t.Minute()), 10)
554 b = append(b, ti.timeSeparator...)
555
556 if t.Second() < 10 {
557 b = append(b, '0')
558 }
559
560 b = strconv.AppendInt(b, int64(t.Second()), 10)
561 b = append(b, []byte{0x20}...)
562
563 if t.Hour() < 12 {
564 b = append(b, ti.periodsAbbreviated[0]...)
565 } else {
566 b = append(b, ti.periodsAbbreviated[1]...)
567 }
568
569 return string(b)
570 }
571
572
573 func (ti *ti_ET) FmtTimeLong(t time.Time) string {
574
575 b := make([]byte, 0, 32)
576
577 h := t.Hour()
578
579 if h > 12 {
580 h -= 12
581 }
582
583 b = strconv.AppendInt(b, int64(h), 10)
584 b = append(b, ti.timeSeparator...)
585
586 if t.Minute() < 10 {
587 b = append(b, '0')
588 }
589
590 b = strconv.AppendInt(b, int64(t.Minute()), 10)
591 b = append(b, ti.timeSeparator...)
592
593 if t.Second() < 10 {
594 b = append(b, '0')
595 }
596
597 b = strconv.AppendInt(b, int64(t.Second()), 10)
598 b = append(b, []byte{0x20}...)
599
600 if t.Hour() < 12 {
601 b = append(b, ti.periodsAbbreviated[0]...)
602 } else {
603 b = append(b, ti.periodsAbbreviated[1]...)
604 }
605
606 b = append(b, []byte{0x20}...)
607
608 tz, _ := t.Zone()
609 b = append(b, tz...)
610
611 return string(b)
612 }
613
614
615 func (ti *ti_ET) FmtTimeFull(t time.Time) string {
616
617 b := make([]byte, 0, 32)
618
619 h := t.Hour()
620
621 if h > 12 {
622 h -= 12
623 }
624
625 b = strconv.AppendInt(b, int64(h), 10)
626 b = append(b, ti.timeSeparator...)
627
628 if t.Minute() < 10 {
629 b = append(b, '0')
630 }
631
632 b = strconv.AppendInt(b, int64(t.Minute()), 10)
633 b = append(b, ti.timeSeparator...)
634
635 if t.Second() < 10 {
636 b = append(b, '0')
637 }
638
639 b = strconv.AppendInt(b, int64(t.Second()), 10)
640 b = append(b, []byte{0x20}...)
641
642 if t.Hour() < 12 {
643 b = append(b, ti.periodsAbbreviated[0]...)
644 } else {
645 b = append(b, ti.periodsAbbreviated[1]...)
646 }
647
648 b = append(b, []byte{0x20}...)
649
650 tz, _ := t.Zone()
651
652 if btz, ok := ti.timezones[tz]; ok {
653 b = append(b, btz...)
654 } else {
655 b = append(b, tz...)
656 }
657
658 return string(b)
659 }
660
View as plain text