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 monthsAbbreviated []string
28 daysAbbreviated []string
32 periodsAbbreviated []string
33 periodsNarrow []string
36 erasAbbreviated []string
39 timezones map[string]string
42 // New returns a new instance of translator for the 'ak' locale
43 func New() locales.Translator {
46 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", "GH₵", "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 monthsAbbreviated: []string{"", "S-Ɔ", "K-Ɔ", "E-Ɔ", "E-O", "E-K", "O-A", "A-K", "D-Ɔ", "F-Ɛ", "Ɔ-A", "Ɔ-O", "M-Ɔ"},
54 monthsWide: []string{"", "Sanda-Ɔpɛpɔn", "Kwakwar-Ɔgyefuo", "Ebɔw-Ɔbenem", "Ebɔbira-Oforisuo", "Esusow Aketseaba-Kɔtɔnimba", "Obirade-Ayɛwohomumu", "Ayɛwoho-Kitawonsa", "Difuu-Ɔsandaa", "Fankwa-Ɛbɔ", "Ɔbɛsɛ-Ahinime", "Ɔberɛfɛw-Obubuo", "Mumu-Ɔpɛnimba"},
55 daysAbbreviated: []string{"Kwe", "Dwo", "Ben", "Wuk", "Yaw", "Fia", "Mem"},
56 daysNarrow: []string{"K", "D", "B", "W", "Y", "F", "M"},
57 daysWide: []string{"Kwesida", "Dwowda", "Benada", "Wukuda", "Yawda", "Fida", "Memeneda"},
58 periodsAbbreviated: []string{"AN", "EW"},
59 periodsWide: []string{"AN", "EW"},
60 erasAbbreviated: []string{"AK", "KE"},
61 erasNarrow: []string{"", ""},
62 erasWide: []string{"Ansa Kristo", "Kristo Ekyiri"},
63 timezones: map[string]string{"BT": "BT", "ACWDT": "ACWDT", "WIT": "WIT", "EAT": "EAT", "PST": "PST", "CHADT": "CHADT", "CDT": "CDT", "NZST": "NZST", "ARST": "ARST", "NZDT": "NZDT", "AEDT": "AEDT", "EDT": "EDT", "AKST": "AKST", "UYST": "UYST", "MESZ": "MESZ", "WARST": "WARST", "HAT": "HAT", "COST": "COST", "AWST": "AWST", "AWDT": "AWDT", "HNEG": "HNEG", "WESZ": "WESZ", "GMT": "GMT", "ChST": "ChST", "CST": "CST", "MDT": "MDT", "HKST": "HKST", "SGT": "SGT", "OEZ": "OEZ", "ACWST": "ACWST", "HENOMX": "HENOMX", "WITA": "WITA", "SAST": "SAST", "CLT": "CLT", "JST": "JST", "AKDT": "AKDT", "OESZ": "OESZ", "LHST": "LHST", "HNOG": "HNOG", "WAT": "WAT", "HKT": "HKT", "EST": "EST", "WEZ": "WEZ", "GYT": "GYT", "CHAST": "CHAST", "∅∅∅": "∅∅∅", "BOT": "BOT", "WART": "WART", "VET": "VET", "ADT": "ADT", "GFT": "GFT", "WIB": "WIB", "HEPM": "HEPM", "JDT": "JDT", "ACDT": "ACDT", "ECT": "ECT", "HNPMX": "HNPMX", "HAST": "HAST", "HADT": "HADT", "TMT": "TMT", "AST": "AST", "HEEG": "HEEG", "COT": "COT", "HEPMX": "HEPMX", "HNCU": "HNCU", "MYT": "MYT", "MEZ": "MEZ", "HNNOMX": "HNNOMX", "IST": "IST", "HNT": "HNT", "CLST": "CLST", "ACST": "ACST", "HECU": "HECU", "HNPM": "HNPM", "MST": "MST", "SRT": "SRT", "UYT": "UYT", "TMST": "TMST", "ART": "ART", "CAT": "CAT", "PDT": "PDT", "LHDT": "LHDT", "AEST": "AEST", "HEOG": "HEOG", "WAST": "WAST"},
67 // Locale returns the current translators string locale
68 func (ak *ak) Locale() string {
72 // PluralsCardinal returns the list of cardinal plural rules associated with 'ak'
73 func (ak *ak) PluralsCardinal() []locales.PluralRule {
74 return ak.pluralsCardinal
77 // PluralsOrdinal returns the list of ordinal plural rules associated with 'ak'
78 func (ak *ak) PluralsOrdinal() []locales.PluralRule {
79 return ak.pluralsOrdinal
82 // PluralsRange returns the list of range plural rules associated with 'ak'
83 func (ak *ak) PluralsRange() []locales.PluralRule {
84 return ak.pluralsRange
87 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ak'
88 func (ak *ak) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
93 return locales.PluralRuleOne
96 return locales.PluralRuleOther
99 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ak'
100 func (ak *ak) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
101 return locales.PluralRuleUnknown
104 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ak'
105 func (ak *ak) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
106 return locales.PluralRuleUnknown
109 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
110 func (ak *ak) MonthAbbreviated(month time.Month) string {
111 return ak.monthsAbbreviated[month]
114 // MonthsAbbreviated returns the locales abbreviated months
115 func (ak *ak) MonthsAbbreviated() []string {
116 return ak.monthsAbbreviated[1:]
119 // MonthNarrow returns the locales narrow month given the 'month' provided
120 func (ak *ak) MonthNarrow(month time.Month) string {
121 return ak.monthsNarrow[month]
124 // MonthsNarrow returns the locales narrow months
125 func (ak *ak) MonthsNarrow() []string {
129 // MonthWide returns the locales wide month given the 'month' provided
130 func (ak *ak) MonthWide(month time.Month) string {
131 return ak.monthsWide[month]
134 // MonthsWide returns the locales wide months
135 func (ak *ak) MonthsWide() []string {
136 return ak.monthsWide[1:]
139 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
140 func (ak *ak) WeekdayAbbreviated(weekday time.Weekday) string {
141 return ak.daysAbbreviated[weekday]
144 // WeekdaysAbbreviated returns the locales abbreviated weekdays
145 func (ak *ak) WeekdaysAbbreviated() []string {
146 return ak.daysAbbreviated
149 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
150 func (ak *ak) WeekdayNarrow(weekday time.Weekday) string {
151 return ak.daysNarrow[weekday]
154 // WeekdaysNarrow returns the locales narrow weekdays
155 func (ak *ak) WeekdaysNarrow() []string {
159 // WeekdayShort returns the locales short weekday given the 'weekday' provided
160 func (ak *ak) WeekdayShort(weekday time.Weekday) string {
161 return ak.daysShort[weekday]
164 // WeekdaysShort returns the locales short weekdays
165 func (ak *ak) WeekdaysShort() []string {
169 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
170 func (ak *ak) WeekdayWide(weekday time.Weekday) string {
171 return ak.daysWide[weekday]
174 // WeekdaysWide returns the locales wide weekdays
175 func (ak *ak) WeekdaysWide() []string {
179 // Decimal returns the decimal point of number
180 func (ak *ak) Decimal() string {
184 // Group returns the group of number
185 func (ak *ak) Group() string {
189 // Group returns the minus sign of number
190 func (ak *ak) Minus() string {
194 // FmtNumber returns 'num' with digits/precision of 'v' for 'ak' and handles both Whole and Real numbers based on 'v'
195 func (ak *ak) FmtNumber(num float64, v uint64) string {
197 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
200 // FmtPercent returns 'num' with digits/precision of 'v' for 'ak' and handles both Whole and Real numbers based on 'v'
201 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
202 func (ak *ak) FmtPercent(num float64, v uint64) string {
203 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ak'
207 func (ak *ak) FmtCurrency(num float64, v uint64, currency currency.Type) string {
209 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
210 symbol := ak.currencies[currency]
211 l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
214 b := make([]byte, 0, l)
216 for i := len(s) - 1; i >= 0; i-- {
219 b = append(b, ak.decimal[0])
226 b = append(b, ak.group[0])
236 for j := len(symbol) - 1; j >= 0; j-- {
237 b = append(b, symbol[j])
241 b = append(b, ak.minus[0])
245 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
246 b[i], b[j] = b[j], b[i]
252 b = append(b, ak.decimal...)
255 for i := 0; i < 2-int(v); i++ {
263 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ak'
264 // in accounting notation.
265 func (ak *ak) FmtAccounting(num float64, v uint64, currency currency.Type) string {
267 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
268 symbol := ak.currencies[currency]
269 l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
272 b := make([]byte, 0, l)
274 for i := len(s) - 1; i >= 0; i-- {
277 b = append(b, ak.decimal[0])
284 b = append(b, ak.group[0])
296 for j := len(symbol) - 1; j >= 0; j-- {
297 b = append(b, symbol[j])
300 b = append(b, ak.minus[0])
304 for j := len(symbol) - 1; j >= 0; j-- {
305 b = append(b, symbol[j])
311 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
312 b[i], b[j] = b[j], b[i]
318 b = append(b, ak.decimal...)
321 for i := 0; i < 2-int(v); i++ {
329 // FmtDateShort returns the short date representation of 't' for 'ak'
330 func (ak *ak) FmtDateShort(t time.Time) string {
332 b := make([]byte, 0, 32)
335 b = append(b, strconv.Itoa(t.Year())[2:]...)
337 b = append(b, strconv.Itoa(t.Year())[1:]...)
340 b = append(b, []byte{0x2f}...)
346 b = strconv.AppendInt(b, int64(t.Month()), 10)
348 b = append(b, []byte{0x2f}...)
354 b = strconv.AppendInt(b, int64(t.Day()), 10)
359 // FmtDateMedium returns the medium date representation of 't' for 'ak'
360 func (ak *ak) FmtDateMedium(t time.Time) string {
362 b := make([]byte, 0, 32)
365 b = strconv.AppendInt(b, int64(t.Year()), 10)
367 b = strconv.AppendInt(b, int64(-t.Year()), 10)
370 b = append(b, []byte{0x20}...)
371 b = append(b, ak.monthsAbbreviated[t.Month()]...)
372 b = append(b, []byte{0x20}...)
373 b = strconv.AppendInt(b, int64(t.Day()), 10)
378 // FmtDateLong returns the long date representation of 't' for 'ak'
379 func (ak *ak) FmtDateLong(t time.Time) string {
381 b := make([]byte, 0, 32)
384 b = strconv.AppendInt(b, int64(t.Year()), 10)
386 b = strconv.AppendInt(b, int64(-t.Year()), 10)
389 b = append(b, []byte{0x20}...)
390 b = append(b, ak.monthsWide[t.Month()]...)
391 b = append(b, []byte{0x20}...)
392 b = strconv.AppendInt(b, int64(t.Day()), 10)
397 // FmtDateFull returns the full date representation of 't' for 'ak'
398 func (ak *ak) FmtDateFull(t time.Time) string {
400 b := make([]byte, 0, 32)
402 b = append(b, ak.daysWide[t.Weekday()]...)
403 b = append(b, []byte{0x2c, 0x20}...)
406 b = strconv.AppendInt(b, int64(t.Year()), 10)
408 b = strconv.AppendInt(b, int64(-t.Year()), 10)
411 b = append(b, []byte{0x20}...)
412 b = append(b, ak.monthsWide[t.Month()]...)
413 b = append(b, []byte{0x20}...)
419 b = strconv.AppendInt(b, int64(t.Day()), 10)
424 // FmtTimeShort returns the short time representation of 't' for 'ak'
425 func (ak *ak) FmtTimeShort(t time.Time) string {
427 b := make([]byte, 0, 32)
435 b = strconv.AppendInt(b, int64(h), 10)
436 b = append(b, ak.timeSeparator...)
442 b = strconv.AppendInt(b, int64(t.Minute()), 10)
443 b = append(b, []byte{0x20}...)
446 b = append(b, ak.periodsAbbreviated[0]...)
448 b = append(b, ak.periodsAbbreviated[1]...)
454 // FmtTimeMedium returns the medium time representation of 't' for 'ak'
455 func (ak *ak) FmtTimeMedium(t time.Time) string {
457 b := make([]byte, 0, 32)
465 b = strconv.AppendInt(b, int64(h), 10)
466 b = append(b, ak.timeSeparator...)
472 b = strconv.AppendInt(b, int64(t.Minute()), 10)
473 b = append(b, ak.timeSeparator...)
479 b = strconv.AppendInt(b, int64(t.Second()), 10)
480 b = append(b, []byte{0x20}...)
483 b = append(b, ak.periodsAbbreviated[0]...)
485 b = append(b, ak.periodsAbbreviated[1]...)
491 // FmtTimeLong returns the long time representation of 't' for 'ak'
492 func (ak *ak) FmtTimeLong(t time.Time) string {
494 b := make([]byte, 0, 32)
502 b = strconv.AppendInt(b, int64(h), 10)
503 b = append(b, ak.timeSeparator...)
509 b = strconv.AppendInt(b, int64(t.Minute()), 10)
510 b = append(b, ak.timeSeparator...)
516 b = strconv.AppendInt(b, int64(t.Second()), 10)
517 b = append(b, []byte{0x20}...)
520 b = append(b, ak.periodsAbbreviated[0]...)
522 b = append(b, ak.periodsAbbreviated[1]...)
525 b = append(b, []byte{0x20}...)
533 // FmtTimeFull returns the full time representation of 't' for 'ak'
534 func (ak *ak) FmtTimeFull(t time.Time) string {
536 b := make([]byte, 0, 32)
544 b = strconv.AppendInt(b, int64(h), 10)
545 b = append(b, ak.timeSeparator...)
551 b = strconv.AppendInt(b, int64(t.Minute()), 10)
552 b = append(b, ak.timeSeparator...)
558 b = strconv.AppendInt(b, int64(t.Second()), 10)
559 b = append(b, []byte{0x20}...)
562 b = append(b, ak.periodsAbbreviated[0]...)
564 b = append(b, ak.periodsAbbreviated[1]...)
567 b = append(b, []byte{0x20}...)
571 if btz, ok := ak.timezones[tz]; ok {
572 b = append(b, btz...)