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 'seh' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 6},
52 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", "MTn", "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"},
53 monthsAbbreviated: []string{"", "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Aug", "Set", "Otu", "Nov", "Dec"},
54 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
55 monthsWide: []string{"", "Janeiro", "Fevreiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Augusto", "Setembro", "Otubro", "Novembro", "Decembro"},
56 daysAbbreviated: []string{"Dim", "Pos", "Pir", "Tat", "Nai", "Sha", "Sab"},
57 daysNarrow: []string{"D", "P", "C", "T", "N", "S", "S"},
58 daysWide: []string{"Dimingu", "Chiposi", "Chipiri", "Chitatu", "Chinai", "Chishanu", "Sabudu"},
59 erasAbbreviated: []string{"AC", "AD"},
60 erasNarrow: []string{"", ""},
61 erasWide: []string{"Antes de Cristo", "Anno Domini"},
62 timezones: map[string]string{"CLST": "CLST", "HADT": "HADT", "LHDT": "LHDT", "VET": "VET", "HAT": "HAT", "AKST": "AKST", "SGT": "SGT", "PDT": "PDT", "CDT": "CDT", "WART": "WART", "COT": "COT", "CHADT": "CHADT", "ACWDT": "ACWDT", "TMST": "TMST", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "GYT": "GYT", "ECT": "ECT", "HEPM": "HEPM", "MDT": "MDT", "ACWST": "ACWST", "NZDT": "NZDT", "TMT": "TMT", "JDT": "JDT", "OEZ": "OEZ", "WAT": "WAT", "∅∅∅": "∅∅∅", "CAT": "CAT", "WEZ": "WEZ", "WESZ": "WESZ", "AWST": "AWST", "OESZ": "OESZ", "HEOG": "HEOG", "HNT": "HNT", "HKT": "HKT", "CLT": "CLT", "HECU": "HECU", "MYT": "MYT", "UYT": "UYT", "HKST": "HKST", "HNPM": "HNPM", "IST": "IST", "WAST": "WAST", "CST": "CST", "NZST": "NZST", "HENOMX": "HENOMX", "AEDT": "AEDT", "EAT": "EAT", "EDT": "EDT", "AKDT": "AKDT", "ACST": "ACST", "GFT": "GFT", "EST": "EST", "BT": "BT", "BOT": "BOT", "MST": "MST", "SRT": "SRT", "UYST": "UYST", "ART": "ART", "HNCU": "HNCU", "AWDT": "AWDT", "ARST": "ARST", "GMT": "GMT", "WIB": "WIB", "PST": "PST", "LHST": "LHST", "CHAST": "CHAST", "MEZ": "MEZ", "ADT": "ADT", "SAST": "SAST", "HNEG": "HNEG", "COST": "COST", "ACDT": "ACDT", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "HAST": "HAST", "WARST": "WARST", "WITA": "WITA", "AEST": "AEST", "HNOG": "HNOG", "ChST": "ChST", "WIT": "WIT", "MESZ": "MESZ", "JST": "JST", "AST": "AST"},
66 // Locale returns the current translators string locale
67 func (seh *seh) Locale() string {
71 // PluralsCardinal returns the list of cardinal plural rules associated with 'seh'
72 func (seh *seh) PluralsCardinal() []locales.PluralRule {
73 return seh.pluralsCardinal
76 // PluralsOrdinal returns the list of ordinal plural rules associated with 'seh'
77 func (seh *seh) PluralsOrdinal() []locales.PluralRule {
78 return seh.pluralsOrdinal
81 // PluralsRange returns the list of range plural rules associated with 'seh'
82 func (seh *seh) PluralsRange() []locales.PluralRule {
83 return seh.pluralsRange
86 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'seh'
87 func (seh *seh) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
92 return locales.PluralRuleOne
95 return locales.PluralRuleOther
98 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'seh'
99 func (seh *seh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
100 return locales.PluralRuleUnknown
103 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'seh'
104 func (seh *seh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
105 return locales.PluralRuleUnknown
108 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
109 func (seh *seh) MonthAbbreviated(month time.Month) string {
110 return seh.monthsAbbreviated[month]
113 // MonthsAbbreviated returns the locales abbreviated months
114 func (seh *seh) MonthsAbbreviated() []string {
115 return seh.monthsAbbreviated[1:]
118 // MonthNarrow returns the locales narrow month given the 'month' provided
119 func (seh *seh) MonthNarrow(month time.Month) string {
120 return seh.monthsNarrow[month]
123 // MonthsNarrow returns the locales narrow months
124 func (seh *seh) MonthsNarrow() []string {
125 return seh.monthsNarrow[1:]
128 // MonthWide returns the locales wide month given the 'month' provided
129 func (seh *seh) MonthWide(month time.Month) string {
130 return seh.monthsWide[month]
133 // MonthsWide returns the locales wide months
134 func (seh *seh) MonthsWide() []string {
135 return seh.monthsWide[1:]
138 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
139 func (seh *seh) WeekdayAbbreviated(weekday time.Weekday) string {
140 return seh.daysAbbreviated[weekday]
143 // WeekdaysAbbreviated returns the locales abbreviated weekdays
144 func (seh *seh) WeekdaysAbbreviated() []string {
145 return seh.daysAbbreviated
148 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
149 func (seh *seh) WeekdayNarrow(weekday time.Weekday) string {
150 return seh.daysNarrow[weekday]
153 // WeekdaysNarrow returns the locales narrow weekdays
154 func (seh *seh) WeekdaysNarrow() []string {
155 return seh.daysNarrow
158 // WeekdayShort returns the locales short weekday given the 'weekday' provided
159 func (seh *seh) WeekdayShort(weekday time.Weekday) string {
160 return seh.daysShort[weekday]
163 // WeekdaysShort returns the locales short weekdays
164 func (seh *seh) WeekdaysShort() []string {
168 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
169 func (seh *seh) WeekdayWide(weekday time.Weekday) string {
170 return seh.daysWide[weekday]
173 // WeekdaysWide returns the locales wide weekdays
174 func (seh *seh) WeekdaysWide() []string {
178 // Decimal returns the decimal point of number
179 func (seh *seh) Decimal() string {
183 // Group returns the group of number
184 func (seh *seh) Group() string {
188 // Group returns the minus sign of number
189 func (seh *seh) Minus() string {
193 // FmtNumber returns 'num' with digits/precision of 'v' for 'seh' and handles both Whole and Real numbers based on 'v'
194 func (seh *seh) FmtNumber(num float64, v uint64) string {
196 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
199 // FmtPercent returns 'num' with digits/precision of 'v' for 'seh' and handles both Whole and Real numbers based on 'v'
200 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
201 func (seh *seh) FmtPercent(num float64, v uint64) string {
202 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'seh'
206 func (seh *seh) FmtCurrency(num float64, v uint64, currency currency.Type) string {
208 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209 symbol := seh.currencies[currency]
210 l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
213 b := make([]byte, 0, l)
215 for i := len(s) - 1; i >= 0; i-- {
218 b = append(b, seh.decimal[0])
225 b = append(b, seh.group[0])
236 b = append(b, seh.minus[0])
240 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
241 b[i], b[j] = b[j], b[i]
247 b = append(b, seh.decimal...)
250 for i := 0; i < 2-int(v); i++ {
255 b = append(b, symbol...)
260 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'seh'
261 // in accounting notation.
262 func (seh *seh) FmtAccounting(num float64, v uint64, currency currency.Type) string {
264 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 symbol := seh.currencies[currency]
266 l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
269 b := make([]byte, 0, l)
271 for i := len(s) - 1; i >= 0; i-- {
274 b = append(b, seh.decimal[0])
281 b = append(b, seh.group[0])
293 b = append(b, seh.minus[0])
298 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
299 b[i], b[j] = b[j], b[i]
305 b = append(b, seh.decimal...)
308 for i := 0; i < 2-int(v); i++ {
314 b = append(b, symbol...)
317 b = append(b, symbol...)
323 // FmtDateShort returns the short date representation of 't' for 'seh'
324 func (seh *seh) FmtDateShort(t time.Time) string {
326 b := make([]byte, 0, 32)
328 b = strconv.AppendInt(b, int64(t.Day()), 10)
329 b = append(b, []byte{0x2f}...)
330 b = strconv.AppendInt(b, int64(t.Month()), 10)
331 b = append(b, []byte{0x2f}...)
334 b = strconv.AppendInt(b, int64(t.Year()), 10)
336 b = strconv.AppendInt(b, int64(-t.Year()), 10)
342 // FmtDateMedium returns the medium date representation of 't' for 'seh'
343 func (seh *seh) FmtDateMedium(t time.Time) string {
345 b := make([]byte, 0, 32)
347 b = strconv.AppendInt(b, int64(t.Day()), 10)
348 b = append(b, []byte{0x20, 0x64, 0x65}...)
349 b = append(b, []byte{0x20}...)
350 b = append(b, seh.monthsAbbreviated[t.Month()]...)
351 b = append(b, []byte{0x20, 0x64, 0x65}...)
352 b = append(b, []byte{0x20}...)
355 b = strconv.AppendInt(b, int64(t.Year()), 10)
357 b = strconv.AppendInt(b, int64(-t.Year()), 10)
363 // FmtDateLong returns the long date representation of 't' for 'seh'
364 func (seh *seh) FmtDateLong(t time.Time) string {
366 b := make([]byte, 0, 32)
368 b = strconv.AppendInt(b, int64(t.Day()), 10)
369 b = append(b, []byte{0x20, 0x64, 0x65}...)
370 b = append(b, []byte{0x20}...)
371 b = append(b, seh.monthsWide[t.Month()]...)
372 b = append(b, []byte{0x20, 0x64, 0x65}...)
373 b = append(b, []byte{0x20}...)
376 b = strconv.AppendInt(b, int64(t.Year()), 10)
378 b = strconv.AppendInt(b, int64(-t.Year()), 10)
384 // FmtDateFull returns the full date representation of 't' for 'seh'
385 func (seh *seh) FmtDateFull(t time.Time) string {
387 b := make([]byte, 0, 32)
389 b = append(b, seh.daysWide[t.Weekday()]...)
390 b = append(b, []byte{0x2c, 0x20}...)
391 b = strconv.AppendInt(b, int64(t.Day()), 10)
392 b = append(b, []byte{0x20, 0x64, 0x65}...)
393 b = append(b, []byte{0x20}...)
394 b = append(b, seh.monthsWide[t.Month()]...)
395 b = append(b, []byte{0x20, 0x64, 0x65}...)
396 b = append(b, []byte{0x20}...)
399 b = strconv.AppendInt(b, int64(t.Year()), 10)
401 b = strconv.AppendInt(b, int64(-t.Year()), 10)
407 // FmtTimeShort returns the short time representation of 't' for 'seh'
408 func (seh *seh) FmtTimeShort(t time.Time) string {
410 b := make([]byte, 0, 32)
416 b = strconv.AppendInt(b, int64(t.Hour()), 10)
417 b = append(b, seh.timeSeparator...)
423 b = strconv.AppendInt(b, int64(t.Minute()), 10)
428 // FmtTimeMedium returns the medium time representation of 't' for 'seh'
429 func (seh *seh) FmtTimeMedium(t time.Time) string {
431 b := make([]byte, 0, 32)
437 b = strconv.AppendInt(b, int64(t.Hour()), 10)
438 b = append(b, seh.timeSeparator...)
444 b = strconv.AppendInt(b, int64(t.Minute()), 10)
445 b = append(b, seh.timeSeparator...)
451 b = strconv.AppendInt(b, int64(t.Second()), 10)
456 // FmtTimeLong returns the long time representation of 't' for 'seh'
457 func (seh *seh) FmtTimeLong(t time.Time) string {
459 b := make([]byte, 0, 32)
465 b = strconv.AppendInt(b, int64(t.Hour()), 10)
466 b = append(b, seh.timeSeparator...)
472 b = strconv.AppendInt(b, int64(t.Minute()), 10)
473 b = append(b, seh.timeSeparator...)
479 b = strconv.AppendInt(b, int64(t.Second()), 10)
480 b = append(b, []byte{0x20}...)
488 // FmtTimeFull returns the full time representation of 't' for 'seh'
489 func (seh *seh) FmtTimeFull(t time.Time) string {
491 b := make([]byte, 0, 32)
497 b = strconv.AppendInt(b, int64(t.Hour()), 10)
498 b = append(b, seh.timeSeparator...)
504 b = strconv.AppendInt(b, int64(t.Minute()), 10)
505 b = append(b, seh.timeSeparator...)
511 b = strconv.AppendInt(b, int64(t.Second()), 10)
512 b = append(b, []byte{0x20}...)
516 if btz, ok := seh.timezones[tz]; ok {
517 b = append(b, btz...)