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 currencyPositivePrefix string
26 currencyNegativePrefix 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 'mgo_CM' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 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", "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"},
59 currencyPositivePrefix: " ",
60 currencyNegativePrefix: " ",
61 monthsAbbreviated: []string{"", "mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"},
62 monthsNarrow: []string{"", "M1", "A2", "M3", "N4", "F5", "I6", "A7", "I8", "K9", "10", "11", "12"},
63 monthsWide: []string{"", "iməg mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"},
64 daysAbbreviated: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"},
65 daysNarrow: []string{"A1", "A2", "A3", "A4", "A5", "A6", "A7"},
66 daysShort: []string{"1", "2", "3", "4", "5", "6", "7"},
67 daysWide: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsWide: []string{"AM", "PM"},
70 erasAbbreviated: []string{"BCE", "CE"},
71 erasNarrow: []string{"", ""},
72 erasWide: []string{"", ""},
73 timezones: map[string]string{"CLST": "CLST", "HEPM": "HEPM", "∅∅∅": "∅∅∅", "WARST": "WARST", "HNEG": "HNEG", "WESZ": "WESZ", "CHADT": "CHADT", "PST": "PST", "ACWST": "ACWST", "WART": "WART", "SAST": "SAST", "HKST": "HKST", "COT": "COT", "AKST": "AKST", "HADT": "HADT", "LHST": "LHST", "WITA": "WITA", "OEZ": "OEZ", "WAT": "WAT", "CHAST": "CHAST", "BT": "BT", "EAT": "EAT", "ACDT": "ACDT", "WEZ": "WEZ", "ChST": "ChST", "JDT": "JDT", "COST": "COST", "GFT": "GFT", "EDT": "EDT", "GMT": "GMT", "HEOG": "HEOG", "CLT": "CLT", "CAT": "CAT", "TMT": "TMT", "JST": "JST", "AEST": "AEST", "HNOG": "HNOG", "WIT": "WIT", "ACWDT": "ACWDT", "MEZ": "MEZ", "AEDT": "AEDT", "AKDT": "AKDT", "OESZ": "OESZ", "HEEG": "HEEG", "HKT": "HKT", "HNCU": "HNCU", "UYT": "UYT", "MESZ": "MESZ", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "GYT": "GYT", "SGT": "SGT", "HNPMX": "HNPMX", "MDT": "MDT", "AWDT": "AWDT", "UYST": "UYST", "TMST": "TMST", "VET": "VET", "ARST": "ARST", "HAT": "HAT", "WIB": "WIB", "MST": "MST", "SRT": "SRT", "MYT": "MYT", "NZDT": "NZDT", "EST": "EST", "ACST": "ACST", "ADT": "ADT", "WAST": "WAST", "HNT": "HNT", "IST": "IST", "ART": "ART", "AST": "AST", "HECU": "HECU", "PDT": "PDT", "BOT": "BOT", "CST": "CST", "NZST": "NZST", "LHDT": "LHDT", "ECT": "ECT", "HEPMX": "HEPMX", "HNPM": "HNPM", "AWST": "AWST", "CDT": "CDT", "HAST": "HAST"},
77 // Locale returns the current translators string locale
78 func (mgo *mgo_CM) Locale() string {
82 // PluralsCardinal returns the list of cardinal plural rules associated with 'mgo_CM'
83 func (mgo *mgo_CM) PluralsCardinal() []locales.PluralRule {
84 return mgo.pluralsCardinal
87 // PluralsOrdinal returns the list of ordinal plural rules associated with 'mgo_CM'
88 func (mgo *mgo_CM) PluralsOrdinal() []locales.PluralRule {
89 return mgo.pluralsOrdinal
92 // PluralsRange returns the list of range plural rules associated with 'mgo_CM'
93 func (mgo *mgo_CM) PluralsRange() []locales.PluralRule {
94 return mgo.pluralsRange
97 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM'
98 func (mgo *mgo_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
103 return locales.PluralRuleOne
106 return locales.PluralRuleOther
109 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM'
110 func (mgo *mgo_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
111 return locales.PluralRuleUnknown
114 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgo_CM'
115 func (mgo *mgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
116 return locales.PluralRuleUnknown
119 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
120 func (mgo *mgo_CM) MonthAbbreviated(month time.Month) string {
121 return mgo.monthsAbbreviated[month]
124 // MonthsAbbreviated returns the locales abbreviated months
125 func (mgo *mgo_CM) MonthsAbbreviated() []string {
126 return mgo.monthsAbbreviated[1:]
129 // MonthNarrow returns the locales narrow month given the 'month' provided
130 func (mgo *mgo_CM) MonthNarrow(month time.Month) string {
131 return mgo.monthsNarrow[month]
134 // MonthsNarrow returns the locales narrow months
135 func (mgo *mgo_CM) MonthsNarrow() []string {
136 return mgo.monthsNarrow[1:]
139 // MonthWide returns the locales wide month given the 'month' provided
140 func (mgo *mgo_CM) MonthWide(month time.Month) string {
141 return mgo.monthsWide[month]
144 // MonthsWide returns the locales wide months
145 func (mgo *mgo_CM) MonthsWide() []string {
146 return mgo.monthsWide[1:]
149 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
150 func (mgo *mgo_CM) WeekdayAbbreviated(weekday time.Weekday) string {
151 return mgo.daysAbbreviated[weekday]
154 // WeekdaysAbbreviated returns the locales abbreviated weekdays
155 func (mgo *mgo_CM) WeekdaysAbbreviated() []string {
156 return mgo.daysAbbreviated
159 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
160 func (mgo *mgo_CM) WeekdayNarrow(weekday time.Weekday) string {
161 return mgo.daysNarrow[weekday]
164 // WeekdaysNarrow returns the locales narrow weekdays
165 func (mgo *mgo_CM) WeekdaysNarrow() []string {
166 return mgo.daysNarrow
169 // WeekdayShort returns the locales short weekday given the 'weekday' provided
170 func (mgo *mgo_CM) WeekdayShort(weekday time.Weekday) string {
171 return mgo.daysShort[weekday]
174 // WeekdaysShort returns the locales short weekdays
175 func (mgo *mgo_CM) WeekdaysShort() []string {
179 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
180 func (mgo *mgo_CM) WeekdayWide(weekday time.Weekday) string {
181 return mgo.daysWide[weekday]
184 // WeekdaysWide returns the locales wide weekdays
185 func (mgo *mgo_CM) WeekdaysWide() []string {
189 // Decimal returns the decimal point of number
190 func (mgo *mgo_CM) Decimal() string {
194 // Group returns the group of number
195 func (mgo *mgo_CM) Group() string {
199 // Group returns the minus sign of number
200 func (mgo *mgo_CM) Minus() string {
204 // FmtNumber returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v'
205 func (mgo *mgo_CM) FmtNumber(num float64, v uint64) string {
207 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
208 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
211 b := make([]byte, 0, l)
213 for i := len(s) - 1; i >= 0; i-- {
216 b = append(b, mgo.decimal[0])
223 b = append(b, mgo.group[0])
234 b = append(b, mgo.minus[0])
238 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
239 b[i], b[j] = b[j], b[i]
245 // FmtPercent returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v'
246 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
247 func (mgo *mgo_CM) FmtPercent(num float64, v uint64) string {
248 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250 b := make([]byte, 0, l)
252 for i := len(s) - 1; i >= 0; i-- {
255 b = append(b, mgo.decimal[0])
263 b = append(b, mgo.minus[0])
267 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
268 b[i], b[j] = b[j], b[i]
271 b = append(b, mgo.percent...)
276 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM'
277 func (mgo *mgo_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
279 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
280 symbol := mgo.currencies[currency]
281 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
284 b := make([]byte, 0, l)
286 for i := len(s) - 1; i >= 0; i-- {
289 b = append(b, mgo.decimal[0])
296 b = append(b, mgo.group[0])
306 for j := len(symbol) - 1; j >= 0; j-- {
307 b = append(b, symbol[j])
310 for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- {
311 b = append(b, mgo.currencyPositivePrefix[j])
315 b = append(b, mgo.minus[0])
319 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
320 b[i], b[j] = b[j], b[i]
326 b = append(b, mgo.decimal...)
329 for i := 0; i < 2-int(v); i++ {
337 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM'
338 // in accounting notation.
339 func (mgo *mgo_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
341 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
342 symbol := mgo.currencies[currency]
343 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
346 b := make([]byte, 0, l)
348 for i := len(s) - 1; i >= 0; i-- {
351 b = append(b, mgo.decimal[0])
358 b = append(b, mgo.group[0])
370 for j := len(symbol) - 1; j >= 0; j-- {
371 b = append(b, symbol[j])
374 for j := len(mgo.currencyNegativePrefix) - 1; j >= 0; j-- {
375 b = append(b, mgo.currencyNegativePrefix[j])
378 b = append(b, mgo.minus[0])
382 for j := len(symbol) - 1; j >= 0; j-- {
383 b = append(b, symbol[j])
386 for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- {
387 b = append(b, mgo.currencyPositivePrefix[j])
393 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
394 b[i], b[j] = b[j], b[i]
400 b = append(b, mgo.decimal...)
403 for i := 0; i < 2-int(v); i++ {
411 // FmtDateShort returns the short date representation of 't' for 'mgo_CM'
412 func (mgo *mgo_CM) FmtDateShort(t time.Time) string {
414 b := make([]byte, 0, 32)
417 b = strconv.AppendInt(b, int64(t.Year()), 10)
419 b = strconv.AppendInt(b, int64(-t.Year()), 10)
422 b = append(b, []byte{0x2d}...)
428 b = strconv.AppendInt(b, int64(t.Month()), 10)
430 b = append(b, []byte{0x2d}...)
436 b = strconv.AppendInt(b, int64(t.Day()), 10)
441 // FmtDateMedium returns the medium date representation of 't' for 'mgo_CM'
442 func (mgo *mgo_CM) FmtDateMedium(t time.Time) string {
444 b := make([]byte, 0, 32)
447 b = strconv.AppendInt(b, int64(t.Year()), 10)
449 b = strconv.AppendInt(b, int64(-t.Year()), 10)
452 b = append(b, []byte{0x20}...)
453 b = append(b, mgo.monthsAbbreviated[t.Month()]...)
454 b = append(b, []byte{0x20}...)
455 b = strconv.AppendInt(b, int64(t.Day()), 10)
460 // FmtDateLong returns the long date representation of 't' for 'mgo_CM'
461 func (mgo *mgo_CM) FmtDateLong(t time.Time) string {
463 b := make([]byte, 0, 32)
466 b = strconv.AppendInt(b, int64(t.Year()), 10)
468 b = strconv.AppendInt(b, int64(-t.Year()), 10)
471 b = append(b, []byte{0x20}...)
472 b = append(b, mgo.monthsWide[t.Month()]...)
473 b = append(b, []byte{0x20}...)
474 b = strconv.AppendInt(b, int64(t.Day()), 10)
479 // FmtDateFull returns the full date representation of 't' for 'mgo_CM'
480 func (mgo *mgo_CM) FmtDateFull(t time.Time) string {
482 b := make([]byte, 0, 32)
484 b = append(b, mgo.daysWide[t.Weekday()]...)
485 b = append(b, []byte{0x2c, 0x20}...)
488 b = strconv.AppendInt(b, int64(t.Year()), 10)
490 b = strconv.AppendInt(b, int64(-t.Year()), 10)
493 b = append(b, []byte{0x20}...)
494 b = append(b, mgo.monthsWide[t.Month()]...)
495 b = append(b, []byte{0x20}...)
501 b = strconv.AppendInt(b, int64(t.Day()), 10)
506 // FmtTimeShort returns the short time representation of 't' for 'mgo_CM'
507 func (mgo *mgo_CM) FmtTimeShort(t time.Time) string {
509 b := make([]byte, 0, 32)
515 b = strconv.AppendInt(b, int64(t.Hour()), 10)
516 b = append(b, mgo.timeSeparator...)
522 b = strconv.AppendInt(b, int64(t.Minute()), 10)
527 // FmtTimeMedium returns the medium time representation of 't' for 'mgo_CM'
528 func (mgo *mgo_CM) FmtTimeMedium(t time.Time) string {
530 b := make([]byte, 0, 32)
536 b = strconv.AppendInt(b, int64(t.Hour()), 10)
537 b = append(b, mgo.timeSeparator...)
543 b = strconv.AppendInt(b, int64(t.Minute()), 10)
544 b = append(b, mgo.timeSeparator...)
550 b = strconv.AppendInt(b, int64(t.Second()), 10)
555 // FmtTimeLong returns the long time representation of 't' for 'mgo_CM'
556 func (mgo *mgo_CM) FmtTimeLong(t time.Time) string {
558 b := make([]byte, 0, 32)
564 b = strconv.AppendInt(b, int64(t.Hour()), 10)
565 b = append(b, mgo.timeSeparator...)
571 b = strconv.AppendInt(b, int64(t.Minute()), 10)
572 b = append(b, mgo.timeSeparator...)
578 b = strconv.AppendInt(b, int64(t.Second()), 10)
579 b = append(b, []byte{0x20}...)
587 // FmtTimeFull returns the full time representation of 't' for 'mgo_CM'
588 func (mgo *mgo_CM) FmtTimeFull(t time.Time) string {
590 b := make([]byte, 0, 32)
596 b = strconv.AppendInt(b, int64(t.Hour()), 10)
597 b = append(b, mgo.timeSeparator...)
603 b = strconv.AppendInt(b, int64(t.Minute()), 10)
604 b = append(b, mgo.timeSeparator...)
610 b = strconv.AppendInt(b, int64(t.Second()), 10)
611 b = append(b, []byte{0x20}...)
615 if btz, ok := mgo.timezones[tz]; ok {
616 b = append(b, btz...)