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 'se_SE' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 3, 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", "Nkr", "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 currencyPositiveSuffix: " ",
62 currencyNegativeSuffix: " ",
63 monthsAbbreviated: []string{"", "ođđj", "guov", "njuk", "cuo", "mies", "geas", "suoi", "borg", "čakč", "golg", "skáb", "juov"},
64 monthsNarrow: []string{"", "O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"},
65 monthsWide: []string{"", "ođđajagemánnu", "guovvamánnu", "njukčamánnu", "cuoŋománnu", "miessemánnu", "geassemánnu", "suoidnemánnu", "borgemánnu", "čakčamánnu", "golggotmánnu", "skábmamánnu", "juovlamánnu"},
66 daysAbbreviated: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"},
67 daysNarrow: []string{"S", "V", "M", "G", "D", "B", "L"},
68 daysShort: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"},
69 daysWide: []string{"sotnabeaivi", "vuossárga", "maŋŋebárga", "gaskavahkku", "duorasdat", "bearjadat", "lávvardat"},
70 periodsAbbreviated: []string{"i.b.", "e.b."},
71 periodsNarrow: []string{"i.b.", "e.b."},
72 periodsWide: []string{"iđitbeaivet", "eahketbeaivet"},
73 erasAbbreviated: []string{"o.Kr.", "m.Kr."},
74 erasNarrow: []string{"ooá", "oá"},
75 erasWide: []string{"ovdal Kristtusa", "maŋŋel Kristtusa"},
76 timezones: map[string]string{"GFT": "GFT", "HECU": "HECU", "NZDT": "NZDT", "WART": "WART", "JDT": "JDT", "LHST": "LHST", "VET": "VET", "COST": "COST", "EST": "EST", "CAT": "CAT", "GMT": "Greenwich gaskka áigi", "AWST": "AWST", "ACWDT": "ACWDT", "ACWST": "ACWST", "LHDT": "LHDT", "MESZ": "gaska-Eurohpá geassiáigi", "ARST": "ARST", "COT": "COT", "SGT": "SGT", "SRT": "SRT", "AWDT": "AWDT", "WIT": "WIT", "CDT": "CDT", "HAST": "HAST", "AEST": "AEST", "HKT": "HKT", "CLT": "CLT", "ChST": "ChST", "HNPMX": "HNPMX", "PDT": "PDT", "WITA": "WITA", "OEZ": "nuorti-Eurohpá dábálašáigi", "∅∅∅": "∅∅∅", "AKDT": "AKDT", "WEZ": "oarje-Eurohpá dábálašáigi", "HNCU": "HNCU", "CST": "CST", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "AEDT": "AEDT", "EAT": "EAT", "HNEG": "HNEG", "GYT": "GYT", "HNPM": "HNPM", "BT": "BT", "IST": "IST", "AST": "AST", "HNT": "HNT", "HKST": "HKST", "ACDT": "ACDT", "WIB": "WIB", "UYT": "UYT", "OESZ": "nuorti-Eurohpá geassiáigi", "NZST": "NZST", "JST": "JST", "WAST": "WAST", "CLST": "CLST", "WESZ": "oarje-Eurohpá geassiáigi", "HEPM": "HEPM", "MST": "MST", "MDT": "MDT", "HAT": "HAT", "UYST": "UYST", "TMT": "TMT", "MEZ": "gaska-Eurohpá dábálašáigi", "HENOMX": "HENOMX", "HEOG": "HEOG", "EDT": "EDT", "BOT": "BOT", "MYT": "MYT", "HEEG": "HEEG", "SAST": "SAST", "WARST": "WARST", "HADT": "HADT", "ART": "ART", "ACST": "ACST", "ECT": "ECT", "PST": "PST", "CHAST": "CHAST", "TMST": "TMST", "ADT": "ADT", "WAT": "WAT", "CHADT": "CHADT", "AKST": "AKST", "HEPMX": "HEPMX"},
80 // Locale returns the current translators string locale
81 func (se *se_SE) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'se_SE'
86 func (se *se_SE) PluralsCardinal() []locales.PluralRule {
87 return se.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'se_SE'
91 func (se *se_SE) PluralsOrdinal() []locales.PluralRule {
92 return se.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'se_SE'
96 func (se *se_SE) PluralsRange() []locales.PluralRule {
97 return se.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'se_SE'
101 func (se *se_SE) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
106 return locales.PluralRuleOne
108 return locales.PluralRuleTwo
111 return locales.PluralRuleOther
114 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'se_SE'
115 func (se *se_SE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116 return locales.PluralRuleUnknown
119 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'se_SE'
120 func (se *se_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
121 return locales.PluralRuleUnknown
124 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
125 func (se *se_SE) MonthAbbreviated(month time.Month) string {
126 return se.monthsAbbreviated[month]
129 // MonthsAbbreviated returns the locales abbreviated months
130 func (se *se_SE) MonthsAbbreviated() []string {
131 return se.monthsAbbreviated[1:]
134 // MonthNarrow returns the locales narrow month given the 'month' provided
135 func (se *se_SE) MonthNarrow(month time.Month) string {
136 return se.monthsNarrow[month]
139 // MonthsNarrow returns the locales narrow months
140 func (se *se_SE) MonthsNarrow() []string {
141 return se.monthsNarrow[1:]
144 // MonthWide returns the locales wide month given the 'month' provided
145 func (se *se_SE) MonthWide(month time.Month) string {
146 return se.monthsWide[month]
149 // MonthsWide returns the locales wide months
150 func (se *se_SE) MonthsWide() []string {
151 return se.monthsWide[1:]
154 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
155 func (se *se_SE) WeekdayAbbreviated(weekday time.Weekday) string {
156 return se.daysAbbreviated[weekday]
159 // WeekdaysAbbreviated returns the locales abbreviated weekdays
160 func (se *se_SE) WeekdaysAbbreviated() []string {
161 return se.daysAbbreviated
164 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
165 func (se *se_SE) WeekdayNarrow(weekday time.Weekday) string {
166 return se.daysNarrow[weekday]
169 // WeekdaysNarrow returns the locales narrow weekdays
170 func (se *se_SE) WeekdaysNarrow() []string {
174 // WeekdayShort returns the locales short weekday given the 'weekday' provided
175 func (se *se_SE) WeekdayShort(weekday time.Weekday) string {
176 return se.daysShort[weekday]
179 // WeekdaysShort returns the locales short weekdays
180 func (se *se_SE) WeekdaysShort() []string {
184 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
185 func (se *se_SE) WeekdayWide(weekday time.Weekday) string {
186 return se.daysWide[weekday]
189 // WeekdaysWide returns the locales wide weekdays
190 func (se *se_SE) WeekdaysWide() []string {
194 // Decimal returns the decimal point of number
195 func (se *se_SE) Decimal() string {
199 // Group returns the group of number
200 func (se *se_SE) Group() string {
204 // Group returns the minus sign of number
205 func (se *se_SE) Minus() string {
209 // FmtNumber returns 'num' with digits/precision of 'v' for 'se_SE' and handles both Whole and Real numbers based on 'v'
210 func (se *se_SE) FmtNumber(num float64, v uint64) string {
212 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
213 l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3
216 b := make([]byte, 0, l)
218 for i := len(s) - 1; i >= 0; i-- {
221 b = append(b, se.decimal[0])
228 for j := len(se.group) - 1; j >= 0; j-- {
229 b = append(b, se.group[j])
241 for j := len(se.minus) - 1; j >= 0; j-- {
242 b = append(b, se.minus[j])
247 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
248 b[i], b[j] = b[j], b[i]
254 // FmtPercent returns 'num' with digits/precision of 'v' for 'se_SE' and handles both Whole and Real numbers based on 'v'
255 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
256 func (se *se_SE) FmtPercent(num float64, v uint64) string {
257 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
259 b := make([]byte, 0, l)
261 for i := len(s) - 1; i >= 0; i-- {
264 b = append(b, se.decimal[0])
272 for j := len(se.minus) - 1; j >= 0; j-- {
273 b = append(b, se.minus[j])
278 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
279 b[i], b[j] = b[j], b[i]
282 b = append(b, se.percentSuffix...)
284 b = append(b, se.percent...)
289 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'se_SE'
290 func (se *se_SE) FmtCurrency(num float64, v uint64, currency currency.Type) string {
292 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
293 symbol := se.currencies[currency]
294 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
297 b := make([]byte, 0, l)
299 for i := len(s) - 1; i >= 0; i-- {
302 b = append(b, se.decimal[0])
309 for j := len(se.group) - 1; j >= 0; j-- {
310 b = append(b, se.group[j])
322 for j := len(se.minus) - 1; j >= 0; j-- {
323 b = append(b, se.minus[j])
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, se.decimal...)
338 for i := 0; i < 2-int(v); i++ {
343 b = append(b, se.currencyPositiveSuffix...)
345 b = append(b, symbol...)
350 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'se_SE'
351 // in accounting notation.
352 func (se *se_SE) FmtAccounting(num float64, v uint64, currency currency.Type) string {
354 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
355 symbol := se.currencies[currency]
356 l := len(s) + len(symbol) + 6 + 2*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, se.decimal[0])
371 for j := len(se.group) - 1; j >= 0; j-- {
372 b = append(b, se.group[j])
385 for j := len(se.minus) - 1; j >= 0; j-- {
386 b = append(b, se.minus[j])
392 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
393 b[i], b[j] = b[j], b[i]
399 b = append(b, se.decimal...)
402 for i := 0; i < 2-int(v); i++ {
408 b = append(b, se.currencyNegativeSuffix...)
409 b = append(b, symbol...)
412 b = append(b, se.currencyPositiveSuffix...)
413 b = append(b, symbol...)
419 // FmtDateShort returns the short date representation of 't' for 'se_SE'
420 func (se *se_SE) FmtDateShort(t time.Time) string {
422 b := make([]byte, 0, 32)
425 b = strconv.AppendInt(b, int64(t.Year()), 10)
427 b = strconv.AppendInt(b, int64(-t.Year()), 10)
430 b = append(b, []byte{0x2d}...)
436 b = strconv.AppendInt(b, int64(t.Month()), 10)
438 b = append(b, []byte{0x2d}...)
444 b = strconv.AppendInt(b, int64(t.Day()), 10)
449 // FmtDateMedium returns the medium date representation of 't' for 'se_SE'
450 func (se *se_SE) FmtDateMedium(t time.Time) string {
452 b := make([]byte, 0, 32)
455 b = strconv.AppendInt(b, int64(t.Year()), 10)
457 b = strconv.AppendInt(b, int64(-t.Year()), 10)
460 b = append(b, []byte{0x20}...)
461 b = append(b, se.monthsAbbreviated[t.Month()]...)
462 b = append(b, []byte{0x20}...)
463 b = strconv.AppendInt(b, int64(t.Day()), 10)
468 // FmtDateLong returns the long date representation of 't' for 'se_SE'
469 func (se *se_SE) FmtDateLong(t time.Time) string {
471 b := make([]byte, 0, 32)
474 b = strconv.AppendInt(b, int64(t.Year()), 10)
476 b = strconv.AppendInt(b, int64(-t.Year()), 10)
479 b = append(b, []byte{0x20}...)
480 b = append(b, se.monthsWide[t.Month()]...)
481 b = append(b, []byte{0x20}...)
482 b = strconv.AppendInt(b, int64(t.Day()), 10)
487 // FmtDateFull returns the full date representation of 't' for 'se_SE'
488 func (se *se_SE) FmtDateFull(t time.Time) string {
490 b := make([]byte, 0, 32)
493 b = strconv.AppendInt(b, int64(t.Year()), 10)
495 b = strconv.AppendInt(b, int64(-t.Year()), 10)
498 b = append(b, []byte{0x20}...)
499 b = append(b, se.monthsWide[t.Month()]...)
500 b = append(b, []byte{0x20}...)
501 b = strconv.AppendInt(b, int64(t.Day()), 10)
502 b = append(b, []byte{0x2c, 0x20}...)
503 b = append(b, se.daysWide[t.Weekday()]...)
508 // FmtTimeShort returns the short time representation of 't' for 'se_SE'
509 func (se *se_SE) FmtTimeShort(t time.Time) string {
511 b := make([]byte, 0, 32)
517 b = strconv.AppendInt(b, int64(t.Hour()), 10)
518 b = append(b, se.timeSeparator...)
524 b = strconv.AppendInt(b, int64(t.Minute()), 10)
529 // FmtTimeMedium returns the medium time representation of 't' for 'se_SE'
530 func (se *se_SE) FmtTimeMedium(t time.Time) string {
532 b := make([]byte, 0, 32)
538 b = strconv.AppendInt(b, int64(t.Hour()), 10)
539 b = append(b, se.timeSeparator...)
545 b = strconv.AppendInt(b, int64(t.Minute()), 10)
546 b = append(b, se.timeSeparator...)
552 b = strconv.AppendInt(b, int64(t.Second()), 10)
557 // FmtTimeLong returns the long time representation of 't' for 'se_SE'
558 func (se *se_SE) FmtTimeLong(t time.Time) string {
560 b := make([]byte, 0, 32)
566 b = strconv.AppendInt(b, int64(t.Hour()), 10)
567 b = append(b, se.timeSeparator...)
573 b = strconv.AppendInt(b, int64(t.Minute()), 10)
574 b = append(b, se.timeSeparator...)
580 b = strconv.AppendInt(b, int64(t.Second()), 10)
581 b = append(b, []byte{0x20}...)
589 // FmtTimeFull returns the full time representation of 't' for 'se_SE'
590 func (se *se_SE) FmtTimeFull(t time.Time) string {
592 b := make([]byte, 0, 32)
598 b = strconv.AppendInt(b, int64(t.Hour()), 10)
599 b = append(b, se.timeSeparator...)
605 b = strconv.AppendInt(b, int64(t.Minute()), 10)
606 b = append(b, se.timeSeparator...)
612 b = strconv.AppendInt(b, int64(t.Second()), 10)
613 b = append(b, []byte{0x20}...)
617 if btz, ok := se.timezones[tz]; ok {
618 b = append(b, btz...)