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 'sv_AX' locale
46 func New() locales.Translator {
49 pluralsCardinal: []locales.PluralRule{2, 6},
50 pluralsOrdinal: []locales.PluralRule{2, 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", "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{"", "jan.", "feb.", "mars", "apr.", "maj", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "dec."},
64 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
65 monthsWide: []string{"", "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december"},
66 daysAbbreviated: []string{"sön", "mån", "tis", "ons", "tors", "fre", "lör"},
67 daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"},
68 daysShort: []string{"sö", "må", "ti", "on", "to", "fr", "lö"},
69 daysWide: []string{"söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag"},
70 periodsAbbreviated: []string{"fm", "em"},
71 periodsNarrow: []string{"fm", "em"},
72 periodsWide: []string{"fm", "em"},
73 erasAbbreviated: []string{"f.Kr.", "e.Kr."},
74 erasNarrow: []string{"f.Kr.", "e.Kr."},
75 erasWide: []string{"före Kristus", "efter Kristus"},
76 timezones: map[string]string{"CHADT": "Chatham, sommartid", "WITA": "centralindonesisk tid", "AEST": "östaustralisk normaltid", "HKT": "Hongkong, normaltid", "AKDT": "Alaska, sommartid", "HNPM": "S:t Pierre och Miquelon, normaltid", "MESZ": "centraleuropeisk sommartid", "VET": "venezuelansk tid", "OESZ": "östeuropeisk sommartid", "ACDT": "centralaustralisk sommartid", "WEZ": "västeuropeisk normaltid", "SGT": "Singaporetid", "HECU": "kubansk sommartid", "CDT": "centralnordamerikansk sommartid", "HEOG": "västgrönländsk sommartid", "WAT": "västafrikansk normaltid", "WAST": "västafrikansk sommartid", "EST": "östnordamerikansk normaltid", "EDT": "östnordamerikansk sommartid", "COT": "colombiansk normaltid", "HNNOMX": "nordvästmexikansk normaltid", "IST": "indisk tid", "AST": "nordamerikansk atlantnormaltid", "HNEG": "östgrönländsk normaltid", "WIT": "östindonesisk tid", "MEZ": "centraleuropeisk normaltid", "NZST": "nyzeeländsk normaltid", "JST": "japansk normaltid", "HNT": "Newfoundland, normaltid", "ECT": "ecuadoriansk tid", "MDT": "Macausommartid", "UYT": "uruguayansk normaltid", "NZDT": "nyzeeländsk sommartid", "JDT": "japansk sommartid", "AKST": "Alaska, normaltid", "HNPMX": "mexikansk stillahavstid, normaltid", "TMST": "turkmensk sommartid", "WARST": "västargentinsk sommartid", "PST": "västnordamerikansk normaltid", "AWDT": "västaustralisk sommartid", "SRT": "Surinamtid", "CST": "centralnordamerikansk normaltid", "UYST": "uruguayansk sommartid", "ARST": "östargentinsk sommartid", "AEDT": "östaustralisk sommartid", "CLT": "chilensk normaltid", "GMT": "Greenwichtid", "AWST": "västaustralisk normaltid", "COST": "colombiansk sommartid", "HKST": "Hongkong, sommartid", "WIB": "västindonesisk tid", "ADT": "nordamerikansk atlantsommartid", "EAT": "östafrikansk tid", "HAT": "Newfoundland, sommartid", "GYT": "Guyanatid", "HAST": "Honolulu, normaltid", "CHAST": "Chatham, normaltid", "WART": "västargentinsk normaltid", "HENOMX": "nordvästmexikansk sommartid", "HNOG": "västgrönländsk normaltid", "GFT": "Franska Guyanatid", "∅∅∅": "Amazonas, sommartid", "ChST": "Chamorrotid", "OEZ": "östeuropeisk normaltid", "CLST": "chilensk sommartid", "WESZ": "västeuropeisk sommartid", "HEPM": "S:t Pierre och Miquelon, sommartid", "MST": "Macaunormaltid", "TMT": "turkmensk normaltid", "LHDT": "Lord Howe, sommartid", "ACST": "centralaustralisk normaltid", "HNCU": "kubansk normaltid", "ART": "östargentinsk normaltid", "SAST": "sydafrikansk tid", "BOT": "boliviansk tid", "HADT": "Honolulu, sommartid", "LHST": "Lord Howe, normaltid", "CAT": "centralafrikansk tid", "ACWST": "västcentralaustralisk normaltid", "BT": "bhutansk tid", "ACWDT": "västcentralaustralisk sommartid", "MYT": "malaysisk tid", "HEEG": "östgrönländsk sommartid", "HEPMX": "mexikansk stillahavstid, sommartid", "PDT": "västnordamerikansk sommartid"},
80 // Locale returns the current translators string locale
81 func (sv *sv_AX) Locale() string {
85 // PluralsCardinal returns the list of cardinal plural rules associated with 'sv_AX'
86 func (sv *sv_AX) PluralsCardinal() []locales.PluralRule {
87 return sv.pluralsCardinal
90 // PluralsOrdinal returns the list of ordinal plural rules associated with 'sv_AX'
91 func (sv *sv_AX) PluralsOrdinal() []locales.PluralRule {
92 return sv.pluralsOrdinal
95 // PluralsRange returns the list of range plural rules associated with 'sv_AX'
96 func (sv *sv_AX) PluralsRange() []locales.PluralRule {
97 return sv.pluralsRange
100 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sv_AX'
101 func (sv *sv_AX) 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 'sv_AX'
114 func (sv *sv_AX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
117 nMod10 := math.Mod(n, 10)
118 nMod100 := math.Mod(n, 100)
120 if (nMod10 == 1 || nMod10 == 2) && (nMod100 != 11 && nMod100 != 12) {
121 return locales.PluralRuleOne
124 return locales.PluralRuleOther
127 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sv_AX'
128 func (sv *sv_AX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
129 return locales.PluralRuleOther
132 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
133 func (sv *sv_AX) MonthAbbreviated(month time.Month) string {
134 return sv.monthsAbbreviated[month]
137 // MonthsAbbreviated returns the locales abbreviated months
138 func (sv *sv_AX) MonthsAbbreviated() []string {
139 return sv.monthsAbbreviated[1:]
142 // MonthNarrow returns the locales narrow month given the 'month' provided
143 func (sv *sv_AX) MonthNarrow(month time.Month) string {
144 return sv.monthsNarrow[month]
147 // MonthsNarrow returns the locales narrow months
148 func (sv *sv_AX) MonthsNarrow() []string {
149 return sv.monthsNarrow[1:]
152 // MonthWide returns the locales wide month given the 'month' provided
153 func (sv *sv_AX) MonthWide(month time.Month) string {
154 return sv.monthsWide[month]
157 // MonthsWide returns the locales wide months
158 func (sv *sv_AX) MonthsWide() []string {
159 return sv.monthsWide[1:]
162 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
163 func (sv *sv_AX) WeekdayAbbreviated(weekday time.Weekday) string {
164 return sv.daysAbbreviated[weekday]
167 // WeekdaysAbbreviated returns the locales abbreviated weekdays
168 func (sv *sv_AX) WeekdaysAbbreviated() []string {
169 return sv.daysAbbreviated
172 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
173 func (sv *sv_AX) WeekdayNarrow(weekday time.Weekday) string {
174 return sv.daysNarrow[weekday]
177 // WeekdaysNarrow returns the locales narrow weekdays
178 func (sv *sv_AX) WeekdaysNarrow() []string {
182 // WeekdayShort returns the locales short weekday given the 'weekday' provided
183 func (sv *sv_AX) WeekdayShort(weekday time.Weekday) string {
184 return sv.daysShort[weekday]
187 // WeekdaysShort returns the locales short weekdays
188 func (sv *sv_AX) WeekdaysShort() []string {
192 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
193 func (sv *sv_AX) WeekdayWide(weekday time.Weekday) string {
194 return sv.daysWide[weekday]
197 // WeekdaysWide returns the locales wide weekdays
198 func (sv *sv_AX) WeekdaysWide() []string {
202 // Decimal returns the decimal point of number
203 func (sv *sv_AX) Decimal() string {
207 // Group returns the group of number
208 func (sv *sv_AX) Group() string {
212 // Group returns the minus sign of number
213 func (sv *sv_AX) Minus() string {
217 // FmtNumber returns 'num' with digits/precision of 'v' for 'sv_AX' and handles both Whole and Real numbers based on 'v'
218 func (sv *sv_AX) FmtNumber(num float64, v uint64) string {
220 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
221 l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3
224 b := make([]byte, 0, l)
226 for i := len(s) - 1; i >= 0; i-- {
229 b = append(b, sv.decimal[0])
236 for j := len(sv.group) - 1; j >= 0; j-- {
237 b = append(b, sv.group[j])
249 for j := len(sv.minus) - 1; j >= 0; j-- {
250 b = append(b, sv.minus[j])
255 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
256 b[i], b[j] = b[j], b[i]
262 // FmtPercent returns 'num' with digits/precision of 'v' for 'sv_AX' and handles both Whole and Real numbers based on 'v'
263 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
264 func (sv *sv_AX) FmtPercent(num float64, v uint64) string {
265 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
267 b := make([]byte, 0, l)
269 for i := len(s) - 1; i >= 0; i-- {
272 b = append(b, sv.decimal[0])
280 for j := len(sv.minus) - 1; j >= 0; j-- {
281 b = append(b, sv.minus[j])
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, sv.percentSuffix...)
292 b = append(b, sv.percent...)
297 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sv_AX'
298 func (sv *sv_AX) FmtCurrency(num float64, v uint64, currency currency.Type) string {
300 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
301 symbol := sv.currencies[currency]
302 l := len(s) + len(symbol) + 6 + 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, sv.decimal[0])
317 for j := len(sv.group) - 1; j >= 0; j-- {
318 b = append(b, sv.group[j])
330 for j := len(sv.minus) - 1; j >= 0; j-- {
331 b = append(b, sv.minus[j])
336 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
337 b[i], b[j] = b[j], b[i]
343 b = append(b, sv.decimal...)
346 for i := 0; i < 2-int(v); i++ {
351 b = append(b, sv.currencyPositiveSuffix...)
353 b = append(b, symbol...)
358 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sv_AX'
359 // in accounting notation.
360 func (sv *sv_AX) FmtAccounting(num float64, v uint64, currency currency.Type) string {
362 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
363 symbol := sv.currencies[currency]
364 l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
367 b := make([]byte, 0, l)
369 for i := len(s) - 1; i >= 0; i-- {
372 b = append(b, sv.decimal[0])
379 for j := len(sv.group) - 1; j >= 0; j-- {
380 b = append(b, sv.group[j])
393 for j := len(sv.minus) - 1; j >= 0; j-- {
394 b = append(b, sv.minus[j])
400 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
401 b[i], b[j] = b[j], b[i]
407 b = append(b, sv.decimal...)
410 for i := 0; i < 2-int(v); i++ {
416 b = append(b, sv.currencyNegativeSuffix...)
417 b = append(b, symbol...)
420 b = append(b, sv.currencyPositiveSuffix...)
421 b = append(b, symbol...)
427 // FmtDateShort returns the short date representation of 't' for 'sv_AX'
428 func (sv *sv_AX) FmtDateShort(t time.Time) string {
430 b := make([]byte, 0, 32)
433 b = strconv.AppendInt(b, int64(t.Year()), 10)
435 b = strconv.AppendInt(b, int64(-t.Year()), 10)
438 b = append(b, []byte{0x2d}...)
444 b = strconv.AppendInt(b, int64(t.Month()), 10)
446 b = append(b, []byte{0x2d}...)
452 b = strconv.AppendInt(b, int64(t.Day()), 10)
457 // FmtDateMedium returns the medium date representation of 't' for 'sv_AX'
458 func (sv *sv_AX) FmtDateMedium(t time.Time) string {
460 b := make([]byte, 0, 32)
462 b = strconv.AppendInt(b, int64(t.Day()), 10)
463 b = append(b, []byte{0x20}...)
464 b = append(b, sv.monthsAbbreviated[t.Month()]...)
465 b = append(b, []byte{0x20}...)
468 b = strconv.AppendInt(b, int64(t.Year()), 10)
470 b = strconv.AppendInt(b, int64(-t.Year()), 10)
476 // FmtDateLong returns the long date representation of 't' for 'sv_AX'
477 func (sv *sv_AX) FmtDateLong(t time.Time) string {
479 b := make([]byte, 0, 32)
481 b = strconv.AppendInt(b, int64(t.Day()), 10)
482 b = append(b, []byte{0x20}...)
483 b = append(b, sv.monthsWide[t.Month()]...)
484 b = append(b, []byte{0x20}...)
487 b = strconv.AppendInt(b, int64(t.Year()), 10)
489 b = strconv.AppendInt(b, int64(-t.Year()), 10)
495 // FmtDateFull returns the full date representation of 't' for 'sv_AX'
496 func (sv *sv_AX) FmtDateFull(t time.Time) string {
498 b := make([]byte, 0, 32)
500 b = append(b, sv.daysWide[t.Weekday()]...)
501 b = append(b, []byte{0x20}...)
502 b = strconv.AppendInt(b, int64(t.Day()), 10)
503 b = append(b, []byte{0x20}...)
504 b = append(b, sv.monthsWide[t.Month()]...)
505 b = append(b, []byte{0x20}...)
508 b = strconv.AppendInt(b, int64(t.Year()), 10)
510 b = strconv.AppendInt(b, int64(-t.Year()), 10)
516 // FmtTimeShort returns the short time representation of 't' for 'sv_AX'
517 func (sv *sv_AX) FmtTimeShort(t time.Time) string {
519 b := make([]byte, 0, 32)
525 b = strconv.AppendInt(b, int64(t.Hour()), 10)
526 b = append(b, sv.timeSeparator...)
532 b = strconv.AppendInt(b, int64(t.Minute()), 10)
537 // FmtTimeMedium returns the medium time representation of 't' for 'sv_AX'
538 func (sv *sv_AX) FmtTimeMedium(t time.Time) string {
540 b := make([]byte, 0, 32)
546 b = strconv.AppendInt(b, int64(t.Hour()), 10)
547 b = append(b, sv.timeSeparator...)
553 b = strconv.AppendInt(b, int64(t.Minute()), 10)
554 b = append(b, sv.timeSeparator...)
560 b = strconv.AppendInt(b, int64(t.Second()), 10)
565 // FmtTimeLong returns the long time representation of 't' for 'sv_AX'
566 func (sv *sv_AX) FmtTimeLong(t time.Time) string {
568 b := make([]byte, 0, 32)
574 b = strconv.AppendInt(b, int64(t.Hour()), 10)
575 b = append(b, sv.timeSeparator...)
581 b = strconv.AppendInt(b, int64(t.Minute()), 10)
582 b = append(b, sv.timeSeparator...)
588 b = strconv.AppendInt(b, int64(t.Second()), 10)
589 b = append(b, []byte{0x20}...)
597 // FmtTimeFull returns the full time representation of 't' for 'sv_AX'
598 func (sv *sv_AX) FmtTimeFull(t time.Time) string {
600 b := make([]byte, 0, 32)
602 b = append(b, []byte{0x6b, 0x6c}...)
603 b = append(b, []byte{0x2e, 0x20}...)
609 b = strconv.AppendInt(b, int64(t.Hour()), 10)
610 b = append(b, sv.timeSeparator...)
616 b = strconv.AppendInt(b, int64(t.Minute()), 10)
617 b = append(b, sv.timeSeparator...)
623 b = strconv.AppendInt(b, int64(t.Second()), 10)
624 b = append(b, []byte{0x20}...)
628 if btz, ok := sv.timezones[tz]; ok {
629 b = append(b, btz...)