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 'it_IT' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{5, 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{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"},
62 monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"},
63 monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"},
64 daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
65 daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"},
66 daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"},
67 daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"},
68 periodsAbbreviated: []string{"AM", "PM"},
69 periodsNarrow: []string{"m.", "p."},
70 periodsWide: []string{"AM", "PM"},
71 erasAbbreviated: []string{"a.C.", "d.C."},
72 erasNarrow: []string{"aC", "dC"},
73 erasWide: []string{"avanti Cristo", "dopo Cristo"},
74 timezones: map[string]string{"ACST": "Ora standard dell’Australia centrale", "MEZ": "Ora standard dell’Europa centrale", "HNOG": "Ora standard della Groenlandia occidentale", "ACWDT": "Ora legale dell’Australia centroccidentale", "UYT": "Ora standard dell’Uruguay", "WIT": "Ora dell’Indonesia orientale", "JST": "Ora standard del Giappone", "HNPMX": "Ora standard del Pacifico (Messico)", "PDT": "Ora legale del Pacifico USA", "VET": "Ora del Venezuela", "HEOG": "Ora legale della Groenlandia occidentale", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "CST": "Ora standard centrale USA", "AEDT": "Ora legale dell’Australia orientale", "EDT": "Ora legale orientale USA", "WEZ": "Ora standard dell’Europa occidentale", "MDT": "MDT", "MESZ": "Ora legale dell’Europa centrale", "HEEG": "Ora legale della Groenlandia orientale", "HNT": "Ora standard di Terranova", "AKST": "Ora standard dell’Alaska", "HNCU": "Ora standard di Cuba", "MST": "MST", "UYST": "Ora legale dell’Uruguay", "HENOMX": "Ora legale del Messico nord-occidentale", "WAST": "Ora legale dell’Africa occidentale", "WART": "Ora standard dell’Argentina occidentale", "CLST": "Ora legale del Cile", "WESZ": "Ora legale dell’Europa occidentale", "GMT": "Ora del meridiano di Greenwich", "TMT": "Ora standard del Turkmenistan", "OEZ": "Ora standard dell’Europa orientale", "OESZ": "Ora legale dell’Europa orientale", "LHST": "Ora standard di Lord Howe", "GFT": "Ora della Guiana francese", "AST": "Ora standard dell’Atlantico", "HAT": "Ora legale di Terranova", "CAT": "Ora dell’Africa centrale", "WIB": "Ora dell’Indonesia occidentale", "SRT": "Ora del Suriname", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "TMST": "Ora legale del Turkmenistan", "WITA": "Ora dell’Indonesia centrale", "CLT": "Ora standard del Cile", "ACDT": "Ora legale dell’Australia centrale", "PST": "Ora standard del Pacifico USA", "JDT": "Ora legale del Giappone", "HKST": "Ora legale di Hong Kong", "EST": "Ora standard orientale USA", "SAST": "Ora dell’Africa meridionale", "∅∅∅": "Ora legale dell’Amazzonia", "CHADT": "Ora legale delle Chatham", "AWST": "Ora standard dell’Australia occidentale", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "NZDT": "Ora legale della Nuova Zelanda", "WARST": "Ora legale dell’Argentina occidentale", "GYT": "Ora della Guyana", "BOT": "Ora della Bolivia", "CDT": "Ora legale centrale USA", "MYT": "Ora della Malesia", "IST": "Ora standard dell’India", "ARST": "Ora legale dell’Argentina", "HNEG": "Ora standard della Groenlandia orientale", "ChST": "Ora di Chamorro", "HEPMX": "Ora legale del Pacifico (Messico)", "ADT": "Ora legale dell’Atlantico", "AEST": "Ora standard dell’Australia orientale", "COT": "Ora standard della Colombia", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "NZST": "Ora standard della Nuova Zelanda", "WAT": "Ora standard dell’Africa occidentale", "AKDT": "Ora legale dell’Alaska", "SGT": "Ora di Singapore", "HECU": "Ora legale di Cuba", "ART": "Ora standard dell’Argentina", "ACWST": "Ora standard dell’Australia centroccidentale", "HNNOMX": "Ora standard del Messico nord-occidentale", "EAT": "Ora dell’Africa orientale", "COST": "Ora legale della Colombia", "ECT": "Ora dell’Ecuador", "CHAST": "Ora standard delle Chatham", "BT": "Ora del Bhutan", "AWDT": "Ora legale dell’Australia occidentale", "LHDT": "Ora legale di Lord Howe", "HKT": "Ora standard di Hong Kong"},
78 // Locale returns the current translators string locale
79 func (it *it_IT) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'it_IT'
84 func (it *it_IT) PluralsCardinal() []locales.PluralRule {
85 return it.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'it_IT'
89 func (it *it_IT) PluralsOrdinal() []locales.PluralRule {
90 return it.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'it_IT'
94 func (it *it_IT) PluralsRange() []locales.PluralRule {
95 return it.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_IT'
99 func (it *it_IT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
104 if i == 1 && v == 0 {
105 return locales.PluralRuleOne
108 return locales.PluralRuleOther
111 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_IT'
112 func (it *it_IT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
116 if n == 11 || n == 8 || n == 80 || n == 800 {
117 return locales.PluralRuleMany
120 return locales.PluralRuleOther
123 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_IT'
124 func (it *it_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
126 start := it.CardinalPluralRule(num1, v1)
127 end := it.CardinalPluralRule(num2, v2)
129 if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
130 return locales.PluralRuleOther
131 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
132 return locales.PluralRuleOne
135 return locales.PluralRuleOther
139 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
140 func (it *it_IT) MonthAbbreviated(month time.Month) string {
141 return it.monthsAbbreviated[month]
144 // MonthsAbbreviated returns the locales abbreviated months
145 func (it *it_IT) MonthsAbbreviated() []string {
146 return it.monthsAbbreviated[1:]
149 // MonthNarrow returns the locales narrow month given the 'month' provided
150 func (it *it_IT) MonthNarrow(month time.Month) string {
151 return it.monthsNarrow[month]
154 // MonthsNarrow returns the locales narrow months
155 func (it *it_IT) MonthsNarrow() []string {
156 return it.monthsNarrow[1:]
159 // MonthWide returns the locales wide month given the 'month' provided
160 func (it *it_IT) MonthWide(month time.Month) string {
161 return it.monthsWide[month]
164 // MonthsWide returns the locales wide months
165 func (it *it_IT) MonthsWide() []string {
166 return it.monthsWide[1:]
169 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
170 func (it *it_IT) WeekdayAbbreviated(weekday time.Weekday) string {
171 return it.daysAbbreviated[weekday]
174 // WeekdaysAbbreviated returns the locales abbreviated weekdays
175 func (it *it_IT) WeekdaysAbbreviated() []string {
176 return it.daysAbbreviated
179 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
180 func (it *it_IT) WeekdayNarrow(weekday time.Weekday) string {
181 return it.daysNarrow[weekday]
184 // WeekdaysNarrow returns the locales narrow weekdays
185 func (it *it_IT) WeekdaysNarrow() []string {
189 // WeekdayShort returns the locales short weekday given the 'weekday' provided
190 func (it *it_IT) WeekdayShort(weekday time.Weekday) string {
191 return it.daysShort[weekday]
194 // WeekdaysShort returns the locales short weekdays
195 func (it *it_IT) WeekdaysShort() []string {
199 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
200 func (it *it_IT) WeekdayWide(weekday time.Weekday) string {
201 return it.daysWide[weekday]
204 // WeekdaysWide returns the locales wide weekdays
205 func (it *it_IT) WeekdaysWide() []string {
209 // Decimal returns the decimal point of number
210 func (it *it_IT) Decimal() string {
214 // Group returns the group of number
215 func (it *it_IT) Group() string {
219 // Group returns the minus sign of number
220 func (it *it_IT) Minus() string {
224 // FmtNumber returns 'num' with digits/precision of 'v' for 'it_IT' and handles both Whole and Real numbers based on 'v'
225 func (it *it_IT) FmtNumber(num float64, v uint64) string {
227 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
228 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
231 b := make([]byte, 0, l)
233 for i := len(s) - 1; i >= 0; i-- {
236 b = append(b, it.decimal[0])
243 b = append(b, it.group[0])
254 b = append(b, it.minus[0])
258 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
259 b[i], b[j] = b[j], b[i]
265 // FmtPercent returns 'num' with digits/precision of 'v' for 'it_IT' and handles both Whole and Real numbers based on 'v'
266 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
267 func (it *it_IT) FmtPercent(num float64, v uint64) string {
268 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
270 b := make([]byte, 0, l)
272 for i := len(s) - 1; i >= 0; i-- {
275 b = append(b, it.decimal[0])
283 b = append(b, it.minus[0])
287 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
288 b[i], b[j] = b[j], b[i]
291 b = append(b, it.percent...)
296 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_IT'
297 func (it *it_IT) FmtCurrency(num float64, v uint64, currency currency.Type) string {
299 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
300 symbol := it.currencies[currency]
301 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
304 b := make([]byte, 0, l)
306 for i := len(s) - 1; i >= 0; i-- {
309 b = append(b, it.decimal[0])
316 b = append(b, it.group[0])
327 b = append(b, it.minus[0])
331 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
332 b[i], b[j] = b[j], b[i]
338 b = append(b, it.decimal...)
341 for i := 0; i < 2-int(v); i++ {
346 b = append(b, it.currencyPositiveSuffix...)
348 b = append(b, symbol...)
353 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_IT'
354 // in accounting notation.
355 func (it *it_IT) FmtAccounting(num float64, v uint64, currency currency.Type) string {
357 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
358 symbol := it.currencies[currency]
359 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
362 b := make([]byte, 0, l)
364 for i := len(s) - 1; i >= 0; i-- {
367 b = append(b, it.decimal[0])
374 b = append(b, it.group[0])
386 b = append(b, it.minus[0])
391 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
392 b[i], b[j] = b[j], b[i]
398 b = append(b, it.decimal...)
401 for i := 0; i < 2-int(v); i++ {
407 b = append(b, it.currencyNegativeSuffix...)
408 b = append(b, symbol...)
411 b = append(b, it.currencyPositiveSuffix...)
412 b = append(b, symbol...)
418 // FmtDateShort returns the short date representation of 't' for 'it_IT'
419 func (it *it_IT) FmtDateShort(t time.Time) string {
421 b := make([]byte, 0, 32)
427 b = strconv.AppendInt(b, int64(t.Day()), 10)
428 b = append(b, []byte{0x2f}...)
434 b = strconv.AppendInt(b, int64(t.Month()), 10)
436 b = append(b, []byte{0x2f}...)
439 b = append(b, strconv.Itoa(t.Year())[2:]...)
441 b = append(b, strconv.Itoa(t.Year())[1:]...)
447 // FmtDateMedium returns the medium date representation of 't' for 'it_IT'
448 func (it *it_IT) FmtDateMedium(t time.Time) string {
450 b := make([]byte, 0, 32)
456 b = strconv.AppendInt(b, int64(t.Day()), 10)
457 b = append(b, []byte{0x20}...)
458 b = append(b, it.monthsAbbreviated[t.Month()]...)
459 b = append(b, []byte{0x20}...)
462 b = strconv.AppendInt(b, int64(t.Year()), 10)
464 b = strconv.AppendInt(b, int64(-t.Year()), 10)
470 // FmtDateLong returns the long date representation of 't' for 'it_IT'
471 func (it *it_IT) FmtDateLong(t time.Time) string {
473 b := make([]byte, 0, 32)
475 b = strconv.AppendInt(b, int64(t.Day()), 10)
476 b = append(b, []byte{0x20}...)
477 b = append(b, it.monthsWide[t.Month()]...)
478 b = append(b, []byte{0x20}...)
481 b = strconv.AppendInt(b, int64(t.Year()), 10)
483 b = strconv.AppendInt(b, int64(-t.Year()), 10)
489 // FmtDateFull returns the full date representation of 't' for 'it_IT'
490 func (it *it_IT) FmtDateFull(t time.Time) string {
492 b := make([]byte, 0, 32)
494 b = append(b, it.daysWide[t.Weekday()]...)
495 b = append(b, []byte{0x20}...)
496 b = strconv.AppendInt(b, int64(t.Day()), 10)
497 b = append(b, []byte{0x20}...)
498 b = append(b, it.monthsWide[t.Month()]...)
499 b = append(b, []byte{0x20}...)
502 b = strconv.AppendInt(b, int64(t.Year()), 10)
504 b = strconv.AppendInt(b, int64(-t.Year()), 10)
510 // FmtTimeShort returns the short time representation of 't' for 'it_IT'
511 func (it *it_IT) FmtTimeShort(t time.Time) string {
513 b := make([]byte, 0, 32)
519 b = strconv.AppendInt(b, int64(t.Hour()), 10)
520 b = append(b, it.timeSeparator...)
526 b = strconv.AppendInt(b, int64(t.Minute()), 10)
531 // FmtTimeMedium returns the medium time representation of 't' for 'it_IT'
532 func (it *it_IT) FmtTimeMedium(t time.Time) string {
534 b := make([]byte, 0, 32)
540 b = strconv.AppendInt(b, int64(t.Hour()), 10)
541 b = append(b, it.timeSeparator...)
547 b = strconv.AppendInt(b, int64(t.Minute()), 10)
548 b = append(b, it.timeSeparator...)
554 b = strconv.AppendInt(b, int64(t.Second()), 10)
559 // FmtTimeLong returns the long time representation of 't' for 'it_IT'
560 func (it *it_IT) FmtTimeLong(t time.Time) string {
562 b := make([]byte, 0, 32)
568 b = strconv.AppendInt(b, int64(t.Hour()), 10)
569 b = append(b, it.timeSeparator...)
575 b = strconv.AppendInt(b, int64(t.Minute()), 10)
576 b = append(b, it.timeSeparator...)
582 b = strconv.AppendInt(b, int64(t.Second()), 10)
583 b = append(b, []byte{0x20}...)
591 // FmtTimeFull returns the full time representation of 't' for 'it_IT'
592 func (it *it_IT) FmtTimeFull(t time.Time) string {
594 b := make([]byte, 0, 32)
600 b = strconv.AppendInt(b, int64(t.Hour()), 10)
601 b = append(b, it.timeSeparator...)
607 b = strconv.AppendInt(b, int64(t.Minute()), 10)
608 b = append(b, it.timeSeparator...)
614 b = strconv.AppendInt(b, int64(t.Second()), 10)
615 b = append(b, []byte{0x20}...)
619 if btz, ok := it.timezones[tz]; ok {
620 b = append(b, btz...)