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 currencyPositiveSuffix 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 'asa_TZ' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
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", "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", "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", "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"},
53 currencyPositiveSuffix: " ",
54 currencyNegativeSuffix: " ",
55 monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Dec"},
56 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
57 monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"},
58 daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Ijm", "Jmo"},
59 daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"},
60 daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"},
61 periodsAbbreviated: []string{"icheheavo", "ichamthi"},
62 periodsWide: []string{"icheheavo", "ichamthi"},
63 erasAbbreviated: []string{"KM", "BM"},
64 erasNarrow: []string{"", ""},
65 erasWide: []string{"Kabla yakwe Yethu", "Baada yakwe Yethu"},
66 timezones: map[string]string{"HKT": "HKT", "CLT": "CLT", "HEPMX": "HEPMX", "HNPM": "HNPM", "AWST": "AWST", "SRT": "SRT", "ACWDT": "ACWDT", "WAST": "WAST", "MDT": "MDT", "WART": "WART", "HNOG": "HNOG", "GFT": "GFT", "AKDT": "AKDT", "CAT": "CAT", "WEZ": "WEZ", "CHAST": "CHAST", "HEPM": "HEPM", "AKST": "AKST", "ChST": "ChST", "OESZ": "OESZ", "LHDT": "LHDT", "IST": "IST", "HEOG": "HEOG", "CLST": "CLST", "ACDT": "ACDT", "WESZ": "WESZ", "HAST": "HAST", "AEST": "AEST", "HAT": "HAT", "COST": "COST", "ACST": "ACST", "PDT": "PDT", "CHADT": "CHADT", "MST": "MST", "TMT": "TMT", "BT": "BT", "AWDT": "AWDT", "JDT": "JDT", "ADT": "ADT", "OEZ": "OEZ", "AST": "AST", "∅∅∅": "∅∅∅", "HNPMX": "HNPMX", "BOT": "BOT", "CST": "CST", "ACWST": "ACWST", "TMST": "TMST", "EAT": "EAT", "COT": "COT", "WIT": "WIT", "HADT": "HADT", "WARST": "WARST", "WAT": "WAT", "HNEG": "HNEG", "GMT": "GMT", "WIB": "WIB", "NZST": "NZST", "ARST": "ARST", "MEZ": "MEZ", "LHST": "LHST", "HKST": "HKST", "EST": "EST", "ECT": "ECT", "CDT": "CDT", "NZDT": "NZDT", "AEDT": "AEDT", "SAST": "SAST", "EDT": "EDT", "SGT": "SGT", "PST": "PST", "UYT": "UYT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HNT": "HNT", "HNCU": "HNCU", "JST": "JST", "GYT": "GYT", "VET": "VET", "WITA": "WITA", "ART": "ART", "HECU": "HECU", "MYT": "MYT", "UYST": "UYST", "MESZ": "MESZ", "HEEG": "HEEG"},
70 // Locale returns the current translators string locale
71 func (asa *asa_TZ) Locale() string {
75 // PluralsCardinal returns the list of cardinal plural rules associated with 'asa_TZ'
76 func (asa *asa_TZ) PluralsCardinal() []locales.PluralRule {
77 return asa.pluralsCardinal
80 // PluralsOrdinal returns the list of ordinal plural rules associated with 'asa_TZ'
81 func (asa *asa_TZ) PluralsOrdinal() []locales.PluralRule {
82 return asa.pluralsOrdinal
85 // PluralsRange returns the list of range plural rules associated with 'asa_TZ'
86 func (asa *asa_TZ) PluralsRange() []locales.PluralRule {
87 return asa.pluralsRange
90 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'asa_TZ'
91 func (asa *asa_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96 return locales.PluralRuleOne
99 return locales.PluralRuleOther
102 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'asa_TZ'
103 func (asa *asa_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
104 return locales.PluralRuleUnknown
107 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'asa_TZ'
108 func (asa *asa_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
109 return locales.PluralRuleUnknown
112 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
113 func (asa *asa_TZ) MonthAbbreviated(month time.Month) string {
114 return asa.monthsAbbreviated[month]
117 // MonthsAbbreviated returns the locales abbreviated months
118 func (asa *asa_TZ) MonthsAbbreviated() []string {
119 return asa.monthsAbbreviated[1:]
122 // MonthNarrow returns the locales narrow month given the 'month' provided
123 func (asa *asa_TZ) MonthNarrow(month time.Month) string {
124 return asa.monthsNarrow[month]
127 // MonthsNarrow returns the locales narrow months
128 func (asa *asa_TZ) MonthsNarrow() []string {
129 return asa.monthsNarrow[1:]
132 // MonthWide returns the locales wide month given the 'month' provided
133 func (asa *asa_TZ) MonthWide(month time.Month) string {
134 return asa.monthsWide[month]
137 // MonthsWide returns the locales wide months
138 func (asa *asa_TZ) MonthsWide() []string {
139 return asa.monthsWide[1:]
142 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
143 func (asa *asa_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
144 return asa.daysAbbreviated[weekday]
147 // WeekdaysAbbreviated returns the locales abbreviated weekdays
148 func (asa *asa_TZ) WeekdaysAbbreviated() []string {
149 return asa.daysAbbreviated
152 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
153 func (asa *asa_TZ) WeekdayNarrow(weekday time.Weekday) string {
154 return asa.daysNarrow[weekday]
157 // WeekdaysNarrow returns the locales narrow weekdays
158 func (asa *asa_TZ) WeekdaysNarrow() []string {
159 return asa.daysNarrow
162 // WeekdayShort returns the locales short weekday given the 'weekday' provided
163 func (asa *asa_TZ) WeekdayShort(weekday time.Weekday) string {
164 return asa.daysShort[weekday]
167 // WeekdaysShort returns the locales short weekdays
168 func (asa *asa_TZ) WeekdaysShort() []string {
172 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
173 func (asa *asa_TZ) WeekdayWide(weekday time.Weekday) string {
174 return asa.daysWide[weekday]
177 // WeekdaysWide returns the locales wide weekdays
178 func (asa *asa_TZ) WeekdaysWide() []string {
182 // Decimal returns the decimal point of number
183 func (asa *asa_TZ) Decimal() string {
187 // Group returns the group of number
188 func (asa *asa_TZ) Group() string {
192 // Group returns the minus sign of number
193 func (asa *asa_TZ) Minus() string {
197 // FmtNumber returns 'num' with digits/precision of 'v' for 'asa_TZ' and handles both Whole and Real numbers based on 'v'
198 func (asa *asa_TZ) FmtNumber(num float64, v uint64) string {
200 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
203 // FmtPercent returns 'num' with digits/precision of 'v' for 'asa_TZ' and handles both Whole and Real numbers based on 'v'
204 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
205 func (asa *asa_TZ) FmtPercent(num float64, v uint64) string {
206 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'asa_TZ'
210 func (asa *asa_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
212 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
213 symbol := asa.currencies[currency]
214 l := len(s) + len(symbol) + 2
217 b := make([]byte, 0, l)
219 for i := len(s) - 1; i >= 0; i-- {
222 b = append(b, asa.decimal[0])
229 b = append(b, asa.group[0])
240 b = append(b, asa.minus[0])
244 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
245 b[i], b[j] = b[j], b[i]
251 b = append(b, asa.decimal...)
254 for i := 0; i < 2-int(v); i++ {
259 b = append(b, asa.currencyPositiveSuffix...)
261 b = append(b, symbol...)
266 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'asa_TZ'
267 // in accounting notation.
268 func (asa *asa_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
270 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
271 symbol := asa.currencies[currency]
272 l := len(s) + len(symbol) + 2
275 b := make([]byte, 0, l)
277 for i := len(s) - 1; i >= 0; i-- {
280 b = append(b, asa.decimal[0])
287 b = append(b, asa.group[0])
299 b = append(b, asa.minus[0])
304 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
305 b[i], b[j] = b[j], b[i]
311 b = append(b, asa.decimal...)
314 for i := 0; i < 2-int(v); i++ {
320 b = append(b, asa.currencyNegativeSuffix...)
321 b = append(b, symbol...)
324 b = append(b, asa.currencyPositiveSuffix...)
325 b = append(b, symbol...)
331 // FmtDateShort returns the short date representation of 't' for 'asa_TZ'
332 func (asa *asa_TZ) FmtDateShort(t time.Time) string {
334 b := make([]byte, 0, 32)
340 b = strconv.AppendInt(b, int64(t.Day()), 10)
341 b = append(b, []byte{0x2f}...)
347 b = strconv.AppendInt(b, int64(t.Month()), 10)
349 b = append(b, []byte{0x2f}...)
352 b = strconv.AppendInt(b, int64(t.Year()), 10)
354 b = strconv.AppendInt(b, int64(-t.Year()), 10)
360 // FmtDateMedium returns the medium date representation of 't' for 'asa_TZ'
361 func (asa *asa_TZ) FmtDateMedium(t time.Time) string {
363 b := make([]byte, 0, 32)
365 b = strconv.AppendInt(b, int64(t.Day()), 10)
366 b = append(b, []byte{0x20}...)
367 b = append(b, asa.monthsAbbreviated[t.Month()]...)
368 b = append(b, []byte{0x20}...)
371 b = strconv.AppendInt(b, int64(t.Year()), 10)
373 b = strconv.AppendInt(b, int64(-t.Year()), 10)
379 // FmtDateLong returns the long date representation of 't' for 'asa_TZ'
380 func (asa *asa_TZ) FmtDateLong(t time.Time) string {
382 b := make([]byte, 0, 32)
384 b = strconv.AppendInt(b, int64(t.Day()), 10)
385 b = append(b, []byte{0x20}...)
386 b = append(b, asa.monthsWide[t.Month()]...)
387 b = append(b, []byte{0x20}...)
390 b = strconv.AppendInt(b, int64(t.Year()), 10)
392 b = strconv.AppendInt(b, int64(-t.Year()), 10)
398 // FmtDateFull returns the full date representation of 't' for 'asa_TZ'
399 func (asa *asa_TZ) FmtDateFull(t time.Time) string {
401 b := make([]byte, 0, 32)
403 b = append(b, asa.daysWide[t.Weekday()]...)
404 b = append(b, []byte{0x2c, 0x20}...)
405 b = strconv.AppendInt(b, int64(t.Day()), 10)
406 b = append(b, []byte{0x20}...)
407 b = append(b, asa.monthsWide[t.Month()]...)
408 b = append(b, []byte{0x20}...)
411 b = strconv.AppendInt(b, int64(t.Year()), 10)
413 b = strconv.AppendInt(b, int64(-t.Year()), 10)
419 // FmtTimeShort returns the short time representation of 't' for 'asa_TZ'
420 func (asa *asa_TZ) FmtTimeShort(t time.Time) string {
422 b := make([]byte, 0, 32)
428 b = strconv.AppendInt(b, int64(t.Hour()), 10)
429 b = append(b, asa.timeSeparator...)
435 b = strconv.AppendInt(b, int64(t.Minute()), 10)
440 // FmtTimeMedium returns the medium time representation of 't' for 'asa_TZ'
441 func (asa *asa_TZ) FmtTimeMedium(t time.Time) string {
443 b := make([]byte, 0, 32)
449 b = strconv.AppendInt(b, int64(t.Hour()), 10)
450 b = append(b, asa.timeSeparator...)
456 b = strconv.AppendInt(b, int64(t.Minute()), 10)
457 b = append(b, asa.timeSeparator...)
463 b = strconv.AppendInt(b, int64(t.Second()), 10)
468 // FmtTimeLong returns the long time representation of 't' for 'asa_TZ'
469 func (asa *asa_TZ) FmtTimeLong(t time.Time) string {
471 b := make([]byte, 0, 32)
477 b = strconv.AppendInt(b, int64(t.Hour()), 10)
478 b = append(b, asa.timeSeparator...)
484 b = strconv.AppendInt(b, int64(t.Minute()), 10)
485 b = append(b, asa.timeSeparator...)
491 b = strconv.AppendInt(b, int64(t.Second()), 10)
492 b = append(b, []byte{0x20}...)
500 // FmtTimeFull returns the full time representation of 't' for 'asa_TZ'
501 func (asa *asa_TZ) FmtTimeFull(t time.Time) string {
503 b := make([]byte, 0, 32)
509 b = strconv.AppendInt(b, int64(t.Hour()), 10)
510 b = append(b, asa.timeSeparator...)
516 b = strconv.AppendInt(b, int64(t.Minute()), 10)
517 b = append(b, asa.timeSeparator...)
523 b = strconv.AppendInt(b, int64(t.Second()), 10)
524 b = append(b, []byte{0x20}...)
528 if btz, ok := asa.timezones[tz]; ok {
529 b = append(b, btz...)