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 'gv_IM' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6},
50 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"},
51 monthsAbbreviated: []string{"", "J-guer", "T-arree", "Mayrnt", "Avrril", "Boaldyn", "M-souree", "J-souree", "Luanistyn", "M-fouyir", "J-fouyir", "M-Houney", "M-Nollick"},
52 monthsWide: []string{"", "Jerrey-geuree", "Toshiaght-arree", "Mayrnt", "Averil", "Boaldyn", "Mean-souree", "Jerrey-souree", "Luanistyn", "Mean-fouyir", "Jerrey-fouyir", "Mee Houney", "Mee ny Nollick"},
53 daysAbbreviated: []string{"Jed", "Jel", "Jem", "Jerc", "Jerd", "Jeh", "Jes"},
54 daysWide: []string{"Jedoonee", "Jelhein", "Jemayrt", "Jercean", "Jerdein", "Jeheiney", "Jesarn"},
55 periodsAbbreviated: []string{"a.m.", "p.m."},
56 periodsWide: []string{"a.m.", "p.m."},
57 erasAbbreviated: []string{"RC", "AD"},
58 erasNarrow: []string{"", ""},
59 erasWide: []string{"", ""},
60 timezones: map[string]string{"MST": "MST", "LHDT": "LHDT", "HEOG": "HEOG", "PDT": "PDT", "CST": "CST", "GYT": "GYT", "HECU": "HECU", "BOT": "BOT", "MDT": "MDT", "OEZ": "OEZ", "ADT": "ADT", "WAT": "WAT", "SAST": "SAST", "HEPM": "HEPM", "TMT": "TMT", "ACST": "ACST", "CHAST": "CHAST", "AWDT": "AWDT", "ART": "ART", "AEDT": "AEDT", "HNEG": "HNEG", "HKT": "HKT", "HKST": "HKST", "UYST": "UYST", "WITA": "WITA", "WAST": "WAST", "CAT": "CAT", "ACWDT": "ACWDT", "NZDT": "NZDT", "TMST": "TMST", "JST": "JST", "CLST": "CLST", "SGT": "SGT", "CHADT": "CHADT", "UYT": "UYT", "HEPMX": "HEPMX", "OESZ": "OESZ", "HNOG": "HNOG", "AKDT": "AKDT", "ACDT": "ACDT", "WESZ": "WESZ", "AEST": "AEST", "EST": "EST", "BT": "BT", "WIT": "WIT", "ACWST": "ACWST", "LHST": "LHST", "CLT": "CLT", "GFT": "GFT", "EDT": "EDT", "HAST": "HAST", "HNPMX": "HNPMX", "HNPM": "HNPM", "SRT": "SRT", "HADT": "HADT", "WARST": "WARST", "WEZ": "WEZ", "GMT": "GMT", "HNCU": "HNCU", "ChST": "ChST", "AWST": "AWST", "VET": "VET", "ARST": "ARST", "EAT": "EAT", "COT": "COT", "HNT": "HNT", "MYT": "MYT", "NZST": "NZST", "MEZ": "MEZ", "PST": "PST", "MESZ": "MESZ", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "AST": "AST", "HEEG": "HEEG", "ECT": "ECT", "CDT": "CDT", "HNNOMX": "HNNOMX", "IST": "IST", "COST": "COST", "HAT": "HAT", "WIB": "WIB", "WART": "WART", "JDT": "JDT", "AKST": "AKST"},
64 // Locale returns the current translators string locale
65 func (gv *gv_IM) Locale() string {
69 // PluralsCardinal returns the list of cardinal plural rules associated with 'gv_IM'
70 func (gv *gv_IM) PluralsCardinal() []locales.PluralRule {
71 return gv.pluralsCardinal
74 // PluralsOrdinal returns the list of ordinal plural rules associated with 'gv_IM'
75 func (gv *gv_IM) PluralsOrdinal() []locales.PluralRule {
76 return gv.pluralsOrdinal
79 // PluralsRange returns the list of range plural rules associated with 'gv_IM'
80 func (gv *gv_IM) PluralsRange() []locales.PluralRule {
81 return gv.pluralsRange
84 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gv_IM'
85 func (gv *gv_IM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
92 if v == 0 && iMod10 == 1 {
93 return locales.PluralRuleOne
94 } else if v == 0 && iMod10 == 2 {
95 return locales.PluralRuleTwo
96 } else if v == 0 && (iMod100 == 0 || iMod100 == 20 || iMod100 == 40 || iMod100 == 60 || iMod100 == 80) {
97 return locales.PluralRuleFew
99 return locales.PluralRuleMany
102 return locales.PluralRuleOther
105 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gv_IM'
106 func (gv *gv_IM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
107 return locales.PluralRuleUnknown
110 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gv_IM'
111 func (gv *gv_IM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
112 return locales.PluralRuleUnknown
115 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
116 func (gv *gv_IM) MonthAbbreviated(month time.Month) string {
117 return gv.monthsAbbreviated[month]
120 // MonthsAbbreviated returns the locales abbreviated months
121 func (gv *gv_IM) MonthsAbbreviated() []string {
122 return gv.monthsAbbreviated[1:]
125 // MonthNarrow returns the locales narrow month given the 'month' provided
126 func (gv *gv_IM) MonthNarrow(month time.Month) string {
127 return gv.monthsNarrow[month]
130 // MonthsNarrow returns the locales narrow months
131 func (gv *gv_IM) MonthsNarrow() []string {
135 // MonthWide returns the locales wide month given the 'month' provided
136 func (gv *gv_IM) MonthWide(month time.Month) string {
137 return gv.monthsWide[month]
140 // MonthsWide returns the locales wide months
141 func (gv *gv_IM) MonthsWide() []string {
142 return gv.monthsWide[1:]
145 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
146 func (gv *gv_IM) WeekdayAbbreviated(weekday time.Weekday) string {
147 return gv.daysAbbreviated[weekday]
150 // WeekdaysAbbreviated returns the locales abbreviated weekdays
151 func (gv *gv_IM) WeekdaysAbbreviated() []string {
152 return gv.daysAbbreviated
155 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
156 func (gv *gv_IM) WeekdayNarrow(weekday time.Weekday) string {
157 return gv.daysNarrow[weekday]
160 // WeekdaysNarrow returns the locales narrow weekdays
161 func (gv *gv_IM) WeekdaysNarrow() []string {
165 // WeekdayShort returns the locales short weekday given the 'weekday' provided
166 func (gv *gv_IM) WeekdayShort(weekday time.Weekday) string {
167 return gv.daysShort[weekday]
170 // WeekdaysShort returns the locales short weekdays
171 func (gv *gv_IM) WeekdaysShort() []string {
175 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
176 func (gv *gv_IM) WeekdayWide(weekday time.Weekday) string {
177 return gv.daysWide[weekday]
180 // WeekdaysWide returns the locales wide weekdays
181 func (gv *gv_IM) WeekdaysWide() []string {
185 // Decimal returns the decimal point of number
186 func (gv *gv_IM) Decimal() string {
190 // Group returns the group of number
191 func (gv *gv_IM) Group() string {
195 // Group returns the minus sign of number
196 func (gv *gv_IM) Minus() string {
200 // FmtNumber returns 'num' with digits/precision of 'v' for 'gv_IM' and handles both Whole and Real numbers based on 'v'
201 func (gv *gv_IM) FmtNumber(num float64, v uint64) string {
203 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
206 // FmtPercent returns 'num' with digits/precision of 'v' for 'gv_IM' and handles both Whole and Real numbers based on 'v'
207 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
208 func (gv *gv_IM) FmtPercent(num float64, v uint64) string {
209 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
212 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gv_IM'
213 func (gv *gv_IM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
215 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
216 symbol := gv.currencies[currency]
217 l := len(s) + len(symbol) + 0
220 b := make([]byte, 0, l)
222 for i := len(s) - 1; i >= 0; i-- {
225 b = append(b, gv.decimal[0])
232 b = append(b, gv.group[0])
242 for j := len(symbol) - 1; j >= 0; j-- {
243 b = append(b, symbol[j])
247 b = append(b, gv.minus[0])
251 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
252 b[i], b[j] = b[j], b[i]
258 b = append(b, gv.decimal...)
261 for i := 0; i < 2-int(v); i++ {
269 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gv_IM'
270 // in accounting notation.
271 func (gv *gv_IM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
273 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
274 symbol := gv.currencies[currency]
275 l := len(s) + len(symbol) + 0
278 b := make([]byte, 0, l)
280 for i := len(s) - 1; i >= 0; i-- {
283 b = append(b, gv.decimal[0])
290 b = append(b, gv.group[0])
302 for j := len(symbol) - 1; j >= 0; j-- {
303 b = append(b, symbol[j])
306 b = append(b, gv.minus[0])
310 for j := len(symbol) - 1; j >= 0; j-- {
311 b = append(b, symbol[j])
317 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
318 b[i], b[j] = b[j], b[i]
324 b = append(b, gv.decimal...)
327 for i := 0; i < 2-int(v); i++ {
335 // FmtDateShort returns the short date representation of 't' for 'gv_IM'
336 func (gv *gv_IM) FmtDateShort(t time.Time) string {
338 b := make([]byte, 0, 32)
344 b = strconv.AppendInt(b, int64(t.Day()), 10)
345 b = append(b, []byte{0x2f}...)
351 b = strconv.AppendInt(b, int64(t.Month()), 10)
353 b = append(b, []byte{0x2f}...)
356 b = append(b, strconv.Itoa(t.Year())[2:]...)
358 b = append(b, strconv.Itoa(t.Year())[1:]...)
364 // FmtDateMedium returns the medium date representation of 't' for 'gv_IM'
365 func (gv *gv_IM) FmtDateMedium(t time.Time) string {
367 b := make([]byte, 0, 32)
369 b = append(b, gv.monthsAbbreviated[t.Month()]...)
370 b = append(b, []byte{0x20}...)
376 b = strconv.AppendInt(b, int64(t.Day()), 10)
377 b = append(b, []byte{0x2c, 0x20}...)
380 b = strconv.AppendInt(b, int64(t.Year()), 10)
382 b = strconv.AppendInt(b, int64(-t.Year()), 10)
388 // FmtDateLong returns the long date representation of 't' for 'gv_IM'
389 func (gv *gv_IM) FmtDateLong(t time.Time) string {
391 b := make([]byte, 0, 32)
397 b = strconv.AppendInt(b, int64(t.Day()), 10)
398 b = append(b, []byte{0x20}...)
399 b = append(b, gv.monthsWide[t.Month()]...)
400 b = append(b, []byte{0x20}...)
403 b = strconv.AppendInt(b, int64(t.Year()), 10)
405 b = strconv.AppendInt(b, int64(-t.Year()), 10)
411 // FmtDateFull returns the full date representation of 't' for 'gv_IM'
412 func (gv *gv_IM) FmtDateFull(t time.Time) string {
414 b := make([]byte, 0, 32)
416 b = append(b, gv.daysWide[t.Weekday()]...)
417 b = append(b, []byte{0x20}...)
423 b = strconv.AppendInt(b, int64(t.Day()), 10)
424 b = append(b, []byte{0x20}...)
425 b = append(b, gv.monthsWide[t.Month()]...)
426 b = append(b, []byte{0x20}...)
429 b = strconv.AppendInt(b, int64(t.Year()), 10)
431 b = strconv.AppendInt(b, int64(-t.Year()), 10)
437 // FmtTimeShort returns the short time representation of 't' for 'gv_IM'
438 func (gv *gv_IM) FmtTimeShort(t time.Time) string {
440 b := make([]byte, 0, 32)
446 b = strconv.AppendInt(b, int64(t.Hour()), 10)
447 b = append(b, gv.timeSeparator...)
453 b = strconv.AppendInt(b, int64(t.Minute()), 10)
458 // FmtTimeMedium returns the medium time representation of 't' for 'gv_IM'
459 func (gv *gv_IM) FmtTimeMedium(t time.Time) string {
461 b := make([]byte, 0, 32)
467 b = strconv.AppendInt(b, int64(t.Hour()), 10)
468 b = append(b, gv.timeSeparator...)
474 b = strconv.AppendInt(b, int64(t.Minute()), 10)
475 b = append(b, gv.timeSeparator...)
481 b = strconv.AppendInt(b, int64(t.Second()), 10)
486 // FmtTimeLong returns the long time representation of 't' for 'gv_IM'
487 func (gv *gv_IM) FmtTimeLong(t time.Time) string {
489 b := make([]byte, 0, 32)
495 b = strconv.AppendInt(b, int64(t.Hour()), 10)
496 b = append(b, gv.timeSeparator...)
502 b = strconv.AppendInt(b, int64(t.Minute()), 10)
503 b = append(b, gv.timeSeparator...)
509 b = strconv.AppendInt(b, int64(t.Second()), 10)
510 b = append(b, []byte{0x20}...)
518 // FmtTimeFull returns the full time representation of 't' for 'gv_IM'
519 func (gv *gv_IM) FmtTimeFull(t time.Time) string {
521 b := make([]byte, 0, 32)
527 b = strconv.AppendInt(b, int64(t.Hour()), 10)
528 b = append(b, gv.timeSeparator...)
534 b = strconv.AppendInt(b, int64(t.Minute()), 10)
535 b = append(b, gv.timeSeparator...)
541 b = strconv.AppendInt(b, int64(t.Second()), 10)
542 b = append(b, []byte{0x20}...)
546 if btz, ok := gv.timezones[tz]; ok {
547 b = append(b, btz...)