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 currencyNegativePrefix 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 'en_SE' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6},
51 pluralsRange: []locales.PluralRule{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", "kr", "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 currencyNegativePrefix: "(",
62 currencyNegativeSuffix: ")",
63 monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
64 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65 monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
66 daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
67 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
68 daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
69 daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
70 periodsAbbreviated: []string{"am", "pm"},
71 periodsNarrow: []string{"a", "p"},
72 periodsWide: []string{"am", "pm"},
73 erasAbbreviated: []string{"BC", "AD"},
74 erasNarrow: []string{"B", "A"},
75 erasWide: []string{"Before Christ", "Anno Domini"},
76 timezones: map[string]string{"EAT": "East Africa Time", "WIT": "Eastern Indonesia Time", "NZST": "New Zealand Standard Time", "WART": "Western Argentina Standard Time", "AEDT": "Australian Eastern Daylight Time", "ACST": "Australian Central Standard Time", "AKDT": "Alaska Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHAST": "Chatham Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "SAST": "South Africa Standard Time", "HKST": "Hong Kong Summer Time", "CLT": "Chile Standard Time", "COST": "Colombia Summer Time", "PST": "Pacific Standard Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "WARST": "Western Argentina Summer Time", "HNT": "Newfoundland Standard Time", "WAT": "West Africa Standard Time", "COT": "Colombia Standard Time", "ACDT": "Australian Central Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "LHDT": "Lord Howe Daylight Time", "MDT": "Mountain Daylight Time", "AEST": "Australian Eastern Standard Time", "ACWDT": "Australian Central Western Daylight Time", "GYT": "Guyana Time", "WEZ": "Western European Standard Time", "SRT": "Suriname Time", "ECT": "Ecuador Time", "HNCU": "Cuba Standard Time", "UYT": "Uruguay Standard Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "HNOG": "West Greenland Standard Time", "GFT": "French Guiana Time", "AKST": "Alaska Standard Time", "CHADT": "Chatham Daylight Time", "CST": "Central Standard Time", "UYST": "Uruguay Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEOG": "West Greenland Summer Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ART": "Argentina Standard Time", "HEEG": "East Greenland Summer Time", "EDT": "Eastern Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "WITA": "Central Indonesia Time", "WIB": "Western Indonesia Time", "CDT": "Central Daylight Time", "WAST": "West Africa Summer Time", "HKT": "Hong Kong Standard Time", "AWST": "Australian Western Standard Time", "MYT": "Malaysia Time", "MESZ": "Central European Summer Time", "JDT": "Japan Daylight Time", "MST": "Mountain Standard Time", "VET": "Venezuela Time", "AWDT": "Australian Western Daylight Time", "OESZ": "Eastern European Summer Time", "∅∅∅": "Azores Summer Time", "HNEG": "East Greenland Standard Time", "CLST": "Chile Summer Time", "CAT": "Central Africa Time", "GMT": "Greenwich Mean Time", "NZDT": "New Zealand Daylight Time", "OEZ": "Eastern European Standard Time", "IST": "India Standard Time", "AST": "Atlantic Standard Time", "HAT": "Newfoundland Daylight Time", "WESZ": "Western European Summer Time", "BT": "Bhutan Time", "BOT": "Bolivia Time", "HNNOMX": "Northwest Mexico Standard Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "HECU": "Cuba Daylight Time", "ACWST": "Australian Central Western Standard Time", "EST": "Eastern Standard Time", "SGT": "Singapore Standard Time", "PDT": "Pacific Daylight Time"},
80 // Locale returns the current translators string locale
81 func (en *en_SE) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'en_SE'
86 func (en *en_SE) PluralsCardinal() []locales.PluralRule {
87 return en.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SE'
91 func (en *en_SE) PluralsOrdinal() []locales.PluralRule {
92 return en.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'en_SE'
96 func (en *en_SE) PluralsRange() []locales.PluralRule {
97 return en.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SE'
101 func (en *en_SE) 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 'en_SE'
114 func (en *en_SE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
117 nMod10 := math.Mod(n, 10)
118 nMod100 := math.Mod(n, 100)
120 if nMod10 == 1 && nMod100 != 11 {
121 return locales.PluralRuleOne
122 } else if nMod10 == 2 && nMod100 != 12 {
123 return locales.PluralRuleTwo
124 } else if nMod10 == 3 && nMod100 != 13 {
125 return locales.PluralRuleFew
128 return locales.PluralRuleOther
131 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SE'
132 func (en *en_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
133 return locales.PluralRuleOther
136 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
137 func (en *en_SE) MonthAbbreviated(month time.Month) string {
138 return en.monthsAbbreviated[month]
141 // MonthsAbbreviated returns the locales abbreviated months
142 func (en *en_SE) MonthsAbbreviated() []string {
143 return en.monthsAbbreviated[1:]
146 // MonthNarrow returns the locales narrow month given the 'month' provided
147 func (en *en_SE) MonthNarrow(month time.Month) string {
148 return en.monthsNarrow[month]
151 // MonthsNarrow returns the locales narrow months
152 func (en *en_SE) MonthsNarrow() []string {
153 return en.monthsNarrow[1:]
156 // MonthWide returns the locales wide month given the 'month' provided
157 func (en *en_SE) MonthWide(month time.Month) string {
158 return en.monthsWide[month]
161 // MonthsWide returns the locales wide months
162 func (en *en_SE) MonthsWide() []string {
163 return en.monthsWide[1:]
166 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
167 func (en *en_SE) WeekdayAbbreviated(weekday time.Weekday) string {
168 return en.daysAbbreviated[weekday]
171 // WeekdaysAbbreviated returns the locales abbreviated weekdays
172 func (en *en_SE) WeekdaysAbbreviated() []string {
173 return en.daysAbbreviated
176 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
177 func (en *en_SE) WeekdayNarrow(weekday time.Weekday) string {
178 return en.daysNarrow[weekday]
181 // WeekdaysNarrow returns the locales narrow weekdays
182 func (en *en_SE) WeekdaysNarrow() []string {
186 // WeekdayShort returns the locales short weekday given the 'weekday' provided
187 func (en *en_SE) WeekdayShort(weekday time.Weekday) string {
188 return en.daysShort[weekday]
191 // WeekdaysShort returns the locales short weekdays
192 func (en *en_SE) WeekdaysShort() []string {
196 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
197 func (en *en_SE) WeekdayWide(weekday time.Weekday) string {
198 return en.daysWide[weekday]
201 // WeekdaysWide returns the locales wide weekdays
202 func (en *en_SE) WeekdaysWide() []string {
206 // Decimal returns the decimal point of number
207 func (en *en_SE) Decimal() string {
211 // Group returns the group of number
212 func (en *en_SE) Group() string {
216 // Group returns the minus sign of number
217 func (en *en_SE) Minus() string {
221 // FmtNumber returns 'num' with digits/precision of 'v' for 'en_SE' and handles both Whole and Real numbers based on 'v'
222 func (en *en_SE) FmtNumber(num float64, v uint64) string {
224 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
225 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
228 b := make([]byte, 0, l)
230 for i := len(s) - 1; i >= 0; i-- {
233 b = append(b, en.decimal[0])
240 for j := len(en.group) - 1; j >= 0; j-- {
241 b = append(b, en.group[j])
253 b = append(b, en.minus[0])
257 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
258 b[i], b[j] = b[j], b[i]
264 // FmtPercent returns 'num' with digits/precision of 'v' for 'en_SE' and handles both Whole and Real numbers based on 'v'
265 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
266 func (en *en_SE) FmtPercent(num float64, v uint64) string {
267 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 b := make([]byte, 0, l)
271 for i := len(s) - 1; i >= 0; i-- {
274 b = append(b, en.decimal[0])
282 b = append(b, en.minus[0])
286 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
287 b[i], b[j] = b[j], b[i]
290 b = append(b, en.percentSuffix...)
292 b = append(b, en.percent...)
297 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SE'
298 func (en *en_SE) FmtCurrency(num float64, v uint64, currency currency.Type) string {
300 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
301 symbol := en.currencies[currency]
302 l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3
305 b := make([]byte, 0, l)
307 for i := len(s) - 1; i >= 0; i-- {
310 b = append(b, en.decimal[0])
317 for j := len(en.group) - 1; j >= 0; j-- {
318 b = append(b, en.group[j])
329 for j := len(symbol) - 1; j >= 0; j-- {
330 b = append(b, symbol[j])
334 b = append(b, en.minus[0])
338 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
339 b[i], b[j] = b[j], b[i]
345 b = append(b, en.decimal...)
348 for i := 0; i < 2-int(v); i++ {
356 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SE'
357 // in accounting notation.
358 func (en *en_SE) FmtAccounting(num float64, v uint64, currency currency.Type) string {
360 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
361 symbol := en.currencies[currency]
362 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
365 b := make([]byte, 0, l)
367 for i := len(s) - 1; i >= 0; i-- {
370 b = append(b, en.decimal[0])
377 for j := len(en.group) - 1; j >= 0; j-- {
378 b = append(b, en.group[j])
391 for j := len(symbol) - 1; j >= 0; j-- {
392 b = append(b, symbol[j])
395 b = append(b, en.currencyNegativePrefix[0])
399 for j := len(symbol) - 1; j >= 0; j-- {
400 b = append(b, symbol[j])
406 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
407 b[i], b[j] = b[j], b[i]
413 b = append(b, en.decimal...)
416 for i := 0; i < 2-int(v); i++ {
422 b = append(b, en.currencyNegativeSuffix...)
428 // FmtDateShort returns the short date representation of 't' for 'en_SE'
429 func (en *en_SE) FmtDateShort(t time.Time) string {
431 b := make([]byte, 0, 32)
434 b = strconv.AppendInt(b, int64(t.Year()), 10)
436 b = strconv.AppendInt(b, int64(-t.Year()), 10)
439 b = append(b, []byte{0x2d}...)
445 b = strconv.AppendInt(b, int64(t.Month()), 10)
447 b = append(b, []byte{0x2d}...)
453 b = strconv.AppendInt(b, int64(t.Day()), 10)
458 // FmtDateMedium returns the medium date representation of 't' for 'en_SE'
459 func (en *en_SE) FmtDateMedium(t time.Time) string {
461 b := make([]byte, 0, 32)
463 b = append(b, en.monthsAbbreviated[t.Month()]...)
464 b = append(b, []byte{0x20}...)
465 b = strconv.AppendInt(b, int64(t.Day()), 10)
466 b = append(b, []byte{0x2c, 0x20}...)
469 b = strconv.AppendInt(b, int64(t.Year()), 10)
471 b = strconv.AppendInt(b, int64(-t.Year()), 10)
477 // FmtDateLong returns the long date representation of 't' for 'en_SE'
478 func (en *en_SE) FmtDateLong(t time.Time) string {
480 b := make([]byte, 0, 32)
482 b = append(b, en.monthsWide[t.Month()]...)
483 b = append(b, []byte{0x20}...)
484 b = strconv.AppendInt(b, int64(t.Day()), 10)
485 b = append(b, []byte{0x2c, 0x20}...)
488 b = strconv.AppendInt(b, int64(t.Year()), 10)
490 b = strconv.AppendInt(b, int64(-t.Year()), 10)
496 // FmtDateFull returns the full date representation of 't' for 'en_SE'
497 func (en *en_SE) FmtDateFull(t time.Time) string {
499 b := make([]byte, 0, 32)
501 b = append(b, en.daysWide[t.Weekday()]...)
502 b = append(b, []byte{0x2c, 0x20}...)
503 b = append(b, en.monthsWide[t.Month()]...)
504 b = append(b, []byte{0x20}...)
505 b = strconv.AppendInt(b, int64(t.Day()), 10)
506 b = append(b, []byte{0x2c, 0x20}...)
509 b = strconv.AppendInt(b, int64(t.Year()), 10)
511 b = strconv.AppendInt(b, int64(-t.Year()), 10)
517 // FmtTimeShort returns the short time representation of 't' for 'en_SE'
518 func (en *en_SE) FmtTimeShort(t time.Time) string {
520 b := make([]byte, 0, 32)
528 b = strconv.AppendInt(b, int64(h), 10)
529 b = append(b, en.timeSeparator...)
535 b = strconv.AppendInt(b, int64(t.Minute()), 10)
536 b = append(b, []byte{0x20}...)
539 b = append(b, en.periodsAbbreviated[0]...)
541 b = append(b, en.periodsAbbreviated[1]...)
547 // FmtTimeMedium returns the medium time representation of 't' for 'en_SE'
548 func (en *en_SE) FmtTimeMedium(t time.Time) string {
550 b := make([]byte, 0, 32)
558 b = strconv.AppendInt(b, int64(h), 10)
559 b = append(b, en.timeSeparator...)
565 b = strconv.AppendInt(b, int64(t.Minute()), 10)
566 b = append(b, en.timeSeparator...)
572 b = strconv.AppendInt(b, int64(t.Second()), 10)
573 b = append(b, []byte{0x20}...)
576 b = append(b, en.periodsAbbreviated[0]...)
578 b = append(b, en.periodsAbbreviated[1]...)
584 // FmtTimeLong returns the long time representation of 't' for 'en_SE'
585 func (en *en_SE) FmtTimeLong(t time.Time) string {
587 b := make([]byte, 0, 32)
595 b = strconv.AppendInt(b, int64(h), 10)
596 b = append(b, en.timeSeparator...)
602 b = strconv.AppendInt(b, int64(t.Minute()), 10)
603 b = append(b, en.timeSeparator...)
609 b = strconv.AppendInt(b, int64(t.Second()), 10)
610 b = append(b, []byte{0x20}...)
613 b = append(b, en.periodsAbbreviated[0]...)
615 b = append(b, en.periodsAbbreviated[1]...)
618 b = append(b, []byte{0x20}...)
626 // FmtTimeFull returns the full time representation of 't' for 'en_SE'
627 func (en *en_SE) FmtTimeFull(t time.Time) string {
629 b := make([]byte, 0, 32)
637 b = strconv.AppendInt(b, int64(h), 10)
638 b = append(b, en.timeSeparator...)
644 b = strconv.AppendInt(b, int64(t.Minute()), 10)
645 b = append(b, en.timeSeparator...)
651 b = strconv.AppendInt(b, int64(t.Second()), 10)
652 b = append(b, []byte{0x20}...)
655 b = append(b, en.periodsAbbreviated[0]...)
657 b = append(b, en.periodsAbbreviated[1]...)
660 b = append(b, []byte{0x20}...)
664 if btz, ok := en.timezones[tz]; ok {
665 b = append(b, btz...)