1 package en_ZA
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 en_ZA 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 currencyNegativePrefix string
26 currencyNegativeSuffix 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 &en_ZA{
47 locale: "en_ZA",
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6},
50 pluralsRange: []locales.PluralRule{6},
51 decimal: ",",
52 group: " ",
53 minus: "-",
54 percent: "%",
55 perMille: "‰",
56 timeSeparator: ":",
57 inifinity: "∞",
58 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", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59 currencyNegativePrefix: "(",
60 currencyNegativeSuffix: ")",
61 monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
62 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
63 monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
64 daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
65 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
66 daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
67 daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
68 periodsAbbreviated: []string{"am", "pm"},
69 periodsNarrow: []string{"", "pm"},
70 periodsWide: []string{"am", "pm"},
71 erasAbbreviated: []string{"BC", "AD"},
72 erasNarrow: []string{"B", "A"},
73 erasWide: []string{"Before Christ", "Anno Domini"},
74 timezones: map[string]string{"ACDT": "Australian Central Daylight Time", "ACST": "Australian Central Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "ADT": "Atlantic Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "AKDT": "Alaska Daylight Time", "AKST": "Alaska Standard Time", "ARST": "Argentina Summer Time", "ART": "Argentina Standard Time", "AST": "Atlantic Standard Time", "AWDT": "Australian Western Daylight Time", "AWST": "Australian Western Standard Time", "BOT": "Bolivia Time", "BT": "Bhutan Time", "CAT": "Central Africa Time", "CDT": "Central Daylight Time", "CHADT": "Chatham Daylight Time", "CHAST": "Chatham Standard Time", "CLST": "Chile Summer Time", "CLT": "Chile Standard Time", "COST": "Colombia Summer Time", "COT": "Colombia Standard Time", "CST": "Central Standard Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "ECT": "Ecuador Time", "EDT": "Eastern Daylight Time", "EST": "Eastern Standard Time", "GFT": "French Guiana Time", "GMT": "Greenwich Mean Time", "GST": "Gulf Standard Time", "GYT": "Guyana Time", "HADT": "Hawaii-Aleutian Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HAT": "Newfoundland Daylight Time", "HECU": "Cuba Daylight Time", "HEEG": "East Greenland Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEOG": "West Greenland Summer Time", "HEPM": "St Pierre & Miquelon Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HKST": "Hong Kong Summer Time", "HKT": "Hong Kong Standard Time", "HNCU": "Cuba Standard Time", "HNEG": "East Greenland Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNOG": "West Greenland Standard Time", "HNPM": "St Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HNT": "Newfoundland Standard Time", "IST": "India Standard Time", "JDT": "Japan Daylight Time", "JST": "Japan Standard Time", "LHDT": "Lord Howe Daylight Time", "LHST": "Lord Howe Standard Time", "MDT": "Mountain Daylight Time", "MESZ": "Central European Summer Time", "MEZ": "Central European Standard Time", "MST": "Mountain Standard Time", "MYT": "Malaysia Time", "NZDT": "New Zealand Daylight Time", "NZST": "New Zealand Standard Time", "OESZ": "Eastern European Summer Time", "OEZ": "Eastern European Standard Time", "PDT": "Pacific Daylight Time", "PST": "Pacific Standard Time", "SAST": "South Africa Standard Time", "SGT": "Singapore Standard Time", "SRT": "Suriname Time", "TMST": "Turkmenistan Summer Time", "TMT": "Turkmenistan Standard Time", "UYST": "Uruguay Summer Time", "UYT": "Uruguay Standard Time", "VET": "Venezuela Time", "WARST": "Western Argentina Summer Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "WAT": "West Africa Standard Time", "WESZ": "Western European Summer Time", "WEZ": "Western European Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "WITA": "Central Indonesia Time", "∅∅∅": "Brasilia Summer Time"},
75 }
76 }
77
78
79 func (en *en_ZA) Locale() string {
80 return en.locale
81 }
82
83
84 func (en *en_ZA) PluralsCardinal() []locales.PluralRule {
85 return en.pluralsCardinal
86 }
87
88
89 func (en *en_ZA) PluralsOrdinal() []locales.PluralRule {
90 return en.pluralsOrdinal
91 }
92
93
94 func (en *en_ZA) PluralsRange() []locales.PluralRule {
95 return en.pluralsRange
96 }
97
98
99 func (en *en_ZA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101 n := math.Abs(num)
102 i := int64(n)
103
104 if i == 1 && v == 0 {
105 return locales.PluralRuleOne
106 }
107
108 return locales.PluralRuleOther
109 }
110
111
112 func (en *en_ZA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113
114 n := math.Abs(num)
115 nMod10 := math.Mod(n, 10)
116 nMod100 := math.Mod(n, 100)
117
118 if nMod10 == 1 && nMod100 != 11 {
119 return locales.PluralRuleOne
120 } else if nMod10 == 2 && nMod100 != 12 {
121 return locales.PluralRuleTwo
122 } else if nMod10 == 3 && nMod100 != 13 {
123 return locales.PluralRuleFew
124 }
125
126 return locales.PluralRuleOther
127 }
128
129
130 func (en *en_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
131 return locales.PluralRuleOther
132 }
133
134
135 func (en *en_ZA) MonthAbbreviated(month time.Month) string {
136 return en.monthsAbbreviated[month]
137 }
138
139
140 func (en *en_ZA) MonthsAbbreviated() []string {
141 return en.monthsAbbreviated[1:]
142 }
143
144
145 func (en *en_ZA) MonthNarrow(month time.Month) string {
146 return en.monthsNarrow[month]
147 }
148
149
150 func (en *en_ZA) MonthsNarrow() []string {
151 return en.monthsNarrow[1:]
152 }
153
154
155 func (en *en_ZA) MonthWide(month time.Month) string {
156 return en.monthsWide[month]
157 }
158
159
160 func (en *en_ZA) MonthsWide() []string {
161 return en.monthsWide[1:]
162 }
163
164
165 func (en *en_ZA) WeekdayAbbreviated(weekday time.Weekday) string {
166 return en.daysAbbreviated[weekday]
167 }
168
169
170 func (en *en_ZA) WeekdaysAbbreviated() []string {
171 return en.daysAbbreviated
172 }
173
174
175 func (en *en_ZA) WeekdayNarrow(weekday time.Weekday) string {
176 return en.daysNarrow[weekday]
177 }
178
179
180 func (en *en_ZA) WeekdaysNarrow() []string {
181 return en.daysNarrow
182 }
183
184
185 func (en *en_ZA) WeekdayShort(weekday time.Weekday) string {
186 return en.daysShort[weekday]
187 }
188
189
190 func (en *en_ZA) WeekdaysShort() []string {
191 return en.daysShort
192 }
193
194
195 func (en *en_ZA) WeekdayWide(weekday time.Weekday) string {
196 return en.daysWide[weekday]
197 }
198
199
200 func (en *en_ZA) WeekdaysWide() []string {
201 return en.daysWide
202 }
203
204
205 func (en *en_ZA) Decimal() string {
206 return en.decimal
207 }
208
209
210 func (en *en_ZA) Group() string {
211 return en.group
212 }
213
214
215 func (en *en_ZA) Minus() string {
216 return en.minus
217 }
218
219
220 func (en *en_ZA) FmtNumber(num float64, v uint64) string {
221
222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
223 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
224 count := 0
225 inWhole := v == 0
226 b := make([]byte, 0, l)
227
228 for i := len(s) - 1; i >= 0; i-- {
229
230 if s[i] == '.' {
231 b = append(b, en.decimal[0])
232 inWhole = true
233 continue
234 }
235
236 if inWhole {
237 if count == 3 {
238 for j := len(en.group) - 1; j >= 0; j-- {
239 b = append(b, en.group[j])
240 }
241 count = 1
242 } else {
243 count++
244 }
245 }
246
247 b = append(b, s[i])
248 }
249
250 if num < 0 {
251 b = append(b, en.minus[0])
252 }
253
254
255 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
256 b[i], b[j] = b[j], b[i]
257 }
258
259 return string(b)
260 }
261
262
263
264 func (en *en_ZA) FmtPercent(num float64, v uint64) string {
265 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
266 l := len(s) + 3
267 b := make([]byte, 0, l)
268
269 for i := len(s) - 1; i >= 0; i-- {
270
271 if s[i] == '.' {
272 b = append(b, en.decimal[0])
273 continue
274 }
275
276 b = append(b, s[i])
277 }
278
279 if num < 0 {
280 b = append(b, en.minus[0])
281 }
282
283
284 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
285 b[i], b[j] = b[j], b[i]
286 }
287
288 b = append(b, en.percent...)
289
290 return string(b)
291 }
292
293
294 func (en *en_ZA) FmtCurrency(num float64, v uint64, currency currency.Type) string {
295
296 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
297 symbol := en.currencies[currency]
298 l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3
299 count := 0
300 inWhole := v == 0
301 b := make([]byte, 0, l)
302
303 for i := len(s) - 1; i >= 0; i-- {
304
305 if s[i] == '.' {
306 b = append(b, en.decimal[0])
307 inWhole = true
308 continue
309 }
310
311 if inWhole {
312 if count == 3 {
313 for j := len(en.group) - 1; j >= 0; j-- {
314 b = append(b, en.group[j])
315 }
316 count = 1
317 } else {
318 count++
319 }
320 }
321
322 b = append(b, s[i])
323 }
324
325 for j := len(symbol) - 1; j >= 0; j-- {
326 b = append(b, symbol[j])
327 }
328
329 if num < 0 {
330 b = append(b, en.minus[0])
331 }
332
333
334 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
335 b[i], b[j] = b[j], b[i]
336 }
337
338 if int(v) < 2 {
339
340 if v == 0 {
341 b = append(b, en.decimal...)
342 }
343
344 for i := 0; i < 2-int(v); i++ {
345 b = append(b, '0')
346 }
347 }
348
349 return string(b)
350 }
351
352
353
354 func (en *en_ZA) FmtAccounting(num float64, v uint64, currency currency.Type) string {
355
356 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
357 symbol := en.currencies[currency]
358 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
359 count := 0
360 inWhole := v == 0
361 b := make([]byte, 0, l)
362
363 for i := len(s) - 1; i >= 0; i-- {
364
365 if s[i] == '.' {
366 b = append(b, en.decimal[0])
367 inWhole = true
368 continue
369 }
370
371 if inWhole {
372 if count == 3 {
373 for j := len(en.group) - 1; j >= 0; j-- {
374 b = append(b, en.group[j])
375 }
376 count = 1
377 } else {
378 count++
379 }
380 }
381
382 b = append(b, s[i])
383 }
384
385 if num < 0 {
386
387 for j := len(symbol) - 1; j >= 0; j-- {
388 b = append(b, symbol[j])
389 }
390
391 b = append(b, en.currencyNegativePrefix[0])
392
393 } else {
394
395 for j := len(symbol) - 1; j >= 0; j-- {
396 b = append(b, symbol[j])
397 }
398
399 }
400
401
402 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
403 b[i], b[j] = b[j], b[i]
404 }
405
406 if int(v) < 2 {
407
408 if v == 0 {
409 b = append(b, en.decimal...)
410 }
411
412 for i := 0; i < 2-int(v); i++ {
413 b = append(b, '0')
414 }
415 }
416
417 if num < 0 {
418 b = append(b, en.currencyNegativeSuffix...)
419 }
420
421 return string(b)
422 }
423
424
425 func (en *en_ZA) FmtDateShort(t time.Time) string {
426
427 b := make([]byte, 0, 32)
428
429 if t.Year() > 0 {
430 b = strconv.AppendInt(b, int64(t.Year()), 10)
431 } else {
432 b = strconv.AppendInt(b, int64(-t.Year()), 10)
433 }
434
435 b = append(b, []byte{0x2f}...)
436
437 if t.Month() < 10 {
438 b = append(b, '0')
439 }
440
441 b = strconv.AppendInt(b, int64(t.Month()), 10)
442
443 b = append(b, []byte{0x2f}...)
444
445 if t.Day() < 10 {
446 b = append(b, '0')
447 }
448
449 b = strconv.AppendInt(b, int64(t.Day()), 10)
450
451 return string(b)
452 }
453
454
455 func (en *en_ZA) FmtDateMedium(t time.Time) string {
456
457 b := make([]byte, 0, 32)
458
459 if t.Day() < 10 {
460 b = append(b, '0')
461 }
462
463 b = strconv.AppendInt(b, int64(t.Day()), 10)
464 b = append(b, []byte{0x20}...)
465 b = append(b, en.monthsAbbreviated[t.Month()]...)
466 b = append(b, []byte{0x20}...)
467
468 if t.Year() > 0 {
469 b = strconv.AppendInt(b, int64(t.Year()), 10)
470 } else {
471 b = strconv.AppendInt(b, int64(-t.Year()), 10)
472 }
473
474 return string(b)
475 }
476
477
478 func (en *en_ZA) FmtDateLong(t time.Time) string {
479
480 b := make([]byte, 0, 32)
481
482 if t.Day() < 10 {
483 b = append(b, '0')
484 }
485
486 b = strconv.AppendInt(b, int64(t.Day()), 10)
487 b = append(b, []byte{0x20}...)
488 b = append(b, en.monthsWide[t.Month()]...)
489 b = append(b, []byte{0x20}...)
490
491 if t.Year() > 0 {
492 b = strconv.AppendInt(b, int64(t.Year()), 10)
493 } else {
494 b = strconv.AppendInt(b, int64(-t.Year()), 10)
495 }
496
497 return string(b)
498 }
499
500
501 func (en *en_ZA) FmtDateFull(t time.Time) string {
502
503 b := make([]byte, 0, 32)
504
505 b = append(b, en.daysWide[t.Weekday()]...)
506 b = append(b, []byte{0x2c, 0x20}...)
507
508 if t.Day() < 10 {
509 b = append(b, '0')
510 }
511
512 b = strconv.AppendInt(b, int64(t.Day()), 10)
513 b = append(b, []byte{0x20}...)
514 b = append(b, en.monthsWide[t.Month()]...)
515 b = append(b, []byte{0x20}...)
516
517 if t.Year() > 0 {
518 b = strconv.AppendInt(b, int64(t.Year()), 10)
519 } else {
520 b = strconv.AppendInt(b, int64(-t.Year()), 10)
521 }
522
523 return string(b)
524 }
525
526
527 func (en *en_ZA) FmtTimeShort(t time.Time) string {
528
529 b := make([]byte, 0, 32)
530
531 if t.Hour() < 10 {
532 b = append(b, '0')
533 }
534
535 b = strconv.AppendInt(b, int64(t.Hour()), 10)
536 b = append(b, en.timeSeparator...)
537
538 if t.Minute() < 10 {
539 b = append(b, '0')
540 }
541
542 b = strconv.AppendInt(b, int64(t.Minute()), 10)
543
544 return string(b)
545 }
546
547
548 func (en *en_ZA) FmtTimeMedium(t time.Time) string {
549
550 b := make([]byte, 0, 32)
551
552 if t.Hour() < 10 {
553 b = append(b, '0')
554 }
555
556 b = strconv.AppendInt(b, int64(t.Hour()), 10)
557 b = append(b, en.timeSeparator...)
558
559 if t.Minute() < 10 {
560 b = append(b, '0')
561 }
562
563 b = strconv.AppendInt(b, int64(t.Minute()), 10)
564 b = append(b, en.timeSeparator...)
565
566 if t.Second() < 10 {
567 b = append(b, '0')
568 }
569
570 b = strconv.AppendInt(b, int64(t.Second()), 10)
571
572 return string(b)
573 }
574
575
576 func (en *en_ZA) FmtTimeLong(t time.Time) string {
577
578 b := make([]byte, 0, 32)
579
580 if t.Hour() < 10 {
581 b = append(b, '0')
582 }
583
584 b = strconv.AppendInt(b, int64(t.Hour()), 10)
585 b = append(b, en.timeSeparator...)
586
587 if t.Minute() < 10 {
588 b = append(b, '0')
589 }
590
591 b = strconv.AppendInt(b, int64(t.Minute()), 10)
592 b = append(b, en.timeSeparator...)
593
594 if t.Second() < 10 {
595 b = append(b, '0')
596 }
597
598 b = strconv.AppendInt(b, int64(t.Second()), 10)
599 b = append(b, []byte{0x20}...)
600
601 tz, _ := t.Zone()
602 b = append(b, tz...)
603
604 return string(b)
605 }
606
607
608 func (en *en_ZA) FmtTimeFull(t time.Time) string {
609
610 b := make([]byte, 0, 32)
611
612 if t.Hour() < 10 {
613 b = append(b, '0')
614 }
615
616 b = strconv.AppendInt(b, int64(t.Hour()), 10)
617 b = append(b, en.timeSeparator...)
618
619 if t.Minute() < 10 {
620 b = append(b, '0')
621 }
622
623 b = strconv.AppendInt(b, int64(t.Minute()), 10)
624 b = append(b, en.timeSeparator...)
625
626 if t.Second() < 10 {
627 b = append(b, '0')
628 }
629
630 b = strconv.AppendInt(b, int64(t.Second()), 10)
631 b = append(b, []byte{0x20}...)
632
633 tz, _ := t.Zone()
634
635 if btz, ok := en.timezones[tz]; ok {
636 b = append(b, btz...)
637 } else {
638 b = append(b, tz...)
639 }
640
641 return string(b)
642 }
643
View as plain text