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 'om_ET' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 6},
56 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"},
57 monthsAbbreviated: []string{"", "Ama", "Gur", "Bit", "Elb", "Cam", "Wax", "Ado", "Hag", "Ful", "Onk", "Sad", "Mud"},
58 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
59 monthsWide: []string{"", "Amajjii", "Guraandhala", "Bitooteessa", "Elba", "Caamsa", "Waxabajjii", "Adooleessa", "Hagayya", "Fuulbana", "Onkololeessa", "Sadaasa", "Muddee"},
60 daysAbbreviated: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"},
61 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
62 daysShort: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"},
63 daysWide: []string{"Dilbata", "Wiixata", "Qibxata", "Roobii", "Kamiisa", "Jimaata", "Sanbata"},
64 periodsAbbreviated: []string{"WD", "WB"},
65 periodsNarrow: []string{"WD", "WB"},
66 periodsWide: []string{"WD", "WB"},
67 erasAbbreviated: []string{"BCE", "CE"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"", ""},
70 timezones: map[string]string{"MYT": "MYT", "UYT": "UYT", "CHADT": "CHADT", "WARST": "WARST", "AEDT": "AEDT", "COST": "COST", "EDT": "EDT", "CAT": "CAT", "WEZ": "WEZ", "NZDT": "NZDT", "VET": "VET", "ACDT": "ACDT", "WESZ": "WESZ", "WIB": "WIB", "PST": "PST", "MEZ": "MEZ", "OEZ": "OEZ", "GYT": "GYT", "HNCU": "HNCU", "SRT": "SRT", "ADT": "ADT", "AEST": "AEST", "HNEG": "HNEG", "HECU": "HECU", "BOT": "BOT", "OESZ": "OESZ", "ART": "ART", "ARST": "ARST", "GFT": "GFT", "CHAST": "CHAST", "AST": "AST", "WAT": "WAT", "EST": "EST", "ACST": "ACST", "PDT": "PDT", "HNPM": "HNPM", "HADT": "HADT", "∅∅∅": "∅∅∅", "CLT": "CLT", "HEEG": "HEEG", "JST": "JST", "CLST": "CLST", "HNPMX": "HNPMX", "AWDT": "AWDT", "NZST": "NZST", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "WITA": "WITA", "AWST": "AWST", "ACWST": "ACWST", "ACWDT": "ACWDT", "TMST": "TMST", "CDT": "CDT", "JDT": "JDT", "MDT": "MDT", "WART": "WART", "WAST": "WAST", "HKT": "HKT", "AKST": "AKST", "HEPM": "HEPM", "HENOMX": "HENOMX", "MESZ": "MESZ", "WIT": "WIT", "EAT": "EAT", "HNT": "HNT", "HKST": "HKST", "SGT": "SGT", "GMT": "GMT", "BT": "BT", "HAST": "HAST", "LHST": "LHST", "IST": "IST", "HEOG": "HEOG", "ECT": "ECT", "ChST": "ChST", "CST": "CST", "MST": "MST", "SAST": "SAST", "COT": "COT", "HNOG": "HNOG", "HAT": "HAT", "HEPMX": "HEPMX", "UYST": "UYST", "TMT": "TMT", "LHDT": "LHDT"},
74 // Locale returns the current translators string locale
75 func (om *om_ET) Locale() string {
79 // PluralsCardinal returns the list of cardinal plural rules associated with 'om_ET'
80 func (om *om_ET) PluralsCardinal() []locales.PluralRule {
81 return om.pluralsCardinal
84 // PluralsOrdinal returns the list of ordinal plural rules associated with 'om_ET'
85 func (om *om_ET) PluralsOrdinal() []locales.PluralRule {
86 return om.pluralsOrdinal
89 // PluralsRange returns the list of range plural rules associated with 'om_ET'
90 func (om *om_ET) PluralsRange() []locales.PluralRule {
91 return om.pluralsRange
94 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'om_ET'
95 func (om *om_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleOne
103 return locales.PluralRuleOther
106 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'om_ET'
107 func (om *om_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
108 return locales.PluralRuleUnknown
111 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'om_ET'
112 func (om *om_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
113 return locales.PluralRuleUnknown
116 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
117 func (om *om_ET) MonthAbbreviated(month time.Month) string {
118 return om.monthsAbbreviated[month]
121 // MonthsAbbreviated returns the locales abbreviated months
122 func (om *om_ET) MonthsAbbreviated() []string {
123 return om.monthsAbbreviated[1:]
126 // MonthNarrow returns the locales narrow month given the 'month' provided
127 func (om *om_ET) MonthNarrow(month time.Month) string {
128 return om.monthsNarrow[month]
131 // MonthsNarrow returns the locales narrow months
132 func (om *om_ET) MonthsNarrow() []string {
133 return om.monthsNarrow[1:]
136 // MonthWide returns the locales wide month given the 'month' provided
137 func (om *om_ET) MonthWide(month time.Month) string {
138 return om.monthsWide[month]
141 // MonthsWide returns the locales wide months
142 func (om *om_ET) MonthsWide() []string {
143 return om.monthsWide[1:]
146 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
147 func (om *om_ET) WeekdayAbbreviated(weekday time.Weekday) string {
148 return om.daysAbbreviated[weekday]
151 // WeekdaysAbbreviated returns the locales abbreviated weekdays
152 func (om *om_ET) WeekdaysAbbreviated() []string {
153 return om.daysAbbreviated
156 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
157 func (om *om_ET) WeekdayNarrow(weekday time.Weekday) string {
158 return om.daysNarrow[weekday]
161 // WeekdaysNarrow returns the locales narrow weekdays
162 func (om *om_ET) WeekdaysNarrow() []string {
166 // WeekdayShort returns the locales short weekday given the 'weekday' provided
167 func (om *om_ET) WeekdayShort(weekday time.Weekday) string {
168 return om.daysShort[weekday]
171 // WeekdaysShort returns the locales short weekdays
172 func (om *om_ET) WeekdaysShort() []string {
176 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
177 func (om *om_ET) WeekdayWide(weekday time.Weekday) string {
178 return om.daysWide[weekday]
181 // WeekdaysWide returns the locales wide weekdays
182 func (om *om_ET) WeekdaysWide() []string {
186 // Decimal returns the decimal point of number
187 func (om *om_ET) Decimal() string {
191 // Group returns the group of number
192 func (om *om_ET) Group() string {
196 // Group returns the minus sign of number
197 func (om *om_ET) Minus() string {
201 // FmtNumber returns 'num' with digits/precision of 'v' for 'om_ET' and handles both Whole and Real numbers based on 'v'
202 func (om *om_ET) FmtNumber(num float64, v uint64) string {
204 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
208 b := make([]byte, 0, l)
210 for i := len(s) - 1; i >= 0; i-- {
213 b = append(b, om.decimal[0])
220 b = append(b, om.group[0])
231 b = append(b, om.minus[0])
235 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
236 b[i], b[j] = b[j], b[i]
242 // FmtPercent returns 'num' with digits/precision of 'v' for 'om_ET' and handles both Whole and Real numbers based on 'v'
243 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
244 func (om *om_ET) FmtPercent(num float64, v uint64) string {
245 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
247 b := make([]byte, 0, l)
249 for i := len(s) - 1; i >= 0; i-- {
252 b = append(b, om.decimal[0])
260 b = append(b, om.minus[0])
264 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
265 b[i], b[j] = b[j], b[i]
268 b = append(b, om.percent...)
273 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'om_ET'
274 func (om *om_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string {
276 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
277 symbol := om.currencies[currency]
278 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
281 b := make([]byte, 0, l)
283 for i := len(s) - 1; i >= 0; i-- {
286 b = append(b, om.decimal[0])
293 b = append(b, om.group[0])
303 for j := len(symbol) - 1; j >= 0; j-- {
304 b = append(b, symbol[j])
308 b = append(b, om.minus[0])
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
319 b = append(b, om.decimal...)
322 for i := 0; i < 2-int(v); i++ {
330 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'om_ET'
331 // in accounting notation.
332 func (om *om_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string {
334 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
335 symbol := om.currencies[currency]
336 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
339 b := make([]byte, 0, l)
341 for i := len(s) - 1; i >= 0; i-- {
344 b = append(b, om.decimal[0])
351 b = append(b, om.group[0])
363 for j := len(symbol) - 1; j >= 0; j-- {
364 b = append(b, symbol[j])
367 b = append(b, om.minus[0])
371 for j := len(symbol) - 1; j >= 0; j-- {
372 b = append(b, symbol[j])
378 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
379 b[i], b[j] = b[j], b[i]
385 b = append(b, om.decimal...)
388 for i := 0; i < 2-int(v); i++ {
396 // FmtDateShort returns the short date representation of 't' for 'om_ET'
397 func (om *om_ET) FmtDateShort(t time.Time) string {
399 b := make([]byte, 0, 32)
405 b = strconv.AppendInt(b, int64(t.Day()), 10)
406 b = append(b, []byte{0x2f}...)
412 b = strconv.AppendInt(b, int64(t.Month()), 10)
414 b = append(b, []byte{0x2f}...)
417 b = append(b, strconv.Itoa(t.Year())[2:]...)
419 b = append(b, strconv.Itoa(t.Year())[1:]...)
425 // FmtDateMedium returns the medium date representation of 't' for 'om_ET'
426 func (om *om_ET) FmtDateMedium(t time.Time) string {
428 b := make([]byte, 0, 32)
434 b = strconv.AppendInt(b, int64(t.Day()), 10)
435 b = append(b, []byte{0x2d}...)
436 b = append(b, om.monthsAbbreviated[t.Month()]...)
437 b = append(b, []byte{0x2d}...)
440 b = strconv.AppendInt(b, int64(t.Year()), 10)
442 b = strconv.AppendInt(b, int64(-t.Year()), 10)
448 // FmtDateLong returns the long date representation of 't' for 'om_ET'
449 func (om *om_ET) FmtDateLong(t time.Time) string {
451 b := make([]byte, 0, 32)
457 b = strconv.AppendInt(b, int64(t.Day()), 10)
458 b = append(b, []byte{0x20}...)
459 b = append(b, om.monthsWide[t.Month()]...)
460 b = append(b, []byte{0x20}...)
463 b = strconv.AppendInt(b, int64(t.Year()), 10)
465 b = strconv.AppendInt(b, int64(-t.Year()), 10)
471 // FmtDateFull returns the full date representation of 't' for 'om_ET'
472 func (om *om_ET) FmtDateFull(t time.Time) string {
474 b := make([]byte, 0, 32)
476 b = append(b, om.daysWide[t.Weekday()]...)
477 b = append(b, []byte{0x2c, 0x20}...)
478 b = append(b, om.monthsWide[t.Month()]...)
479 b = append(b, []byte{0x20}...)
480 b = strconv.AppendInt(b, int64(t.Day()), 10)
481 b = append(b, []byte{0x2c, 0x20}...)
484 b = strconv.AppendInt(b, int64(t.Year()), 10)
486 b = strconv.AppendInt(b, int64(-t.Year()), 10)
492 // FmtTimeShort returns the short time representation of 't' for 'om_ET'
493 func (om *om_ET) FmtTimeShort(t time.Time) string {
495 b := make([]byte, 0, 32)
503 b = strconv.AppendInt(b, int64(h), 10)
504 b = append(b, om.timeSeparator...)
510 b = strconv.AppendInt(b, int64(t.Minute()), 10)
511 b = append(b, []byte{0x20}...)
514 b = append(b, om.periodsAbbreviated[0]...)
516 b = append(b, om.periodsAbbreviated[1]...)
522 // FmtTimeMedium returns the medium time representation of 't' for 'om_ET'
523 func (om *om_ET) FmtTimeMedium(t time.Time) string {
525 b := make([]byte, 0, 32)
533 b = strconv.AppendInt(b, int64(h), 10)
534 b = append(b, om.timeSeparator...)
540 b = strconv.AppendInt(b, int64(t.Minute()), 10)
541 b = append(b, om.timeSeparator...)
547 b = strconv.AppendInt(b, int64(t.Second()), 10)
548 b = append(b, []byte{0x20}...)
551 b = append(b, om.periodsAbbreviated[0]...)
553 b = append(b, om.periodsAbbreviated[1]...)
559 // FmtTimeLong returns the long time representation of 't' for 'om_ET'
560 func (om *om_ET) FmtTimeLong(t time.Time) string {
562 b := make([]byte, 0, 32)
570 b = strconv.AppendInt(b, int64(h), 10)
571 b = append(b, om.timeSeparator...)
577 b = strconv.AppendInt(b, int64(t.Minute()), 10)
578 b = append(b, om.timeSeparator...)
584 b = strconv.AppendInt(b, int64(t.Second()), 10)
585 b = append(b, []byte{0x20}...)
588 b = append(b, om.periodsAbbreviated[0]...)
590 b = append(b, om.periodsAbbreviated[1]...)
593 b = append(b, []byte{0x20}...)
601 // FmtTimeFull returns the full time representation of 't' for 'om_ET'
602 func (om *om_ET) FmtTimeFull(t time.Time) string {
604 b := make([]byte, 0, 32)
612 b = strconv.AppendInt(b, int64(h), 10)
613 b = append(b, om.timeSeparator...)
619 b = strconv.AppendInt(b, int64(t.Minute()), 10)
620 b = append(b, om.timeSeparator...)
626 b = strconv.AppendInt(b, int64(t.Second()), 10)
627 b = append(b, []byte{0x20}...)
630 b = append(b, om.periodsAbbreviated[0]...)
632 b = append(b, om.periodsAbbreviated[1]...)
635 b = append(b, []byte{0x20}...)
639 if btz, ok := om.timezones[tz]; ok {
640 b = append(b, btz...)