1 package nd_ZW
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 nd_ZW 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 &nd_ZW{
47 locale: "nd_ZW",
48 pluralsCardinal: []locales.PluralRule{2, 6},
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 currencyNegativePrefix: "(",
54 currencyNegativeSuffix: ")",
55 monthsAbbreviated: []string{"", "Zib", "Nhlo", "Mbi", "Mab", "Nkw", "Nhla", "Ntu", "Ncw", "Mpan", "Mfu", "Lwe", "Mpal"},
56 monthsNarrow: []string{"", "Z", "N", "M", "M", "N", "N", "N", "N", "M", "M", "L", "M"},
57 monthsWide: []string{"", "Zibandlela", "Nhlolanja", "Mbimbitho", "Mabasa", "Nkwenkwezi", "Nhlangula", "Ntulikazi", "Ncwabakazi", "Mpandula", "Mfumfu", "Lwezi", "Mpalakazi"},
58 daysAbbreviated: []string{"Son", "Mvu", "Sib", "Sit", "Sin", "Sih", "Mgq"},
59 daysNarrow: []string{"S", "M", "S", "S", "S", "S", "M"},
60 daysWide: []string{"Sonto", "Mvulo", "Sibili", "Sithathu", "Sine", "Sihlanu", "Mgqibelo"},
61 erasAbbreviated: []string{"BC", "AD"},
62 erasNarrow: []string{"", ""},
63 erasWide: []string{"UKristo angakabuyi", "Ukristo ebuyile"},
64 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", "∅∅∅": "∅∅∅"},
65 }
66 }
67
68
69 func (nd *nd_ZW) Locale() string {
70 return nd.locale
71 }
72
73
74 func (nd *nd_ZW) PluralsCardinal() []locales.PluralRule {
75 return nd.pluralsCardinal
76 }
77
78
79 func (nd *nd_ZW) PluralsOrdinal() []locales.PluralRule {
80 return nd.pluralsOrdinal
81 }
82
83
84 func (nd *nd_ZW) PluralsRange() []locales.PluralRule {
85 return nd.pluralsRange
86 }
87
88
89 func (nd *nd_ZW) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
90
91 n := math.Abs(num)
92
93 if n == 1 {
94 return locales.PluralRuleOne
95 }
96
97 return locales.PluralRuleOther
98 }
99
100
101 func (nd *nd_ZW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
102 return locales.PluralRuleUnknown
103 }
104
105
106 func (nd *nd_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
107 return locales.PluralRuleUnknown
108 }
109
110
111 func (nd *nd_ZW) MonthAbbreviated(month time.Month) string {
112 return nd.monthsAbbreviated[month]
113 }
114
115
116 func (nd *nd_ZW) MonthsAbbreviated() []string {
117 return nd.monthsAbbreviated[1:]
118 }
119
120
121 func (nd *nd_ZW) MonthNarrow(month time.Month) string {
122 return nd.monthsNarrow[month]
123 }
124
125
126 func (nd *nd_ZW) MonthsNarrow() []string {
127 return nd.monthsNarrow[1:]
128 }
129
130
131 func (nd *nd_ZW) MonthWide(month time.Month) string {
132 return nd.monthsWide[month]
133 }
134
135
136 func (nd *nd_ZW) MonthsWide() []string {
137 return nd.monthsWide[1:]
138 }
139
140
141 func (nd *nd_ZW) WeekdayAbbreviated(weekday time.Weekday) string {
142 return nd.daysAbbreviated[weekday]
143 }
144
145
146 func (nd *nd_ZW) WeekdaysAbbreviated() []string {
147 return nd.daysAbbreviated
148 }
149
150
151 func (nd *nd_ZW) WeekdayNarrow(weekday time.Weekday) string {
152 return nd.daysNarrow[weekday]
153 }
154
155
156 func (nd *nd_ZW) WeekdaysNarrow() []string {
157 return nd.daysNarrow
158 }
159
160
161 func (nd *nd_ZW) WeekdayShort(weekday time.Weekday) string {
162 return nd.daysShort[weekday]
163 }
164
165
166 func (nd *nd_ZW) WeekdaysShort() []string {
167 return nd.daysShort
168 }
169
170
171 func (nd *nd_ZW) WeekdayWide(weekday time.Weekday) string {
172 return nd.daysWide[weekday]
173 }
174
175
176 func (nd *nd_ZW) WeekdaysWide() []string {
177 return nd.daysWide
178 }
179
180
181 func (nd *nd_ZW) Decimal() string {
182 return nd.decimal
183 }
184
185
186 func (nd *nd_ZW) Group() string {
187 return nd.group
188 }
189
190
191 func (nd *nd_ZW) Minus() string {
192 return nd.minus
193 }
194
195
196 func (nd *nd_ZW) FmtNumber(num float64, v uint64) string {
197
198 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
199 }
200
201
202
203 func (nd *nd_ZW) FmtPercent(num float64, v uint64) string {
204 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 }
206
207
208 func (nd *nd_ZW) FmtCurrency(num float64, v uint64, currency currency.Type) string {
209
210 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211 symbol := nd.currencies[currency]
212 l := len(s) + len(symbol) + 0
213 count := 0
214 inWhole := v == 0
215 b := make([]byte, 0, l)
216
217 for i := len(s) - 1; i >= 0; i-- {
218
219 if s[i] == '.' {
220 b = append(b, nd.decimal[0])
221 inWhole = true
222 continue
223 }
224
225 if inWhole {
226 if count == 3 {
227 b = append(b, nd.group[0])
228 count = 1
229 } else {
230 count++
231 }
232 }
233
234 b = append(b, s[i])
235 }
236
237 for j := len(symbol) - 1; j >= 0; j-- {
238 b = append(b, symbol[j])
239 }
240
241 if num < 0 {
242 b = append(b, nd.minus[0])
243 }
244
245
246 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
247 b[i], b[j] = b[j], b[i]
248 }
249
250 if int(v) < 2 {
251
252 if v == 0 {
253 b = append(b, nd.decimal...)
254 }
255
256 for i := 0; i < 2-int(v); i++ {
257 b = append(b, '0')
258 }
259 }
260
261 return string(b)
262 }
263
264
265
266 func (nd *nd_ZW) FmtAccounting(num float64, v uint64, currency currency.Type) string {
267
268 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 symbol := nd.currencies[currency]
270 l := len(s) + len(symbol) + 2
271 count := 0
272 inWhole := v == 0
273 b := make([]byte, 0, l)
274
275 for i := len(s) - 1; i >= 0; i-- {
276
277 if s[i] == '.' {
278 b = append(b, nd.decimal[0])
279 inWhole = true
280 continue
281 }
282
283 if inWhole {
284 if count == 3 {
285 b = append(b, nd.group[0])
286 count = 1
287 } else {
288 count++
289 }
290 }
291
292 b = append(b, s[i])
293 }
294
295 if num < 0 {
296
297 for j := len(symbol) - 1; j >= 0; j-- {
298 b = append(b, symbol[j])
299 }
300
301 b = append(b, nd.currencyNegativePrefix[0])
302
303 } else {
304
305 for j := len(symbol) - 1; j >= 0; j-- {
306 b = append(b, symbol[j])
307 }
308
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, nd.decimal...)
320 }
321
322 for i := 0; i < 2-int(v); i++ {
323 b = append(b, '0')
324 }
325 }
326
327 if num < 0 {
328 b = append(b, nd.currencyNegativeSuffix...)
329 }
330
331 return string(b)
332 }
333
334
335 func (nd *nd_ZW) FmtDateShort(t time.Time) string {
336
337 b := make([]byte, 0, 32)
338
339 if t.Day() < 10 {
340 b = append(b, '0')
341 }
342
343 b = strconv.AppendInt(b, int64(t.Day()), 10)
344 b = append(b, []byte{0x2f}...)
345
346 if t.Month() < 10 {
347 b = append(b, '0')
348 }
349
350 b = strconv.AppendInt(b, int64(t.Month()), 10)
351
352 b = append(b, []byte{0x2f}...)
353
354 if t.Year() > 0 {
355 b = strconv.AppendInt(b, int64(t.Year()), 10)
356 } else {
357 b = strconv.AppendInt(b, int64(-t.Year()), 10)
358 }
359
360 return string(b)
361 }
362
363
364 func (nd *nd_ZW) FmtDateMedium(t time.Time) string {
365
366 b := make([]byte, 0, 32)
367
368 b = strconv.AppendInt(b, int64(t.Day()), 10)
369 b = append(b, []byte{0x20}...)
370 b = append(b, nd.monthsAbbreviated[t.Month()]...)
371 b = append(b, []byte{0x20}...)
372
373 if t.Year() > 0 {
374 b = strconv.AppendInt(b, int64(t.Year()), 10)
375 } else {
376 b = strconv.AppendInt(b, int64(-t.Year()), 10)
377 }
378
379 return string(b)
380 }
381
382
383 func (nd *nd_ZW) FmtDateLong(t time.Time) string {
384
385 b := make([]byte, 0, 32)
386
387 b = strconv.AppendInt(b, int64(t.Day()), 10)
388 b = append(b, []byte{0x20}...)
389 b = append(b, nd.monthsWide[t.Month()]...)
390 b = append(b, []byte{0x20}...)
391
392 if t.Year() > 0 {
393 b = strconv.AppendInt(b, int64(t.Year()), 10)
394 } else {
395 b = strconv.AppendInt(b, int64(-t.Year()), 10)
396 }
397
398 return string(b)
399 }
400
401
402 func (nd *nd_ZW) FmtDateFull(t time.Time) string {
403
404 b := make([]byte, 0, 32)
405
406 b = append(b, nd.daysWide[t.Weekday()]...)
407 b = append(b, []byte{0x2c, 0x20}...)
408 b = strconv.AppendInt(b, int64(t.Day()), 10)
409 b = append(b, []byte{0x20}...)
410 b = append(b, nd.monthsWide[t.Month()]...)
411 b = append(b, []byte{0x20}...)
412
413 if t.Year() > 0 {
414 b = strconv.AppendInt(b, int64(t.Year()), 10)
415 } else {
416 b = strconv.AppendInt(b, int64(-t.Year()), 10)
417 }
418
419 return string(b)
420 }
421
422
423 func (nd *nd_ZW) FmtTimeShort(t time.Time) string {
424
425 b := make([]byte, 0, 32)
426
427 if t.Hour() < 10 {
428 b = append(b, '0')
429 }
430
431 b = strconv.AppendInt(b, int64(t.Hour()), 10)
432 b = append(b, nd.timeSeparator...)
433
434 if t.Minute() < 10 {
435 b = append(b, '0')
436 }
437
438 b = strconv.AppendInt(b, int64(t.Minute()), 10)
439
440 return string(b)
441 }
442
443
444 func (nd *nd_ZW) FmtTimeMedium(t time.Time) string {
445
446 b := make([]byte, 0, 32)
447
448 if t.Hour() < 10 {
449 b = append(b, '0')
450 }
451
452 b = strconv.AppendInt(b, int64(t.Hour()), 10)
453 b = append(b, nd.timeSeparator...)
454
455 if t.Minute() < 10 {
456 b = append(b, '0')
457 }
458
459 b = strconv.AppendInt(b, int64(t.Minute()), 10)
460 b = append(b, nd.timeSeparator...)
461
462 if t.Second() < 10 {
463 b = append(b, '0')
464 }
465
466 b = strconv.AppendInt(b, int64(t.Second()), 10)
467
468 return string(b)
469 }
470
471
472 func (nd *nd_ZW) FmtTimeLong(t time.Time) string {
473
474 b := make([]byte, 0, 32)
475
476 if t.Hour() < 10 {
477 b = append(b, '0')
478 }
479
480 b = strconv.AppendInt(b, int64(t.Hour()), 10)
481 b = append(b, nd.timeSeparator...)
482
483 if t.Minute() < 10 {
484 b = append(b, '0')
485 }
486
487 b = strconv.AppendInt(b, int64(t.Minute()), 10)
488 b = append(b, nd.timeSeparator...)
489
490 if t.Second() < 10 {
491 b = append(b, '0')
492 }
493
494 b = strconv.AppendInt(b, int64(t.Second()), 10)
495 b = append(b, []byte{0x20}...)
496
497 tz, _ := t.Zone()
498 b = append(b, tz...)
499
500 return string(b)
501 }
502
503
504 func (nd *nd_ZW) FmtTimeFull(t time.Time) string {
505
506 b := make([]byte, 0, 32)
507
508 if t.Hour() < 10 {
509 b = append(b, '0')
510 }
511
512 b = strconv.AppendInt(b, int64(t.Hour()), 10)
513 b = append(b, nd.timeSeparator...)
514
515 if t.Minute() < 10 {
516 b = append(b, '0')
517 }
518
519 b = strconv.AppendInt(b, int64(t.Minute()), 10)
520 b = append(b, nd.timeSeparator...)
521
522 if t.Second() < 10 {
523 b = append(b, '0')
524 }
525
526 b = strconv.AppendInt(b, int64(t.Second()), 10)
527 b = append(b, []byte{0x20}...)
528
529 tz, _ := t.Zone()
530
531 if btz, ok := nd.timezones[tz]; ok {
532 b = append(b, btz...)
533 } else {
534 b = append(b, tz...)
535 }
536
537 return string(b)
538 }
539
View as plain text