8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
24 currencies []string // idx = enum of currency code
25 currencyNegativePrefix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'en_NZ' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6},
50 pluralsRange: []locales.PluralRule{6},
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", "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", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "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", "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", "UZS", "VEB", "VEF", "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"},
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{"a", "p"},
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{"HEPMX": "Mexican Pacific Daylight Time", "LHDT": "Lord Howe Daylight Time", "HNT": "Newfoundland Standard Time", "∅∅∅": "Peru Summer Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "UYST": "Uruguay Summer Time", "WAST": "West Africa Summer Time", "GFT": "French Guiana Time", "COST": "Colombia Summer Time", "ECT": "Ecuador Time", "EAT": "East Africa Time", "GMT": "Greenwich Mean Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MYT": "Malaysia Time", "NZST": "New Zealand Standard Time", "LHST": "Lord Howe Standard Time", "NZDT": "New Zealand Daylight Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "HNEG": "East Greenland Standard Time", "EST": "Eastern Standard Time", "CHAST": "Chatham Standard Time", "AWST": "Australian Western Standard Time", "AST": "Atlantic Standard Time", "ARST": "Argentina Summer Time", "HNOG": "West Greenland Standard Time", "WAT": "West Africa Standard Time", "HAT": "Newfoundland Daylight Time", "COT": "Colombia Standard Time", "ACST": "Australian Central Standard Time", "WEZ": "Western European Standard Time", "SGT": "Singapore Standard Time", "PDT": "Pacific Daylight Time", "WARST": "Western Argentina Summer Time", "EDT": "Eastern Daylight Time", "GYT": "Guyana Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "ART": "Argentina Standard Time", "HNPMX": "Mexican Pacific Standard Time", "MDT": "Macau Summer Time", "ACWDT": "Australian Central Western Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "OEZ": "Eastern European Standard Time", "AEDT": "Australian Eastern Daylight Time", "ChST": "Chamorro Standard Time", "WIB": "Western Indonesia Time", "PST": "Pacific Standard Time", "SRT": "Suriname Time", "UYT": "Uruguay Standard Time", "WITA": "Central Indonesia Time", "IST": "India Standard Time", "HEOG": "West Greenland Summer Time", "ACWST": "Australian Central Western Standard Time", "WIT": "Eastern Indonesia Time", "MESZ": "Central European Summer Time", "OESZ": "Eastern European Summer Time", "BOT": "Bolivia Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "CHADT": "Chatham Daylight Time", "BT": "Bhutan Time", "HADT": "Hawaii-Aleutian Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "HKST": "Hong Kong Summer Time", "CAT": "Central Africa Time", "CDT": "Central Daylight Time", "MST": "Macau Standard Time", "MEZ": "Central European Standard Time", "HEEG": "East Greenland Summer Time", "HKT": "Hong Kong Standard Time", "CLT": "Chile Standard Time", "AKST": "Alaska Standard Time", "WESZ": "Western European Summer Time", "CST": "Central Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "AWDT": "Australian Western Daylight Time", "JST": "Japan Standard Time", "ADT": "Atlantic Daylight Time", "ACDT": "Australian Central Daylight Time"},
78 // Locale returns the current translators string locale
79 func (en *en_NZ) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'en_NZ'
84 func (en *en_NZ) PluralsCardinal() []locales.PluralRule {
85 return en.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NZ'
89 func (en *en_NZ) PluralsOrdinal() []locales.PluralRule {
90 return en.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'en_NZ'
94 func (en *en_NZ) PluralsRange() []locales.PluralRule {
95 return en.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NZ'
99 func (en *en_NZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
104 if i == 1 && v == 0 {
105 return locales.PluralRuleOne
108 return locales.PluralRuleOther
111 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NZ'
112 func (en *en_NZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
115 nMod10 := math.Mod(n, 10)
116 nMod100 := math.Mod(n, 100)
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
126 return locales.PluralRuleOther
129 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NZ'
130 func (en *en_NZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
131 return locales.PluralRuleOther
134 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
135 func (en *en_NZ) MonthAbbreviated(month time.Month) string {
136 return en.monthsAbbreviated[month]
139 // MonthsAbbreviated returns the locales abbreviated months
140 func (en *en_NZ) MonthsAbbreviated() []string {
141 return en.monthsAbbreviated[1:]
144 // MonthNarrow returns the locales narrow month given the 'month' provided
145 func (en *en_NZ) MonthNarrow(month time.Month) string {
146 return en.monthsNarrow[month]
149 // MonthsNarrow returns the locales narrow months
150 func (en *en_NZ) MonthsNarrow() []string {
151 return en.monthsNarrow[1:]
154 // MonthWide returns the locales wide month given the 'month' provided
155 func (en *en_NZ) MonthWide(month time.Month) string {
156 return en.monthsWide[month]
159 // MonthsWide returns the locales wide months
160 func (en *en_NZ) MonthsWide() []string {
161 return en.monthsWide[1:]
164 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
165 func (en *en_NZ) WeekdayAbbreviated(weekday time.Weekday) string {
166 return en.daysAbbreviated[weekday]
169 // WeekdaysAbbreviated returns the locales abbreviated weekdays
170 func (en *en_NZ) WeekdaysAbbreviated() []string {
171 return en.daysAbbreviated
174 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
175 func (en *en_NZ) WeekdayNarrow(weekday time.Weekday) string {
176 return en.daysNarrow[weekday]
179 // WeekdaysNarrow returns the locales narrow weekdays
180 func (en *en_NZ) WeekdaysNarrow() []string {
184 // WeekdayShort returns the locales short weekday given the 'weekday' provided
185 func (en *en_NZ) WeekdayShort(weekday time.Weekday) string {
186 return en.daysShort[weekday]
189 // WeekdaysShort returns the locales short weekdays
190 func (en *en_NZ) WeekdaysShort() []string {
194 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
195 func (en *en_NZ) WeekdayWide(weekday time.Weekday) string {
196 return en.daysWide[weekday]
199 // WeekdaysWide returns the locales wide weekdays
200 func (en *en_NZ) WeekdaysWide() []string {
204 // Decimal returns the decimal point of number
205 func (en *en_NZ) Decimal() string {
209 // Group returns the group of number
210 func (en *en_NZ) Group() string {
214 // Group returns the minus sign of number
215 func (en *en_NZ) Minus() string {
219 // FmtNumber returns 'num' with digits/precision of 'v' for 'en_NZ' and handles both Whole and Real numbers based on 'v'
220 func (en *en_NZ) FmtNumber(num float64, v uint64) string {
222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
223 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
226 b := make([]byte, 0, l)
228 for i := len(s) - 1; i >= 0; i-- {
231 b = append(b, en.decimal[0])
238 b = append(b, en.group[0])
249 b = append(b, en.minus[0])
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]
260 // FmtPercent returns 'num' with digits/precision of 'v' for 'en_NZ' and handles both Whole and Real numbers based on 'v'
261 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
262 func (en *en_NZ) FmtPercent(num float64, v uint64) string {
263 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 b := make([]byte, 0, l)
267 for i := len(s) - 1; i >= 0; i-- {
270 b = append(b, en.decimal[0])
278 b = append(b, en.minus[0])
282 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
283 b[i], b[j] = b[j], b[i]
286 b = append(b, en.percent...)
291 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NZ'
292 func (en *en_NZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
294 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
295 symbol := en.currencies[currency]
296 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
299 b := make([]byte, 0, l)
301 for i := len(s) - 1; i >= 0; i-- {
304 b = append(b, en.decimal[0])
311 b = append(b, en.group[0])
321 for j := len(symbol) - 1; j >= 0; j-- {
322 b = append(b, symbol[j])
326 b = append(b, en.minus[0])
330 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
331 b[i], b[j] = b[j], b[i]
337 b = append(b, en.decimal...)
340 for i := 0; i < 2-int(v); i++ {
348 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NZ'
349 // in accounting notation.
350 func (en *en_NZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
352 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
353 symbol := en.currencies[currency]
354 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
357 b := make([]byte, 0, l)
359 for i := len(s) - 1; i >= 0; i-- {
362 b = append(b, en.decimal[0])
369 b = append(b, en.group[0])
381 for j := len(symbol) - 1; j >= 0; j-- {
382 b = append(b, symbol[j])
385 b = append(b, en.currencyNegativePrefix[0])
389 for j := len(symbol) - 1; j >= 0; j-- {
390 b = append(b, symbol[j])
396 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
397 b[i], b[j] = b[j], b[i]
403 b = append(b, en.decimal...)
406 for i := 0; i < 2-int(v); i++ {
412 b = append(b, en.currencyNegativeSuffix...)
418 // FmtDateShort returns the short date representation of 't' for 'en_NZ'
419 func (en *en_NZ) FmtDateShort(t time.Time) string {
421 b := make([]byte, 0, 32)
423 b = strconv.AppendInt(b, int64(t.Day()), 10)
424 b = append(b, []byte{0x2f}...)
430 b = strconv.AppendInt(b, int64(t.Month()), 10)
432 b = append(b, []byte{0x2f}...)
435 b = append(b, strconv.Itoa(t.Year())[2:]...)
437 b = append(b, strconv.Itoa(t.Year())[1:]...)
443 // FmtDateMedium returns the medium date representation of 't' for 'en_NZ'
444 func (en *en_NZ) FmtDateMedium(t time.Time) string {
446 b := make([]byte, 0, 32)
448 b = strconv.AppendInt(b, int64(t.Day()), 10)
449 b = append(b, []byte{0x2f}...)
455 b = strconv.AppendInt(b, int64(t.Month()), 10)
457 b = append(b, []byte{0x2f}...)
460 b = strconv.AppendInt(b, int64(t.Year()), 10)
462 b = strconv.AppendInt(b, int64(-t.Year()), 10)
468 // FmtDateLong returns the long date representation of 't' for 'en_NZ'
469 func (en *en_NZ) FmtDateLong(t time.Time) string {
471 b := make([]byte, 0, 32)
473 b = strconv.AppendInt(b, int64(t.Day()), 10)
474 b = append(b, []byte{0x20}...)
475 b = append(b, en.monthsWide[t.Month()]...)
476 b = append(b, []byte{0x20}...)
479 b = strconv.AppendInt(b, int64(t.Year()), 10)
481 b = strconv.AppendInt(b, int64(-t.Year()), 10)
487 // FmtDateFull returns the full date representation of 't' for 'en_NZ'
488 func (en *en_NZ) FmtDateFull(t time.Time) string {
490 b := make([]byte, 0, 32)
492 b = append(b, en.daysWide[t.Weekday()]...)
493 b = append(b, []byte{0x2c, 0x20}...)
494 b = strconv.AppendInt(b, int64(t.Day()), 10)
495 b = append(b, []byte{0x20}...)
496 b = append(b, en.monthsWide[t.Month()]...)
497 b = append(b, []byte{0x20}...)
500 b = strconv.AppendInt(b, int64(t.Year()), 10)
502 b = strconv.AppendInt(b, int64(-t.Year()), 10)
508 // FmtTimeShort returns the short time representation of 't' for 'en_NZ'
509 func (en *en_NZ) FmtTimeShort(t time.Time) string {
511 b := make([]byte, 0, 32)
517 b = strconv.AppendInt(b, int64(t.Hour()), 10)
518 b = append(b, en.timeSeparator...)
524 b = strconv.AppendInt(b, int64(t.Minute()), 10)
529 // FmtTimeMedium returns the medium time representation of 't' for 'en_NZ'
530 func (en *en_NZ) FmtTimeMedium(t time.Time) string {
532 b := make([]byte, 0, 32)
538 b = strconv.AppendInt(b, int64(t.Hour()), 10)
539 b = append(b, en.timeSeparator...)
545 b = strconv.AppendInt(b, int64(t.Minute()), 10)
546 b = append(b, en.timeSeparator...)
552 b = strconv.AppendInt(b, int64(t.Second()), 10)
557 // FmtTimeLong returns the long time representation of 't' for 'en_NZ'
558 func (en *en_NZ) FmtTimeLong(t time.Time) string {
560 b := make([]byte, 0, 32)
566 b = strconv.AppendInt(b, int64(t.Hour()), 10)
567 b = append(b, en.timeSeparator...)
573 b = strconv.AppendInt(b, int64(t.Minute()), 10)
574 b = append(b, en.timeSeparator...)
580 b = strconv.AppendInt(b, int64(t.Second()), 10)
581 b = append(b, []byte{0x20}...)
589 // FmtTimeFull returns the full time representation of 't' for 'en_NZ'
590 func (en *en_NZ) FmtTimeFull(t time.Time) string {
592 b := make([]byte, 0, 32)
598 b = strconv.AppendInt(b, int64(t.Hour()), 10)
599 b = append(b, en.timeSeparator...)
605 b = strconv.AppendInt(b, int64(t.Minute()), 10)
606 b = append(b, en.timeSeparator...)
612 b = strconv.AppendInt(b, int64(t.Second()), 10)
613 b = append(b, []byte{0x20}...)
617 if btz, ok := en.timezones[tz]; ok {
618 b = append(b, btz...)