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 currencyPositiveSuffix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
30 daysAbbreviated []string
34 periodsAbbreviated []string
35 periodsNarrow []string
38 erasAbbreviated []string
41 timezones map[string]string
44 // New returns a new instance of translator for the 'is_IS' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{2, 6},
58 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"},
59 currencyPositiveSuffix: " ",
60 currencyNegativeSuffix: " ",
61 monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maí", "jún.", "júl.", "ágú.", "sep.", "okt.", "nóv.", "des."},
62 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "Á", "S", "O", "N", "D"},
63 monthsWide: []string{"", "janúar", "febrúar", "mars", "apríl", "maí", "júní", "júlí", "ágúst", "september", "október", "nóvember", "desember"},
64 daysAbbreviated: []string{"sun.", "mán.", "þri.", "mið.", "fim.", "fös.", "lau."},
65 daysNarrow: []string{"S", "M", "Þ", "M", "F", "F", "L"},
66 daysShort: []string{"su.", "má.", "þr.", "mi.", "fi.", "fö.", "la."},
67 daysWide: []string{"sunnudagur", "mánudagur", "þriðjudagur", "miðvikudagur", "fimmtudagur", "föstudagur", "laugardagur"},
68 periodsAbbreviated: []string{"f.h.", "e.h."},
69 periodsNarrow: []string{"f.", "e."},
70 periodsWide: []string{"f.h.", "e.h."},
71 erasAbbreviated: []string{"f.Kr.", "e.Kr."},
72 erasNarrow: []string{"f.k.", "e.k."},
73 erasWide: []string{"fyrir Krist", "eftir Krist"},
74 timezones: map[string]string{"AWST": "Staðaltími í Vestur-Ástralíu", "WAT": "Staðaltími í Vestur-Afríku", "ChST": "Chamorro-staðaltími", "MST": "MST", "CST": "Staðaltími í miðhluta Bandaríkjanna og Kanada", "ACWDT": "Sumartími í miðvesturhluta Ástralíu", "OESZ": "Sumartími í Austur-Evrópu", "ADT": "Sumartími á Atlantshafssvæðinu", "SAST": "Suður-Afríkutími", "ECT": "Ekvadortími", "WEZ": "Staðaltími í Vestur-Evrópu", "AKST": "Staðaltími í Alaska", "CHADT": "Sumartími í Chatham", "TMT": "Staðaltími í Túrkmenistan", "HNOG": "Staðaltími á Vestur-Grænlandi", "HEOG": "Sumartími á Vestur-Grænlandi", "HNEG": "Staðaltími á Austur-Grænlandi", "EST": "Staðaltími í austurhluta Bandaríkjanna og Kanada", "EDT": "Sumartími í austurhluta Bandaríkjanna og Kanada", "COT": "Staðaltími í Kólumbíu", "COST": "Sumartími í Kólumbíu", "MESZ": "Sumartími í Mið-Evrópu", "CLST": "Sumartími í Síle", "GFT": "Tími í Frönsku Gvæjana", "HEPM": "Sumartími á Sankti Pierre og Miquelon", "WIT": "Austur-Indónesíutími", "CHAST": "Staðaltími í Chatham", "ACDT": "Sumartími í Mið-Ástralíu", "PDT": "Sumartími á Kyrrahafssvæðinu", "NZST": "Staðaltími á Nýja-Sjálandi", "TMST": "Sumartími í Túrkmenistan", "VET": "Venesúelatími", "HKT": "Staðaltími í Hong Kong", "CLT": "Staðaltími í Síle", "HNPM": "Staðaltími á Sankti Pierre og Miquelon", "UYST": "Sumartími í Úrúgvæ", "UYT": "Staðaltími í Úrúgvæ", "PST": "Staðaltími á Kyrrahafssvæðinu", "AWDT": "Sumartími í Vestur-Ástralíu", "MEZ": "Staðaltími í Mið-Evrópu", "OEZ": "Staðaltími í Austur-Evrópu", "LHDT": "Sumartími á Lord Howe-eyju", "HKST": "Sumartími í Hong Kong", "∅∅∅": "Sumartími á Amasónsvæðinu", "HECU": "Sumartími á Kúbu", "SRT": "Súrinamtími", "ACWST": "Staðaltími í miðvesturhluta Ástralíu", "BT": "Bútantími", "CDT": "Sumartími í miðhluta Bandaríkjanna og Kanada", "HNNOMX": "Staðaltími í Norðvestur-Mexíkó", "AEDT": "Sumartími í Austur-Ástralíu", "ARST": "Sumartími í Argentínu", "WAST": "Sumartími í Vestur-Afríku", "HEEG": "Sumartími á Austur-Grænlandi", "GMT": "Greenwich-staðaltími", "HADT": "Sumartími á Havaí og Aleúta", "BOT": "Bólivíutími", "MDT": "MDT", "LHST": "Staðaltími á Lord Howe-eyju", "WART": "Staðaltími í Vestur-Argentínu", "WARST": "Sumartími í Vestur-Argentínu", "CAT": "Mið-Afríkutími", "SGT": "Singapúrtími", "ART": "Staðaltími í Argentínu", "EAT": "Austur-Afríkutími", "AKDT": "Sumartími í Alaska", "AEST": "Staðaltími í Austur-Ástralíu", "MYT": "Malasíutími", "HENOMX": "Sumartími í Norðvestur-Mexíkó", "JDT": "Sumartími í Japan", "IST": "Indlandstími", "HEPMX": "Sumartími í Mexíkó á Kyrrahafssvæðinu", "HNCU": "Staðaltími á Kúbu", "WESZ": "Sumartími í Vestur-Evrópu", "WIB": "Vestur-Indónesíutími", "NZDT": "Sumartími á Nýja-Sjálandi", "AST": "Staðaltími á Atlantshafssvæðinu", "HNT": "Staðaltími á Nýfundnalandi", "HNPMX": "Staðaltími í Mexíkó á Kyrrahafssvæðinu", "HAST": "Staðaltími á Havaí og Aleúta", "WITA": "Mið-Indónesíutími", "JST": "Staðaltími í Japan", "HAT": "Sumartími á Nýfundnalandi", "GYT": "Gvæjanatími", "ACST": "Staðaltími í Mið-Ástralíu"},
78 // Locale returns the current translators string locale
79 func (is *is_IS) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'is_IS'
84 func (is *is_IS) PluralsCardinal() []locales.PluralRule {
85 return is.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'is_IS'
89 func (is *is_IS) PluralsOrdinal() []locales.PluralRule {
90 return is.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'is_IS'
94 func (is *is_IS) PluralsRange() []locales.PluralRule {
95 return is.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'is_IS'
99 func (is *is_IS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
107 if (t == 0 && iMod10 == 1 && iMod100 != 11) || (t != 0) {
108 return locales.PluralRuleOne
111 return locales.PluralRuleOther
114 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'is_IS'
115 func (is *is_IS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116 return locales.PluralRuleOther
119 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'is_IS'
120 func (is *is_IS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
122 start := is.CardinalPluralRule(num1, v1)
123 end := is.CardinalPluralRule(num2, v2)
125 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
126 return locales.PluralRuleOne
127 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
128 return locales.PluralRuleOther
129 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
130 return locales.PluralRuleOne
133 return locales.PluralRuleOther
137 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
138 func (is *is_IS) MonthAbbreviated(month time.Month) string {
139 return is.monthsAbbreviated[month]
142 // MonthsAbbreviated returns the locales abbreviated months
143 func (is *is_IS) MonthsAbbreviated() []string {
144 return is.monthsAbbreviated[1:]
147 // MonthNarrow returns the locales narrow month given the 'month' provided
148 func (is *is_IS) MonthNarrow(month time.Month) string {
149 return is.monthsNarrow[month]
152 // MonthsNarrow returns the locales narrow months
153 func (is *is_IS) MonthsNarrow() []string {
154 return is.monthsNarrow[1:]
157 // MonthWide returns the locales wide month given the 'month' provided
158 func (is *is_IS) MonthWide(month time.Month) string {
159 return is.monthsWide[month]
162 // MonthsWide returns the locales wide months
163 func (is *is_IS) MonthsWide() []string {
164 return is.monthsWide[1:]
167 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
168 func (is *is_IS) WeekdayAbbreviated(weekday time.Weekday) string {
169 return is.daysAbbreviated[weekday]
172 // WeekdaysAbbreviated returns the locales abbreviated weekdays
173 func (is *is_IS) WeekdaysAbbreviated() []string {
174 return is.daysAbbreviated
177 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
178 func (is *is_IS) WeekdayNarrow(weekday time.Weekday) string {
179 return is.daysNarrow[weekday]
182 // WeekdaysNarrow returns the locales narrow weekdays
183 func (is *is_IS) WeekdaysNarrow() []string {
187 // WeekdayShort returns the locales short weekday given the 'weekday' provided
188 func (is *is_IS) WeekdayShort(weekday time.Weekday) string {
189 return is.daysShort[weekday]
192 // WeekdaysShort returns the locales short weekdays
193 func (is *is_IS) WeekdaysShort() []string {
197 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
198 func (is *is_IS) WeekdayWide(weekday time.Weekday) string {
199 return is.daysWide[weekday]
202 // WeekdaysWide returns the locales wide weekdays
203 func (is *is_IS) WeekdaysWide() []string {
207 // Decimal returns the decimal point of number
208 func (is *is_IS) Decimal() string {
212 // Group returns the group of number
213 func (is *is_IS) Group() string {
217 // Group returns the minus sign of number
218 func (is *is_IS) Minus() string {
222 // FmtNumber returns 'num' with digits/precision of 'v' for 'is_IS' and handles both Whole and Real numbers based on 'v'
223 func (is *is_IS) FmtNumber(num float64, v uint64) string {
225 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
226 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
229 b := make([]byte, 0, l)
231 for i := len(s) - 1; i >= 0; i-- {
234 b = append(b, is.decimal[0])
241 b = append(b, is.group[0])
252 b = append(b, is.minus[0])
256 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
257 b[i], b[j] = b[j], b[i]
263 // FmtPercent returns 'num' with digits/precision of 'v' for 'is_IS' and handles both Whole and Real numbers based on 'v'
264 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
265 func (is *is_IS) FmtPercent(num float64, v uint64) string {
266 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
268 b := make([]byte, 0, l)
270 for i := len(s) - 1; i >= 0; i-- {
273 b = append(b, is.decimal[0])
281 b = append(b, is.minus[0])
285 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
286 b[i], b[j] = b[j], b[i]
289 b = append(b, is.percent...)
294 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'is_IS'
295 func (is *is_IS) FmtCurrency(num float64, v uint64, currency currency.Type) string {
297 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
298 symbol := is.currencies[currency]
299 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
302 b := make([]byte, 0, l)
304 for i := len(s) - 1; i >= 0; i-- {
307 b = append(b, is.decimal[0])
314 b = append(b, is.group[0])
325 b = append(b, is.minus[0])
329 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
330 b[i], b[j] = b[j], b[i]
336 b = append(b, is.decimal...)
339 for i := 0; i < 2-int(v); i++ {
344 b = append(b, is.currencyPositiveSuffix...)
346 b = append(b, symbol...)
351 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'is_IS'
352 // in accounting notation.
353 func (is *is_IS) FmtAccounting(num float64, v uint64, currency currency.Type) string {
355 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
356 symbol := is.currencies[currency]
357 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
360 b := make([]byte, 0, l)
362 for i := len(s) - 1; i >= 0; i-- {
365 b = append(b, is.decimal[0])
372 b = append(b, is.group[0])
384 b = append(b, is.minus[0])
389 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
390 b[i], b[j] = b[j], b[i]
396 b = append(b, is.decimal...)
399 for i := 0; i < 2-int(v); i++ {
405 b = append(b, is.currencyNegativeSuffix...)
406 b = append(b, symbol...)
409 b = append(b, is.currencyPositiveSuffix...)
410 b = append(b, symbol...)
416 // FmtDateShort returns the short date representation of 't' for 'is_IS'
417 func (is *is_IS) FmtDateShort(t time.Time) string {
419 b := make([]byte, 0, 32)
421 b = strconv.AppendInt(b, int64(t.Day()), 10)
422 b = append(b, []byte{0x2e}...)
423 b = strconv.AppendInt(b, int64(t.Month()), 10)
424 b = append(b, []byte{0x2e}...)
427 b = strconv.AppendInt(b, int64(t.Year()), 10)
429 b = strconv.AppendInt(b, int64(-t.Year()), 10)
435 // FmtDateMedium returns the medium date representation of 't' for 'is_IS'
436 func (is *is_IS) FmtDateMedium(t time.Time) string {
438 b := make([]byte, 0, 32)
440 b = strconv.AppendInt(b, int64(t.Day()), 10)
441 b = append(b, []byte{0x2e, 0x20}...)
442 b = append(b, is.monthsAbbreviated[t.Month()]...)
443 b = append(b, []byte{0x20}...)
446 b = strconv.AppendInt(b, int64(t.Year()), 10)
448 b = strconv.AppendInt(b, int64(-t.Year()), 10)
454 // FmtDateLong returns the long date representation of 't' for 'is_IS'
455 func (is *is_IS) FmtDateLong(t time.Time) string {
457 b := make([]byte, 0, 32)
459 b = strconv.AppendInt(b, int64(t.Day()), 10)
460 b = append(b, []byte{0x2e, 0x20}...)
461 b = append(b, is.monthsWide[t.Month()]...)
462 b = append(b, []byte{0x20}...)
465 b = strconv.AppendInt(b, int64(t.Year()), 10)
467 b = strconv.AppendInt(b, int64(-t.Year()), 10)
473 // FmtDateFull returns the full date representation of 't' for 'is_IS'
474 func (is *is_IS) FmtDateFull(t time.Time) string {
476 b := make([]byte, 0, 32)
478 b = append(b, is.daysWide[t.Weekday()]...)
479 b = append(b, []byte{0x2c, 0x20}...)
480 b = strconv.AppendInt(b, int64(t.Day()), 10)
481 b = append(b, []byte{0x2e, 0x20}...)
482 b = append(b, is.monthsWide[t.Month()]...)
483 b = append(b, []byte{0x20}...)
486 b = strconv.AppendInt(b, int64(t.Year()), 10)
488 b = strconv.AppendInt(b, int64(-t.Year()), 10)
494 // FmtTimeShort returns the short time representation of 't' for 'is_IS'
495 func (is *is_IS) FmtTimeShort(t time.Time) string {
497 b := make([]byte, 0, 32)
503 b = strconv.AppendInt(b, int64(t.Hour()), 10)
504 b = append(b, is.timeSeparator...)
510 b = strconv.AppendInt(b, int64(t.Minute()), 10)
515 // FmtTimeMedium returns the medium time representation of 't' for 'is_IS'
516 func (is *is_IS) FmtTimeMedium(t time.Time) string {
518 b := make([]byte, 0, 32)
524 b = strconv.AppendInt(b, int64(t.Hour()), 10)
525 b = append(b, is.timeSeparator...)
531 b = strconv.AppendInt(b, int64(t.Minute()), 10)
532 b = append(b, is.timeSeparator...)
538 b = strconv.AppendInt(b, int64(t.Second()), 10)
543 // FmtTimeLong returns the long time representation of 't' for 'is_IS'
544 func (is *is_IS) FmtTimeLong(t time.Time) string {
546 b := make([]byte, 0, 32)
552 b = strconv.AppendInt(b, int64(t.Hour()), 10)
553 b = append(b, is.timeSeparator...)
559 b = strconv.AppendInt(b, int64(t.Minute()), 10)
560 b = append(b, is.timeSeparator...)
566 b = strconv.AppendInt(b, int64(t.Second()), 10)
567 b = append(b, []byte{0x20}...)
575 // FmtTimeFull returns the full time representation of 't' for 'is_IS'
576 func (is *is_IS) FmtTimeFull(t time.Time) string {
578 b := make([]byte, 0, 32)
584 b = strconv.AppendInt(b, int64(t.Hour()), 10)
585 b = append(b, is.timeSeparator...)
591 b = strconv.AppendInt(b, int64(t.Minute()), 10)
592 b = append(b, is.timeSeparator...)
598 b = strconv.AppendInt(b, int64(t.Second()), 10)
599 b = append(b, []byte{0x20}...)
603 if btz, ok := is.timezones[tz]; ok {
604 b = append(b, btz...)