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