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 'rw_RW' locale
45 func New() locales.Translator {
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{"", "mut.", "gas.", "wer.", "mat.", "gic.", "kam.", "nya.", "kan.", "nze.", "ukw.", "ugu.", "uku."},
62 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
63 monthsWide: []string{"", "Mutarama", "Gashyantare", "Werurwe", "Mata", "Gicuransi", "Kamena", "Nyakanga", "Kanama", "Nzeli", "Ukwakira", "Ugushyingo", "Ukuboza"},
64 daysAbbreviated: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."},
65 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
66 daysShort: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."},
67 daysWide: []string{"Ku cyumweru", "Kuwa mbere", "Kuwa kabiri", "Kuwa gatatu", "Kuwa kane", "Kuwa gatanu", "Kuwa gatandatu"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsNarrow: []string{"AM", "PM"},
70 periodsWide: []string{"AM", "PM"},
71 erasAbbreviated: []string{"BCE", "CE"},
72 erasNarrow: []string{"", ""},
73 erasWide: []string{"BCE", "CE"},
74 timezones: map[string]string{"COST": "COST", "EST": "EST", "ACDT": "ACDT", "CAT": "CAT", "WEZ": "WEZ", "HNPM": "HNPM", "ADT": "ADT", "ART": "ART", "OESZ": "OESZ", "HNT": "HNT", "HECU": "HECU", "TMST": "TMST", "SAST": "SAST", "COT": "COT", "∅∅∅": "∅∅∅", "EAT": "EAT", "MESZ": "MESZ", "HADT": "HADT", "TMT": "TMT", "JST": "JST", "OEZ": "OEZ", "VET": "VET", "ACWDT": "ACWDT", "MYT": "MYT", "ECT": "ECT", "GMT": "GMT", "PST": "PST", "CHADT": "CHADT", "BOT": "BOT", "HNEG": "HNEG", "AKDT": "AKDT", "PDT": "PDT", "HNOG": "HNOG", "GYT": "GYT", "LHDT": "LHDT", "HAT": "HAT", "EDT": "EDT", "UYT": "UYT", "NZDT": "NZDT", "WART": "WART", "WARST": "WARST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "AST": "AST", "WAT": "WAT", "MEZ": "MEZ", "HAST": "HAST", "AKST": "AKST", "HEOG": "HEOG", "HKST": "HKST", "CLST": "CLST", "WESZ": "WESZ", "UYST": "UYST", "JDT": "JDT", "SRT": "SRT", "ACWST": "ACWST", "WIT": "WIT", "CLT": "CLT", "HNPMX": "HNPMX", "MST": "MST", "AWST": "AWST", "AEDT": "AEDT", "WAST": "WAST", "CHAST": "CHAST", "HNCU": "HNCU", "LHST": "LHST", "AEST": "AEST", "HKT": "HKT", "HEPMX": "HEPMX", "IST": "IST", "GFT": "GFT", "SGT": "SGT", "WIB": "WIB", "BT": "BT", "CDT": "CDT", "WITA": "WITA", "ACST": "ACST", "AWDT": "AWDT", "NZST": "NZST", "ARST": "ARST", "HEEG": "HEEG", "ChST": "ChST", "HEPM": "HEPM", "CST": "CST", "MDT": "MDT"},
78 // Locale returns the current translators string locale
79 func (rw *rw_RW) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'rw_RW'
84 func (rw *rw_RW) PluralsCardinal() []locales.PluralRule {
85 return rw.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'rw_RW'
89 func (rw *rw_RW) PluralsOrdinal() []locales.PluralRule {
90 return rw.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'rw_RW'
94 func (rw *rw_RW) PluralsRange() []locales.PluralRule {
95 return rw.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rw_RW'
99 func (rw *rw_RW) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
103 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rw_RW'
104 func (rw *rw_RW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105 return locales.PluralRuleUnknown
108 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rw_RW'
109 func (rw *rw_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
110 return locales.PluralRuleUnknown
113 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
114 func (rw *rw_RW) MonthAbbreviated(month time.Month) string {
115 return rw.monthsAbbreviated[month]
118 // MonthsAbbreviated returns the locales abbreviated months
119 func (rw *rw_RW) MonthsAbbreviated() []string {
120 return rw.monthsAbbreviated[1:]
123 // MonthNarrow returns the locales narrow month given the 'month' provided
124 func (rw *rw_RW) MonthNarrow(month time.Month) string {
125 return rw.monthsNarrow[month]
128 // MonthsNarrow returns the locales narrow months
129 func (rw *rw_RW) MonthsNarrow() []string {
130 return rw.monthsNarrow[1:]
133 // MonthWide returns the locales wide month given the 'month' provided
134 func (rw *rw_RW) MonthWide(month time.Month) string {
135 return rw.monthsWide[month]
138 // MonthsWide returns the locales wide months
139 func (rw *rw_RW) MonthsWide() []string {
140 return rw.monthsWide[1:]
143 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
144 func (rw *rw_RW) WeekdayAbbreviated(weekday time.Weekday) string {
145 return rw.daysAbbreviated[weekday]
148 // WeekdaysAbbreviated returns the locales abbreviated weekdays
149 func (rw *rw_RW) WeekdaysAbbreviated() []string {
150 return rw.daysAbbreviated
153 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
154 func (rw *rw_RW) WeekdayNarrow(weekday time.Weekday) string {
155 return rw.daysNarrow[weekday]
158 // WeekdaysNarrow returns the locales narrow weekdays
159 func (rw *rw_RW) WeekdaysNarrow() []string {
163 // WeekdayShort returns the locales short weekday given the 'weekday' provided
164 func (rw *rw_RW) WeekdayShort(weekday time.Weekday) string {
165 return rw.daysShort[weekday]
168 // WeekdaysShort returns the locales short weekdays
169 func (rw *rw_RW) WeekdaysShort() []string {
173 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
174 func (rw *rw_RW) WeekdayWide(weekday time.Weekday) string {
175 return rw.daysWide[weekday]
178 // WeekdaysWide returns the locales wide weekdays
179 func (rw *rw_RW) WeekdaysWide() []string {
183 // Decimal returns the decimal point of number
184 func (rw *rw_RW) Decimal() string {
188 // Group returns the group of number
189 func (rw *rw_RW) Group() string {
193 // Group returns the minus sign of number
194 func (rw *rw_RW) Minus() string {
198 // FmtNumber returns 'num' with digits/precision of 'v' for 'rw_RW' and handles both Whole and Real numbers based on 'v'
199 func (rw *rw_RW) FmtNumber(num float64, v uint64) string {
201 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
205 b := make([]byte, 0, l)
207 for i := len(s) - 1; i >= 0; i-- {
210 b = append(b, rw.decimal[0])
217 b = append(b, rw.group[0])
228 b = append(b, rw.minus[0])
232 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
233 b[i], b[j] = b[j], b[i]
239 // FmtPercent returns 'num' with digits/precision of 'v' for 'rw_RW' and handles both Whole and Real numbers based on 'v'
240 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
241 func (rw *rw_RW) FmtPercent(num float64, v uint64) string {
242 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
244 b := make([]byte, 0, l)
246 for i := len(s) - 1; i >= 0; i-- {
249 b = append(b, rw.decimal[0])
257 b = append(b, rw.minus[0])
261 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
262 b[i], b[j] = b[j], b[i]
265 b = append(b, rw.percent...)
270 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rw_RW'
271 func (rw *rw_RW) FmtCurrency(num float64, v uint64, currency currency.Type) string {
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := rw.currencies[currency]
275 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
278 b := make([]byte, 0, l)
280 for i := len(s) - 1; i >= 0; i-- {
283 b = append(b, rw.decimal[0])
290 b = append(b, rw.group[0])
300 for j := len(symbol) - 1; j >= 0; j-- {
301 b = append(b, symbol[j])
304 for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- {
305 b = append(b, rw.currencyPositivePrefix[j])
309 b = append(b, rw.minus[0])
313 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
314 b[i], b[j] = b[j], b[i]
320 b = append(b, rw.decimal...)
323 for i := 0; i < 2-int(v); i++ {
331 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rw_RW'
332 // in accounting notation.
333 func (rw *rw_RW) FmtAccounting(num float64, v uint64, currency currency.Type) string {
335 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
336 symbol := rw.currencies[currency]
337 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
340 b := make([]byte, 0, l)
342 for i := len(s) - 1; i >= 0; i-- {
345 b = append(b, rw.decimal[0])
352 b = append(b, rw.group[0])
364 for j := len(symbol) - 1; j >= 0; j-- {
365 b = append(b, symbol[j])
368 for j := len(rw.currencyNegativePrefix) - 1; j >= 0; j-- {
369 b = append(b, rw.currencyNegativePrefix[j])
372 b = append(b, rw.minus[0])
376 for j := len(symbol) - 1; j >= 0; j-- {
377 b = append(b, symbol[j])
380 for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- {
381 b = append(b, rw.currencyPositivePrefix[j])
387 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
388 b[i], b[j] = b[j], b[i]
394 b = append(b, rw.decimal...)
397 for i := 0; i < 2-int(v); i++ {
405 // FmtDateShort returns the short date representation of 't' for 'rw_RW'
406 func (rw *rw_RW) FmtDateShort(t time.Time) string {
408 b := make([]byte, 0, 32)
411 b = strconv.AppendInt(b, int64(t.Year()), 10)
413 b = strconv.AppendInt(b, int64(-t.Year()), 10)
416 b = append(b, []byte{0x2d}...)
422 b = strconv.AppendInt(b, int64(t.Month()), 10)
424 b = append(b, []byte{0x2d}...)
430 b = strconv.AppendInt(b, int64(t.Day()), 10)
435 // FmtDateMedium returns the medium date representation of 't' for 'rw_RW'
436 func (rw *rw_RW) FmtDateMedium(t time.Time) string {
438 b := make([]byte, 0, 32)
441 b = strconv.AppendInt(b, int64(t.Year()), 10)
443 b = strconv.AppendInt(b, int64(-t.Year()), 10)
446 b = append(b, []byte{0x20}...)
447 b = append(b, rw.monthsAbbreviated[t.Month()]...)
448 b = append(b, []byte{0x20}...)
449 b = strconv.AppendInt(b, int64(t.Day()), 10)
454 // FmtDateLong returns the long date representation of 't' for 'rw_RW'
455 func (rw *rw_RW) FmtDateLong(t time.Time) string {
457 b := make([]byte, 0, 32)
460 b = strconv.AppendInt(b, int64(t.Year()), 10)
462 b = strconv.AppendInt(b, int64(-t.Year()), 10)
465 b = append(b, []byte{0x20}...)
466 b = append(b, rw.monthsWide[t.Month()]...)
467 b = append(b, []byte{0x20}...)
468 b = strconv.AppendInt(b, int64(t.Day()), 10)
473 // FmtDateFull returns the full date representation of 't' for 'rw_RW'
474 func (rw *rw_RW) FmtDateFull(t time.Time) string {
476 b := make([]byte, 0, 32)
479 b = strconv.AppendInt(b, int64(t.Year()), 10)
481 b = strconv.AppendInt(b, int64(-t.Year()), 10)
484 b = append(b, []byte{0x20}...)
485 b = append(b, rw.monthsWide[t.Month()]...)
486 b = append(b, []byte{0x20}...)
487 b = strconv.AppendInt(b, int64(t.Day()), 10)
488 b = append(b, []byte{0x2c, 0x20}...)
489 b = append(b, rw.daysWide[t.Weekday()]...)
494 // FmtTimeShort returns the short time representation of 't' for 'rw_RW'
495 func (rw *rw_RW) FmtTimeShort(t time.Time) string {
497 b := make([]byte, 0, 32)
503 b = strconv.AppendInt(b, int64(t.Hour()), 10)
504 b = append(b, rw.timeSeparator...)
510 b = strconv.AppendInt(b, int64(t.Minute()), 10)
515 // FmtTimeMedium returns the medium time representation of 't' for 'rw_RW'
516 func (rw *rw_RW) FmtTimeMedium(t time.Time) string {
518 b := make([]byte, 0, 32)
524 b = strconv.AppendInt(b, int64(t.Hour()), 10)
525 b = append(b, rw.timeSeparator...)
531 b = strconv.AppendInt(b, int64(t.Minute()), 10)
532 b = append(b, rw.timeSeparator...)
538 b = strconv.AppendInt(b, int64(t.Second()), 10)
543 // FmtTimeLong returns the long time representation of 't' for 'rw_RW'
544 func (rw *rw_RW) FmtTimeLong(t time.Time) string {
546 b := make([]byte, 0, 32)
552 b = strconv.AppendInt(b, int64(t.Hour()), 10)
553 b = append(b, rw.timeSeparator...)
559 b = strconv.AppendInt(b, int64(t.Minute()), 10)
560 b = append(b, rw.timeSeparator...)
566 b = strconv.AppendInt(b, int64(t.Second()), 10)
567 b = append(b, []byte{0x20}...)
575 // FmtTimeFull returns the full time representation of 't' for 'rw_RW'
576 func (rw *rw_RW) FmtTimeFull(t time.Time) string {
578 b := make([]byte, 0, 32)
584 b = strconv.AppendInt(b, int64(t.Hour()), 10)
585 b = append(b, rw.timeSeparator...)
591 b = strconv.AppendInt(b, int64(t.Minute()), 10)
592 b = append(b, rw.timeSeparator...)
598 b = strconv.AppendInt(b, int64(t.Second()), 10)
599 b = append(b, []byte{0x20}...)
603 if btz, ok := rw.timezones[tz]; ok {
604 b = append(b, btz...)