1 package mt_MT
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 mt_MT 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 &mt_MT{
45 locale: "mt_MT",
46 pluralsCardinal: []locales.PluralRule{2, 4, 5, 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{"", "Jan", "Fra", "Mar", "Apr", "Mej", "Ġun", "Lul", "Aww", "Set", "Ott", "Nov", "Diċ"},
58 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Ġ", "L", "A", "S", "O", "N", "D"},
59 monthsWide: []string{"", "Jannar", "Frar", "Marzu", "April", "Mejju", "Ġunju", "Lulju", "Awwissu", "Settembru", "Ottubru", "Novembru", "Diċembru"},
60 daysAbbreviated: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"},
61 daysNarrow: []string{"Ħd", "T", "Tl", "Er", "Ħm", "Ġm", "Sb"},
62 daysShort: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"},
63 daysWide: []string{"Il-Ħadd", "It-Tnejn", "It-Tlieta", "L-Erbgħa", "Il-Ħamis", "Il-Ġimgħa", "Is-Sibt"},
64 periodsAbbreviated: []string{"AM", "PM"},
65 periodsNarrow: []string{"am", "pm"},
66 periodsWide: []string{"AM", "PM"},
67 erasAbbreviated: []string{"QK", "WK"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"Qabel Kristu", "Wara Kristu"},
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": "Ħin Ċentrali Ewropew tas-Sajf", "MEZ": "Ħin Ċentrali Ewropew Standard", "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 (mt *mt_MT) Locale() string {
76 return mt.locale
77 }
78
79
80 func (mt *mt_MT) PluralsCardinal() []locales.PluralRule {
81 return mt.pluralsCardinal
82 }
83
84
85 func (mt *mt_MT) PluralsOrdinal() []locales.PluralRule {
86 return mt.pluralsOrdinal
87 }
88
89
90 func (mt *mt_MT) PluralsRange() []locales.PluralRule {
91 return mt.pluralsRange
92 }
93
94
95 func (mt *mt_MT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97 n := math.Abs(num)
98 nMod100 := math.Mod(n, 100)
99
100 if n == 1 {
101 return locales.PluralRuleOne
102 } else if (n == 0) || (nMod100 >= 2 && nMod100 <= 10) {
103 return locales.PluralRuleFew
104 } else if nMod100 >= 11 && nMod100 <= 19 {
105 return locales.PluralRuleMany
106 }
107
108 return locales.PluralRuleOther
109 }
110
111
112 func (mt *mt_MT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113 return locales.PluralRuleUnknown
114 }
115
116
117 func (mt *mt_MT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
118 return locales.PluralRuleUnknown
119 }
120
121
122 func (mt *mt_MT) MonthAbbreviated(month time.Month) string {
123 return mt.monthsAbbreviated[month]
124 }
125
126
127 func (mt *mt_MT) MonthsAbbreviated() []string {
128 return mt.monthsAbbreviated[1:]
129 }
130
131
132 func (mt *mt_MT) MonthNarrow(month time.Month) string {
133 return mt.monthsNarrow[month]
134 }
135
136
137 func (mt *mt_MT) MonthsNarrow() []string {
138 return mt.monthsNarrow[1:]
139 }
140
141
142 func (mt *mt_MT) MonthWide(month time.Month) string {
143 return mt.monthsWide[month]
144 }
145
146
147 func (mt *mt_MT) MonthsWide() []string {
148 return mt.monthsWide[1:]
149 }
150
151
152 func (mt *mt_MT) WeekdayAbbreviated(weekday time.Weekday) string {
153 return mt.daysAbbreviated[weekday]
154 }
155
156
157 func (mt *mt_MT) WeekdaysAbbreviated() []string {
158 return mt.daysAbbreviated
159 }
160
161
162 func (mt *mt_MT) WeekdayNarrow(weekday time.Weekday) string {
163 return mt.daysNarrow[weekday]
164 }
165
166
167 func (mt *mt_MT) WeekdaysNarrow() []string {
168 return mt.daysNarrow
169 }
170
171
172 func (mt *mt_MT) WeekdayShort(weekday time.Weekday) string {
173 return mt.daysShort[weekday]
174 }
175
176
177 func (mt *mt_MT) WeekdaysShort() []string {
178 return mt.daysShort
179 }
180
181
182 func (mt *mt_MT) WeekdayWide(weekday time.Weekday) string {
183 return mt.daysWide[weekday]
184 }
185
186
187 func (mt *mt_MT) WeekdaysWide() []string {
188 return mt.daysWide
189 }
190
191
192 func (mt *mt_MT) Decimal() string {
193 return mt.decimal
194 }
195
196
197 func (mt *mt_MT) Group() string {
198 return mt.group
199 }
200
201
202 func (mt *mt_MT) Minus() string {
203 return mt.minus
204 }
205
206
207 func (mt *mt_MT) FmtNumber(num float64, v uint64) string {
208
209 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
210 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
211 count := 0
212 inWhole := v == 0
213 b := make([]byte, 0, l)
214
215 for i := len(s) - 1; i >= 0; i-- {
216
217 if s[i] == '.' {
218 b = append(b, mt.decimal[0])
219 inWhole = true
220 continue
221 }
222
223 if inWhole {
224 if count == 3 {
225 b = append(b, mt.group[0])
226 count = 1
227 } else {
228 count++
229 }
230 }
231
232 b = append(b, s[i])
233 }
234
235 if num < 0 {
236 b = append(b, mt.minus[0])
237 }
238
239
240 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
241 b[i], b[j] = b[j], b[i]
242 }
243
244 return string(b)
245 }
246
247
248
249 func (mt *mt_MT) FmtPercent(num float64, v uint64) string {
250 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
251 l := len(s) + 3
252 b := make([]byte, 0, l)
253
254 for i := len(s) - 1; i >= 0; i-- {
255
256 if s[i] == '.' {
257 b = append(b, mt.decimal[0])
258 continue
259 }
260
261 b = append(b, s[i])
262 }
263
264 if num < 0 {
265 b = append(b, mt.minus[0])
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, mt.percent...)
274
275 return string(b)
276 }
277
278
279 func (mt *mt_MT) FmtCurrency(num float64, v uint64, currency currency.Type) string {
280
281 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
282 symbol := mt.currencies[currency]
283 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
284 count := 0
285 inWhole := v == 0
286 b := make([]byte, 0, l)
287
288 for i := len(s) - 1; i >= 0; i-- {
289
290 if s[i] == '.' {
291 b = append(b, mt.decimal[0])
292 inWhole = true
293 continue
294 }
295
296 if inWhole {
297 if count == 3 {
298 b = append(b, mt.group[0])
299 count = 1
300 } else {
301 count++
302 }
303 }
304
305 b = append(b, s[i])
306 }
307
308 for j := len(symbol) - 1; j >= 0; j-- {
309 b = append(b, symbol[j])
310 }
311
312 if num < 0 {
313 b = append(b, mt.minus[0])
314 }
315
316
317 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
318 b[i], b[j] = b[j], b[i]
319 }
320
321 if int(v) < 2 {
322
323 if v == 0 {
324 b = append(b, mt.decimal...)
325 }
326
327 for i := 0; i < 2-int(v); i++ {
328 b = append(b, '0')
329 }
330 }
331
332 return string(b)
333 }
334
335
336
337 func (mt *mt_MT) FmtAccounting(num float64, v uint64, currency currency.Type) string {
338
339 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
340 symbol := mt.currencies[currency]
341 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
342 count := 0
343 inWhole := v == 0
344 b := make([]byte, 0, l)
345
346 for i := len(s) - 1; i >= 0; i-- {
347
348 if s[i] == '.' {
349 b = append(b, mt.decimal[0])
350 inWhole = true
351 continue
352 }
353
354 if inWhole {
355 if count == 3 {
356 b = append(b, mt.group[0])
357 count = 1
358 } else {
359 count++
360 }
361 }
362
363 b = append(b, s[i])
364 }
365
366 if num < 0 {
367
368 for j := len(symbol) - 1; j >= 0; j-- {
369 b = append(b, symbol[j])
370 }
371
372 b = append(b, mt.minus[0])
373
374 } else {
375
376 for j := len(symbol) - 1; j >= 0; j-- {
377 b = append(b, symbol[j])
378 }
379
380 }
381
382
383 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
384 b[i], b[j] = b[j], b[i]
385 }
386
387 if int(v) < 2 {
388
389 if v == 0 {
390 b = append(b, mt.decimal...)
391 }
392
393 for i := 0; i < 2-int(v); i++ {
394 b = append(b, '0')
395 }
396 }
397
398 return string(b)
399 }
400
401
402 func (mt *mt_MT) FmtDateShort(t time.Time) string {
403
404 b := make([]byte, 0, 32)
405
406 if t.Day() < 10 {
407 b = append(b, '0')
408 }
409
410 b = strconv.AppendInt(b, int64(t.Day()), 10)
411 b = append(b, []byte{0x2f}...)
412
413 if t.Month() < 10 {
414 b = append(b, '0')
415 }
416
417 b = strconv.AppendInt(b, int64(t.Month()), 10)
418
419 b = append(b, []byte{0x2f}...)
420
421 if t.Year() > 0 {
422 b = strconv.AppendInt(b, int64(t.Year()), 10)
423 } else {
424 b = strconv.AppendInt(b, int64(-t.Year()), 10)
425 }
426
427 return string(b)
428 }
429
430
431 func (mt *mt_MT) FmtDateMedium(t time.Time) string {
432
433 b := make([]byte, 0, 32)
434
435 if t.Day() < 10 {
436 b = append(b, '0')
437 }
438
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x20}...)
441 b = append(b, mt.monthsAbbreviated[t.Month()]...)
442 b = append(b, []byte{0x20}...)
443
444 if t.Year() > 0 {
445 b = strconv.AppendInt(b, int64(t.Year()), 10)
446 } else {
447 b = strconv.AppendInt(b, int64(-t.Year()), 10)
448 }
449
450 return string(b)
451 }
452
453
454 func (mt *mt_MT) FmtDateLong(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 b = strconv.AppendInt(b, int64(t.Day()), 10)
459 b = append(b, []byte{0x20, 0x74, 0x61}...)
460 b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...)
461 b = append(b, mt.monthsWide[t.Month()]...)
462 b = append(b, []byte{0x20}...)
463
464 if t.Year() > 0 {
465 b = strconv.AppendInt(b, int64(t.Year()), 10)
466 } else {
467 b = strconv.AppendInt(b, int64(-t.Year()), 10)
468 }
469
470 return string(b)
471 }
472
473
474 func (mt *mt_MT) FmtDateFull(t time.Time) string {
475
476 b := make([]byte, 0, 32)
477
478 b = append(b, mt.daysWide[t.Weekday()]...)
479 b = append(b, []byte{0x2c, 0x20}...)
480 b = strconv.AppendInt(b, int64(t.Day()), 10)
481 b = append(b, []byte{0x20, 0x74, 0x61}...)
482 b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...)
483 b = append(b, mt.monthsWide[t.Month()]...)
484 b = append(b, []byte{0x20}...)
485
486 if t.Year() > 0 {
487 b = strconv.AppendInt(b, int64(t.Year()), 10)
488 } else {
489 b = strconv.AppendInt(b, int64(-t.Year()), 10)
490 }
491
492 return string(b)
493 }
494
495
496 func (mt *mt_MT) FmtTimeShort(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, mt.timeSeparator...)
506
507 if t.Minute() < 10 {
508 b = append(b, '0')
509 }
510
511 b = strconv.AppendInt(b, int64(t.Minute()), 10)
512
513 return string(b)
514 }
515
516
517 func (mt *mt_MT) FmtTimeMedium(t time.Time) string {
518
519 b := make([]byte, 0, 32)
520
521 if t.Hour() < 10 {
522 b = append(b, '0')
523 }
524
525 b = strconv.AppendInt(b, int64(t.Hour()), 10)
526 b = append(b, mt.timeSeparator...)
527
528 if t.Minute() < 10 {
529 b = append(b, '0')
530 }
531
532 b = strconv.AppendInt(b, int64(t.Minute()), 10)
533 b = append(b, mt.timeSeparator...)
534
535 if t.Second() < 10 {
536 b = append(b, '0')
537 }
538
539 b = strconv.AppendInt(b, int64(t.Second()), 10)
540
541 return string(b)
542 }
543
544
545 func (mt *mt_MT) FmtTimeLong(t time.Time) string {
546
547 b := make([]byte, 0, 32)
548
549 if t.Hour() < 10 {
550 b = append(b, '0')
551 }
552
553 b = strconv.AppendInt(b, int64(t.Hour()), 10)
554 b = append(b, mt.timeSeparator...)
555
556 if t.Minute() < 10 {
557 b = append(b, '0')
558 }
559
560 b = strconv.AppendInt(b, int64(t.Minute()), 10)
561 b = append(b, mt.timeSeparator...)
562
563 if t.Second() < 10 {
564 b = append(b, '0')
565 }
566
567 b = strconv.AppendInt(b, int64(t.Second()), 10)
568 b = append(b, []byte{0x20}...)
569
570 tz, _ := t.Zone()
571 b = append(b, tz...)
572
573 return string(b)
574 }
575
576
577 func (mt *mt_MT) FmtTimeFull(t time.Time) string {
578
579 b := make([]byte, 0, 32)
580
581 if t.Hour() < 10 {
582 b = append(b, '0')
583 }
584
585 b = strconv.AppendInt(b, int64(t.Hour()), 10)
586 b = append(b, mt.timeSeparator...)
587
588 if t.Minute() < 10 {
589 b = append(b, '0')
590 }
591
592 b = strconv.AppendInt(b, int64(t.Minute()), 10)
593 b = append(b, mt.timeSeparator...)
594
595 if t.Second() < 10 {
596 b = append(b, '0')
597 }
598
599 b = strconv.AppendInt(b, int64(t.Second()), 10)
600 b = append(b, []byte{0x20}...)
601
602 tz, _ := t.Zone()
603
604 if btz, ok := mt.timezones[tz]; ok {
605 b = append(b, btz...)
606 } else {
607 b = append(b, tz...)
608 }
609
610 return string(b)
611 }
612
View as plain text