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 'bm_ML' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{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 currencyNegativePrefix: "(",
54 currencyNegativeSuffix: ")",
55 monthsAbbreviated: []string{"", "zan", "feb", "mar", "awi", "mɛ", "zuw", "zul", "uti", "sɛt", "ɔku", "now", "des"},
56 monthsNarrow: []string{"", "Z", "F", "M", "A", "M", "Z", "Z", "U", "S", "Ɔ", "N", "D"},
57 monthsWide: []string{"", "zanwuye", "feburuye", "marisi", "awirili", "mɛ", "zuwɛn", "zuluye", "uti", "sɛtanburu", "ɔkutɔburu", "nowanburu", "desanburu"},
58 daysAbbreviated: []string{"kar", "ntɛ", "tar", "ara", "ala", "jum", "sib"},
59 daysNarrow: []string{"K", "N", "T", "A", "A", "J", "S"},
60 daysWide: []string{"kari", "ntɛnɛ", "tarata", "araba", "alamisa", "juma", "sibiri"},
61 erasAbbreviated: []string{"J.-C. ɲɛ", "ni J.-C."},
62 erasNarrow: []string{"", ""},
63 erasWide: []string{"jezu krisiti ɲɛ", "jezu krisiti minkɛ"},
64 timezones: map[string]string{"MST": "MST", "HEEG": "HEEG", "HEPM": "HEPM", "ACWST": "ACWST", "ARST": "ARST", "GYT": "GYT", "AKDT": "AKDT", "HNPMX": "HNPMX", "HNCU": "HNCU", "WITA": "WITA", "OESZ": "OESZ", "AST": "AST", "SGT": "SGT", "MYT": "MYT", "NZST": "NZST", "EAT": "EAT", "EDT": "EDT", "SRT": "SRT", "ADT": "ADT", "GFT": "GFT", "WIB": "WIB", "CDT": "CDT", "JST": "JST", "HNOG": "HNOG", "AEDT": "AEDT", "COST": "COST", "HADT": "HADT", "HNNOMX": "HNNOMX", "LHST": "LHST", "HNT": "HNT", "ECT": "ECT", "AKST": "AKST", "ChST": "ChST", "BT": "BT", "VET": "VET", "LHDT": "LHDT", "HNEG": "HNEG", "WARST": "WARST", "OEZ": "OEZ", "WAST": "WAST", "PST": "PST", "BOT": "BOT", "MESZ": "MESZ", "CLT": "CLT", "ACDT": "ACDT", "CLST": "CLST", "PDT": "PDT", "AWST": "AWST", "∅∅∅": "∅∅∅", "MDT": "MDT", "MEZ": "MEZ", "HAST": "HAST", "IST": "IST", "COT": "COT", "CHAST": "CHAST", "UYST": "UYST", "WIT": "WIT", "TMT": "TMT", "AEST": "AEST", "SAST": "SAST", "WESZ": "WESZ", "HNPM": "HNPM", "AWDT": "AWDT", "CST": "CST", "WART": "WART", "HEOG": "HEOG", "CAT": "CAT", "WEZ": "WEZ", "HEPMX": "HEPMX", "GMT": "GMT", "UYT": "UYT", "TMST": "TMST", "HENOMX": "HENOMX", "ACST": "ACST", "ART": "ART", "WAT": "WAT", "HKST": "HKST", "HAT": "HAT", "HKT": "HKT", "EST": "EST", "HECU": "HECU", "CHADT": "CHADT", "ACWDT": "ACWDT", "NZDT": "NZDT", "JDT": "JDT"},
68 // Locale returns the current translators string locale
69 func (bm *bm_ML) Locale() string {
73 // PluralsCardinal returns the list of cardinal plural rules associated with 'bm_ML'
74 func (bm *bm_ML) PluralsCardinal() []locales.PluralRule {
75 return bm.pluralsCardinal
78 // PluralsOrdinal returns the list of ordinal plural rules associated with 'bm_ML'
79 func (bm *bm_ML) PluralsOrdinal() []locales.PluralRule {
80 return bm.pluralsOrdinal
83 // PluralsRange returns the list of range plural rules associated with 'bm_ML'
84 func (bm *bm_ML) PluralsRange() []locales.PluralRule {
85 return bm.pluralsRange
88 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bm_ML'
89 func (bm *bm_ML) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
90 return locales.PluralRuleOther
93 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bm_ML'
94 func (bm *bm_ML) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
95 return locales.PluralRuleUnknown
98 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bm_ML'
99 func (bm *bm_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
103 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
104 func (bm *bm_ML) MonthAbbreviated(month time.Month) string {
105 return bm.monthsAbbreviated[month]
108 // MonthsAbbreviated returns the locales abbreviated months
109 func (bm *bm_ML) MonthsAbbreviated() []string {
110 return bm.monthsAbbreviated[1:]
113 // MonthNarrow returns the locales narrow month given the 'month' provided
114 func (bm *bm_ML) MonthNarrow(month time.Month) string {
115 return bm.monthsNarrow[month]
118 // MonthsNarrow returns the locales narrow months
119 func (bm *bm_ML) MonthsNarrow() []string {
120 return bm.monthsNarrow[1:]
123 // MonthWide returns the locales wide month given the 'month' provided
124 func (bm *bm_ML) MonthWide(month time.Month) string {
125 return bm.monthsWide[month]
128 // MonthsWide returns the locales wide months
129 func (bm *bm_ML) MonthsWide() []string {
130 return bm.monthsWide[1:]
133 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
134 func (bm *bm_ML) WeekdayAbbreviated(weekday time.Weekday) string {
135 return bm.daysAbbreviated[weekday]
138 // WeekdaysAbbreviated returns the locales abbreviated weekdays
139 func (bm *bm_ML) WeekdaysAbbreviated() []string {
140 return bm.daysAbbreviated
143 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
144 func (bm *bm_ML) WeekdayNarrow(weekday time.Weekday) string {
145 return bm.daysNarrow[weekday]
148 // WeekdaysNarrow returns the locales narrow weekdays
149 func (bm *bm_ML) WeekdaysNarrow() []string {
153 // WeekdayShort returns the locales short weekday given the 'weekday' provided
154 func (bm *bm_ML) WeekdayShort(weekday time.Weekday) string {
155 return bm.daysShort[weekday]
158 // WeekdaysShort returns the locales short weekdays
159 func (bm *bm_ML) WeekdaysShort() []string {
163 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
164 func (bm *bm_ML) WeekdayWide(weekday time.Weekday) string {
165 return bm.daysWide[weekday]
168 // WeekdaysWide returns the locales wide weekdays
169 func (bm *bm_ML) WeekdaysWide() []string {
173 // Decimal returns the decimal point of number
174 func (bm *bm_ML) Decimal() string {
178 // Group returns the group of number
179 func (bm *bm_ML) Group() string {
183 // Group returns the minus sign of number
184 func (bm *bm_ML) Minus() string {
188 // FmtNumber returns 'num' with digits/precision of 'v' for 'bm_ML' and handles both Whole and Real numbers based on 'v'
189 func (bm *bm_ML) FmtNumber(num float64, v uint64) string {
191 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
194 // FmtPercent returns 'num' with digits/precision of 'v' for 'bm_ML' and handles both Whole and Real numbers based on 'v'
195 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
196 func (bm *bm_ML) FmtPercent(num float64, v uint64) string {
197 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
200 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bm_ML'
201 func (bm *bm_ML) FmtCurrency(num float64, v uint64, currency currency.Type) string {
203 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
204 symbol := bm.currencies[currency]
205 l := len(s) + len(symbol) + 0
208 b := make([]byte, 0, l)
210 for i := len(s) - 1; i >= 0; i-- {
213 b = append(b, bm.decimal[0])
220 b = append(b, bm.group[0])
230 for j := len(symbol) - 1; j >= 0; j-- {
231 b = append(b, symbol[j])
235 b = append(b, bm.minus[0])
239 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240 b[i], b[j] = b[j], b[i]
246 b = append(b, bm.decimal...)
249 for i := 0; i < 2-int(v); i++ {
257 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bm_ML'
258 // in accounting notation.
259 func (bm *bm_ML) FmtAccounting(num float64, v uint64, currency currency.Type) string {
261 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
262 symbol := bm.currencies[currency]
263 l := len(s) + len(symbol) + 2
266 b := make([]byte, 0, l)
268 for i := len(s) - 1; i >= 0; i-- {
271 b = append(b, bm.decimal[0])
278 b = append(b, bm.group[0])
290 for j := len(symbol) - 1; j >= 0; j-- {
291 b = append(b, symbol[j])
294 b = append(b, bm.currencyNegativePrefix[0])
298 for j := len(symbol) - 1; j >= 0; j-- {
299 b = append(b, symbol[j])
305 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
306 b[i], b[j] = b[j], b[i]
312 b = append(b, bm.decimal...)
315 for i := 0; i < 2-int(v); i++ {
321 b = append(b, bm.currencyNegativeSuffix...)
327 // FmtDateShort returns the short date representation of 't' for 'bm_ML'
328 func (bm *bm_ML) FmtDateShort(t time.Time) string {
330 b := make([]byte, 0, 32)
332 b = strconv.AppendInt(b, int64(t.Day()), 10)
333 b = append(b, []byte{0x2f}...)
334 b = strconv.AppendInt(b, int64(t.Month()), 10)
335 b = append(b, []byte{0x2f}...)
338 b = strconv.AppendInt(b, int64(t.Year()), 10)
340 b = strconv.AppendInt(b, int64(-t.Year()), 10)
346 // FmtDateMedium returns the medium date representation of 't' for 'bm_ML'
347 func (bm *bm_ML) FmtDateMedium(t time.Time) string {
349 b := make([]byte, 0, 32)
351 b = strconv.AppendInt(b, int64(t.Day()), 10)
352 b = append(b, []byte{0x20}...)
353 b = append(b, bm.monthsAbbreviated[t.Month()]...)
354 b = append(b, []byte{0x2c, 0x20}...)
357 b = strconv.AppendInt(b, int64(t.Year()), 10)
359 b = strconv.AppendInt(b, int64(-t.Year()), 10)
365 // FmtDateLong returns the long date representation of 't' for 'bm_ML'
366 func (bm *bm_ML) FmtDateLong(t time.Time) string {
368 b := make([]byte, 0, 32)
370 b = strconv.AppendInt(b, int64(t.Day()), 10)
371 b = append(b, []byte{0x20}...)
372 b = append(b, bm.monthsWide[t.Month()]...)
373 b = append(b, []byte{0x20}...)
376 b = strconv.AppendInt(b, int64(t.Year()), 10)
378 b = strconv.AppendInt(b, int64(-t.Year()), 10)
384 // FmtDateFull returns the full date representation of 't' for 'bm_ML'
385 func (bm *bm_ML) FmtDateFull(t time.Time) string {
387 b := make([]byte, 0, 32)
389 b = append(b, bm.daysWide[t.Weekday()]...)
390 b = append(b, []byte{0x20}...)
391 b = strconv.AppendInt(b, int64(t.Day()), 10)
392 b = append(b, []byte{0x20}...)
393 b = append(b, bm.monthsWide[t.Month()]...)
394 b = append(b, []byte{0x20}...)
397 b = strconv.AppendInt(b, int64(t.Year()), 10)
399 b = strconv.AppendInt(b, int64(-t.Year()), 10)
405 // FmtTimeShort returns the short time representation of 't' for 'bm_ML'
406 func (bm *bm_ML) FmtTimeShort(t time.Time) string {
408 b := make([]byte, 0, 32)
414 b = strconv.AppendInt(b, int64(t.Hour()), 10)
415 b = append(b, bm.timeSeparator...)
421 b = strconv.AppendInt(b, int64(t.Minute()), 10)
426 // FmtTimeMedium returns the medium time representation of 't' for 'bm_ML'
427 func (bm *bm_ML) FmtTimeMedium(t time.Time) string {
429 b := make([]byte, 0, 32)
435 b = strconv.AppendInt(b, int64(t.Hour()), 10)
436 b = append(b, bm.timeSeparator...)
442 b = strconv.AppendInt(b, int64(t.Minute()), 10)
443 b = append(b, bm.timeSeparator...)
449 b = strconv.AppendInt(b, int64(t.Second()), 10)
454 // FmtTimeLong returns the long time representation of 't' for 'bm_ML'
455 func (bm *bm_ML) FmtTimeLong(t time.Time) string {
457 b := make([]byte, 0, 32)
463 b = strconv.AppendInt(b, int64(t.Hour()), 10)
464 b = append(b, bm.timeSeparator...)
470 b = strconv.AppendInt(b, int64(t.Minute()), 10)
471 b = append(b, bm.timeSeparator...)
477 b = strconv.AppendInt(b, int64(t.Second()), 10)
478 b = append(b, []byte{0x20}...)
486 // FmtTimeFull returns the full time representation of 't' for 'bm_ML'
487 func (bm *bm_ML) FmtTimeFull(t time.Time) string {
489 b := make([]byte, 0, 32)
495 b = strconv.AppendInt(b, int64(t.Hour()), 10)
496 b = append(b, bm.timeSeparator...)
502 b = strconv.AppendInt(b, int64(t.Minute()), 10)
503 b = append(b, bm.timeSeparator...)
509 b = strconv.AppendInt(b, int64(t.Second()), 10)
510 b = append(b, []byte{0x20}...)
514 if btz, ok := bm.timezones[tz]; ok {
515 b = append(b, btz...)