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
25 currencies []string // idx = enum of currency code
26 currencyPositiveSuffix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
31 daysAbbreviated []string
35 periodsAbbreviated []string
36 periodsNarrow []string
39 erasAbbreviated []string
42 timezones map[string]string
45 // New returns a new instance of translator for the 'gl_ES' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{6},
51 pluralsRange: []locales.PluralRule{2, 6},
59 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"},
61 currencyPositiveSuffix: " ",
62 currencyNegativeSuffix: " ",
63 monthsAbbreviated: []string{"", "xan.", "feb.", "mar.", "abr.", "maio", "xuño", "xul.", "ago.", "set.", "out.", "nov.", "dec."},
64 monthsNarrow: []string{"", "x.", "f.", "m.", "a.", "m.", "x.", "x.", "a.", "s.", "o.", "n.", "d."},
65 monthsWide: []string{"", "xaneiro", "febreiro", "marzo", "abril", "maio", "xuño", "xullo", "agosto", "setembro", "outubro", "novembro", "decembro"},
66 daysAbbreviated: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."},
67 daysNarrow: []string{"d.", "l.", "m.", "m.", "x.", "v.", "s."},
68 daysShort: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."},
69 daysWide: []string{"domingo", "luns", "martes", "mércores", "xoves", "venres", "sábado"},
70 periodsAbbreviated: []string{"a.m.", "p.m."},
71 periodsNarrow: []string{"a.m.", "p.m."},
72 periodsWide: []string{"a.m.", "p.m."},
73 erasAbbreviated: []string{"a.C.", "d.C."},
74 erasNarrow: []string{"", ""},
75 erasWide: []string{"antes de Cristo", "despois de Cristo"},
76 timezones: map[string]string{"HNPMX": "Horario estándar do Pacífico mexicano", "AEDT": "Horario de verán de Australia Oriental", "CAT": "Horario de África Central", "ACDT": "Horario de verán de Australia Central", "CHADT": "Horario de verán de Chatham", "UYST": "Horario de verán de Uruguai", "COST": "Horario de verán de Colombia", "EST": "Horario estándar do leste, Norteamérica", "GYT": "Horario da Güiana", "SRT": "Horario de Suriname", "WIT": "Horario de Indonesia Oriental", "LHST": "Horario estándar de Lord Howe", "ARST": "Horario de verán de Arxentina", "AKST": "Horario estándar de Alasca", "OESZ": "Horario de verán de Europa Oriental", "WART": "Horario estándar de Arxentina Occidental", "HKST": "Horario de verán de Hong Kong", "HNPM": "Horario estándar de Saint Pierre e Miquelon", "∅∅∅": "Horario de verán de Brasilia", "NZST": "Horario estándar de Nova Zelandia", "NZDT": "Horario de verán de Nova Zelandia", "HENOMX": "Horario de verán de México Noroeste", "ACST": "Horario estándar de Australia Central", "PDT": "Horario de verán do Pacífico, Norteamérica", "CHAST": "Horario estándar de Chatham", "TMST": "Horario de verán de Turcomenistán", "HNOG": "Horario estándar de Groenlandia Occidental", "CLT": "Horario estándar de Chile", "HNCU": "Horario estándar de Cuba", "MST": "MST", "MDT": "MDT", "JST": "Horario estándar do Xapón", "IST": "Horario estándar da India", "ECT": "Horario de Ecuador", "WEZ": "Horario estándar de Europa Occidental", "HEPMX": "Horario de verán do Pacífico mexicano", "TMT": "Horario estándar de Turcomenistán", "WARST": "Horario de verán de Arxentina Occidental", "COT": "Horario estándar de Colombia", "EDT": "Horario de verán do leste, Norteamérica", "ACWST": "Horario estándar de Australia Occidental Central", "MEZ": "Horario estándar de Europa Central", "OEZ": "Horario estándar de Europa Oriental", "HKT": "Horario estándar de Hong Kong", "CLST": "Horario de verán de Chile", "MYT": "Horario de Malaisia", "AST": "Horario estándar do Atlántico", "EAT": "Horario de África Oriental", "HNEG": "Horario estándar de Groenlandia Oriental", "GMT": "Horario do meridiano de Greenwich", "HEPM": "Horario de verán de Saint Pierre e Miquelon", "HAST": "Horario estándar de Hawai-Aleutiano", "AKDT": "Horario de verán de Alasca", "CST": "Horario estándar central, Norteamérica", "WITA": "Horario de Indonesia Central", "LHDT": "Horario de verán de Lord Howe", "HEOG": "Horario de verán de Groenlandia Occidental", "WESZ": "Horario de verán de Europa Occidental", "HAT": "Horario de verán de Terranova", "ChST": "Horario estándar chamorro", "PST": "Horario estándar do Pacífico, Norteamérica", "BOT": "Horario de Bolivia", "VET": "Horario de Venezuela", "ART": "Horario estándar de Arxentina", "WAST": "Horario de verán de África Occidental", "SGT": "Horario estándar de Singapur", "WIB": "Horario de Indonesia Occidental", "AWST": "Horario estándar de Australia Occidental", "MESZ": "Horario de verán de Europa Central", "ADT": "Horario de verán do Atlántico", "SAST": "Horario estándar de África do Sur", "HEEG": "Horario de verán de Groenlandia Oriental", "HECU": "Horario de verán de Cuba", "BT": "Horario de Bután", "HNNOMX": "Horario estándar de México Noroeste", "AEST": "Horario estándar de Australia Oriental", "WAT": "Horario estándar de África Occidental", "AWDT": "Horario de verán de Australia Occidental", "ACWDT": "Horario de verán de Australia Occidental Central", "UYT": "Horario estándar de Uruguai", "HADT": "Horario de verán de Hawai-Aleutiano", "GFT": "Horario da Güiana Francesa", "CDT": "Horario de verán central, Norteamérica", "JDT": "Horario de verán do Xapón", "HNT": "Horario estándar de Terranova"},
80 // Locale returns the current translators string locale
81 func (gl *gl_ES) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'gl_ES'
86 func (gl *gl_ES) PluralsCardinal() []locales.PluralRule {
87 return gl.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'gl_ES'
91 func (gl *gl_ES) PluralsOrdinal() []locales.PluralRule {
92 return gl.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'gl_ES'
96 func (gl *gl_ES) PluralsRange() []locales.PluralRule {
97 return gl.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gl_ES'
101 func (gl *gl_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
106 if i == 1 && v == 0 {
107 return locales.PluralRuleOne
110 return locales.PluralRuleOther
113 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gl_ES'
114 func (gl *gl_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
115 return locales.PluralRuleOther
118 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gl_ES'
119 func (gl *gl_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
121 start := gl.CardinalPluralRule(num1, v1)
122 end := gl.CardinalPluralRule(num2, v2)
124 if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
125 return locales.PluralRuleOther
126 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
127 return locales.PluralRuleOne
130 return locales.PluralRuleOther
134 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
135 func (gl *gl_ES) MonthAbbreviated(month time.Month) string {
136 return gl.monthsAbbreviated[month]
139 // MonthsAbbreviated returns the locales abbreviated months
140 func (gl *gl_ES) MonthsAbbreviated() []string {
141 return gl.monthsAbbreviated[1:]
144 // MonthNarrow returns the locales narrow month given the 'month' provided
145 func (gl *gl_ES) MonthNarrow(month time.Month) string {
146 return gl.monthsNarrow[month]
149 // MonthsNarrow returns the locales narrow months
150 func (gl *gl_ES) MonthsNarrow() []string {
151 return gl.monthsNarrow[1:]
154 // MonthWide returns the locales wide month given the 'month' provided
155 func (gl *gl_ES) MonthWide(month time.Month) string {
156 return gl.monthsWide[month]
159 // MonthsWide returns the locales wide months
160 func (gl *gl_ES) MonthsWide() []string {
161 return gl.monthsWide[1:]
164 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
165 func (gl *gl_ES) WeekdayAbbreviated(weekday time.Weekday) string {
166 return gl.daysAbbreviated[weekday]
169 // WeekdaysAbbreviated returns the locales abbreviated weekdays
170 func (gl *gl_ES) WeekdaysAbbreviated() []string {
171 return gl.daysAbbreviated
174 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
175 func (gl *gl_ES) WeekdayNarrow(weekday time.Weekday) string {
176 return gl.daysNarrow[weekday]
179 // WeekdaysNarrow returns the locales narrow weekdays
180 func (gl *gl_ES) WeekdaysNarrow() []string {
184 // WeekdayShort returns the locales short weekday given the 'weekday' provided
185 func (gl *gl_ES) WeekdayShort(weekday time.Weekday) string {
186 return gl.daysShort[weekday]
189 // WeekdaysShort returns the locales short weekdays
190 func (gl *gl_ES) WeekdaysShort() []string {
194 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
195 func (gl *gl_ES) WeekdayWide(weekday time.Weekday) string {
196 return gl.daysWide[weekday]
199 // WeekdaysWide returns the locales wide weekdays
200 func (gl *gl_ES) WeekdaysWide() []string {
204 // Decimal returns the decimal point of number
205 func (gl *gl_ES) Decimal() string {
209 // Group returns the group of number
210 func (gl *gl_ES) Group() string {
214 // Group returns the minus sign of number
215 func (gl *gl_ES) Minus() string {
219 // FmtNumber returns 'num' with digits/precision of 'v' for 'gl_ES' and handles both Whole and Real numbers based on 'v'
220 func (gl *gl_ES) FmtNumber(num float64, v uint64) string {
222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
223 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
226 b := make([]byte, 0, l)
228 for i := len(s) - 1; i >= 0; i-- {
231 b = append(b, gl.decimal[0])
238 b = append(b, gl.group[0])
249 b = append(b, gl.minus[0])
253 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
254 b[i], b[j] = b[j], b[i]
260 // FmtPercent returns 'num' with digits/precision of 'v' for 'gl_ES' and handles both Whole and Real numbers based on 'v'
261 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
262 func (gl *gl_ES) FmtPercent(num float64, v uint64) string {
263 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 b := make([]byte, 0, l)
267 for i := len(s) - 1; i >= 0; i-- {
270 b = append(b, gl.decimal[0])
278 b = append(b, gl.minus[0])
282 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
283 b[i], b[j] = b[j], b[i]
286 b = append(b, gl.percentSuffix...)
288 b = append(b, gl.percent...)
293 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gl_ES'
294 func (gl *gl_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string {
296 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
297 symbol := gl.currencies[currency]
298 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
301 b := make([]byte, 0, l)
303 for i := len(s) - 1; i >= 0; i-- {
306 b = append(b, gl.decimal[0])
313 b = append(b, gl.group[0])
324 b = append(b, gl.minus[0])
328 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
329 b[i], b[j] = b[j], b[i]
335 b = append(b, gl.decimal...)
338 for i := 0; i < 2-int(v); i++ {
343 b = append(b, gl.currencyPositiveSuffix...)
345 b = append(b, symbol...)
350 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gl_ES'
351 // in accounting notation.
352 func (gl *gl_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string {
354 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
355 symbol := gl.currencies[currency]
356 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
359 b := make([]byte, 0, l)
361 for i := len(s) - 1; i >= 0; i-- {
364 b = append(b, gl.decimal[0])
371 b = append(b, gl.group[0])
383 b = append(b, gl.minus[0])
388 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
389 b[i], b[j] = b[j], b[i]
395 b = append(b, gl.decimal...)
398 for i := 0; i < 2-int(v); i++ {
404 b = append(b, gl.currencyNegativeSuffix...)
405 b = append(b, symbol...)
408 b = append(b, gl.currencyPositiveSuffix...)
409 b = append(b, symbol...)
415 // FmtDateShort returns the short date representation of 't' for 'gl_ES'
416 func (gl *gl_ES) FmtDateShort(t time.Time) string {
418 b := make([]byte, 0, 32)
424 b = strconv.AppendInt(b, int64(t.Day()), 10)
425 b = append(b, []byte{0x2f}...)
431 b = strconv.AppendInt(b, int64(t.Month()), 10)
433 b = append(b, []byte{0x2f}...)
436 b = append(b, strconv.Itoa(t.Year())[2:]...)
438 b = append(b, strconv.Itoa(t.Year())[1:]...)
444 // FmtDateMedium returns the medium date representation of 't' for 'gl_ES'
445 func (gl *gl_ES) FmtDateMedium(t time.Time) string {
447 b := make([]byte, 0, 32)
449 b = strconv.AppendInt(b, int64(t.Day()), 10)
450 b = append(b, []byte{0x20, 0x64, 0x65}...)
451 b = append(b, []byte{0x20}...)
452 b = append(b, gl.monthsAbbreviated[t.Month()]...)
453 b = append(b, []byte{0x20, 0x64, 0x65}...)
454 b = append(b, []byte{0x20}...)
457 b = strconv.AppendInt(b, int64(t.Year()), 10)
459 b = strconv.AppendInt(b, int64(-t.Year()), 10)
465 // FmtDateLong returns the long date representation of 't' for 'gl_ES'
466 func (gl *gl_ES) FmtDateLong(t time.Time) string {
468 b := make([]byte, 0, 32)
470 b = strconv.AppendInt(b, int64(t.Day()), 10)
471 b = append(b, []byte{0x20, 0x64, 0x65}...)
472 b = append(b, []byte{0x20}...)
473 b = append(b, gl.monthsWide[t.Month()]...)
474 b = append(b, []byte{0x20, 0x64, 0x65}...)
475 b = append(b, []byte{0x20}...)
478 b = strconv.AppendInt(b, int64(t.Year()), 10)
480 b = strconv.AppendInt(b, int64(-t.Year()), 10)
486 // FmtDateFull returns the full date representation of 't' for 'gl_ES'
487 func (gl *gl_ES) FmtDateFull(t time.Time) string {
489 b := make([]byte, 0, 32)
491 b = append(b, gl.daysWide[t.Weekday()]...)
492 b = append(b, []byte{0x2c, 0x20}...)
493 b = strconv.AppendInt(b, int64(t.Day()), 10)
494 b = append(b, []byte{0x20, 0x64, 0x65}...)
495 b = append(b, []byte{0x20}...)
496 b = append(b, gl.monthsWide[t.Month()]...)
497 b = append(b, []byte{0x20, 0x64, 0x65}...)
498 b = append(b, []byte{0x20}...)
501 b = strconv.AppendInt(b, int64(t.Year()), 10)
503 b = strconv.AppendInt(b, int64(-t.Year()), 10)
509 // FmtTimeShort returns the short time representation of 't' for 'gl_ES'
510 func (gl *gl_ES) FmtTimeShort(t time.Time) string {
512 b := make([]byte, 0, 32)
518 b = strconv.AppendInt(b, int64(t.Hour()), 10)
519 b = append(b, gl.timeSeparator...)
525 b = strconv.AppendInt(b, int64(t.Minute()), 10)
530 // FmtTimeMedium returns the medium time representation of 't' for 'gl_ES'
531 func (gl *gl_ES) FmtTimeMedium(t time.Time) string {
533 b := make([]byte, 0, 32)
539 b = strconv.AppendInt(b, int64(t.Hour()), 10)
540 b = append(b, gl.timeSeparator...)
546 b = strconv.AppendInt(b, int64(t.Minute()), 10)
547 b = append(b, gl.timeSeparator...)
553 b = strconv.AppendInt(b, int64(t.Second()), 10)
558 // FmtTimeLong returns the long time representation of 't' for 'gl_ES'
559 func (gl *gl_ES) FmtTimeLong(t time.Time) string {
561 b := make([]byte, 0, 32)
567 b = strconv.AppendInt(b, int64(t.Hour()), 10)
568 b = append(b, gl.timeSeparator...)
574 b = strconv.AppendInt(b, int64(t.Minute()), 10)
575 b = append(b, gl.timeSeparator...)
581 b = strconv.AppendInt(b, int64(t.Second()), 10)
582 b = append(b, []byte{0x20}...)
590 // FmtTimeFull returns the full time representation of 't' for 'gl_ES'
591 func (gl *gl_ES) FmtTimeFull(t time.Time) string {
593 b := make([]byte, 0, 32)
599 b = strconv.AppendInt(b, int64(t.Hour()), 10)
600 b = append(b, gl.timeSeparator...)
606 b = strconv.AppendInt(b, int64(t.Minute()), 10)
607 b = append(b, gl.timeSeparator...)
613 b = strconv.AppendInt(b, int64(t.Second()), 10)
614 b = append(b, []byte{0x20}...)
618 if btz, ok := gl.timezones[tz]; ok {
619 b = append(b, btz...)