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 currencyPositivePrefix string
26 currencyNegativePrefix 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_CH' 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 currencyPositivePrefix: " ",
60 currencyNegativePrefix: " ",
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{"ADT": "Ora legale dell’Atlantico", "AKST": "Ora standard dell’Alaska", "ACST": "Ora standard dell’Australia centrale", "AWST": "Ora standard dell’Australia occidentale", "WARST": "Ora legale dell’Argentina occidentale", "JST": "Ora standard del Giappone", "HNOG": "Ora standard della Groenlandia occidentale", "GYT": "Ora della Guyana", "AKDT": "Ora legale dell’Alaska", "∅∅∅": "Ora legale dell’Amazzonia", "WEZ": "Ora standard dell’Europa occidentale", "BOT": "Ora della Bolivia", "CST": "Ora standard centrale USA", "CDT": "Ora legale centrale USA", "NZST": "Ora standard della Nuova Zelanda", "LHDT": "Ora legale di Lord Howe", "HENOMX": "Ora legale del Messico nord-occidentale", "AST": "Ora standard dell’Atlantico", "EAT": "Ora dell’Africa orientale", "ACWST": "Ora standard dell’Australia centroccidentale", "VET": "Ora del Venezuela", "CLST": "Ora legale del Cile", "EST": "Ora standard orientale USA", "ECT": "Ora dell’Ecuador", "PDT": "Ora legale del Pacifico USA", "UYST": "Ora legale dell’Uruguay", "MEZ": "Ora standard dell’Europa centrale", "COT": "Ora standard della Colombia", "GFT": "Ora della Guiana francese", "CAT": "Ora dell’Africa centrale", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "SRT": "Ora del Suriname", "TMT": "Ora standard del Turkmenistan", "HKT": "Ora standard di Hong Kong", "PST": "Ora standard del Pacifico USA", "COST": "Ora legale della Colombia", "EDT": "Ora legale orientale USA", "HNCU": "Ora standard di Cuba", "LHST": "Ora standard di Lord Howe", "IST": "Ora standard dell’India", "HNT": "Ora standard di Terranova", "HECU": "Ora legale di Cuba", "MDT": "MDT", "OEZ": "Ora standard dell’Europa orientale", "ART": "Ora standard dell’Argentina", "SGT": "Ora di Singapore", "CHAST": "Ora standard delle Chatham", "MST": "MST", "ChST": "Ora di Chamorro", "BT": "Ora del Bhutan", "ACWDT": "Ora legale dell’Australia centroccidentale", "WART": "Ora standard dell’Argentina occidentale", "AEDT": "Ora legale dell’Australia orientale", "HKST": "Ora legale di Hong Kong", "ACDT": "Ora legale dell’Australia centrale", "WESZ": "Ora legale dell’Europa occidentale", "HEPMX": "Ora legale del Pacifico (Messico)", "CHADT": "Ora legale delle Chatham", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "MESZ": "Ora legale dell’Europa centrale", "WITA": "Ora dell’Indonesia centrale", "ARST": "Ora legale dell’Argentina", "HAT": "Ora legale di Terranova", "WIT": "Ora dell’Indonesia orientale", "HEEG": "Ora legale della Groenlandia orientale", "WIB": "Ora dell’Indonesia occidentale", "AWDT": "Ora legale dell’Australia occidentale", "HNNOMX": "Ora standard del Messico nord-occidentale", "AEST": "Ora standard dell’Australia orientale", "WAST": "Ora legale dell’Africa occidentale", "CLT": "Ora standard del Cile", "MYT": "Ora della Malesia", "OESZ": "Ora legale dell’Europa orientale", "JDT": "Ora legale del Giappone", "HEOG": "Ora legale della Groenlandia occidentale", "SAST": "Ora dell’Africa meridionale", "WAT": "Ora standard dell’Africa occidentale", "HNEG": "Ora standard della Groenlandia orientale", "UYT": "Ora standard dell’Uruguay", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "NZDT": "Ora legale della Nuova Zelanda", "TMST": "Ora legale del Turkmenistan", "GMT": "Ora del meridiano di Greenwich", "HNPMX": "Ora standard del Pacifico (Messico)"},
78 // Locale returns the current translators string locale
79 func (it *it_CH) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'it_CH'
84 func (it *it_CH) PluralsCardinal() []locales.PluralRule {
85 return it.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'it_CH'
89 func (it *it_CH) PluralsOrdinal() []locales.PluralRule {
90 return it.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'it_CH'
94 func (it *it_CH) PluralsRange() []locales.PluralRule {
95 return it.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH'
99 func (it *it_CH) 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_CH'
112 func (it *it_CH) 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_CH'
124 func (it *it_CH) 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_CH) MonthAbbreviated(month time.Month) string {
141 return it.monthsAbbreviated[month]
144 // MonthsAbbreviated returns the locales abbreviated months
145 func (it *it_CH) MonthsAbbreviated() []string {
146 return it.monthsAbbreviated[1:]
149 // MonthNarrow returns the locales narrow month given the 'month' provided
150 func (it *it_CH) MonthNarrow(month time.Month) string {
151 return it.monthsNarrow[month]
154 // MonthsNarrow returns the locales narrow months
155 func (it *it_CH) MonthsNarrow() []string {
156 return it.monthsNarrow[1:]
159 // MonthWide returns the locales wide month given the 'month' provided
160 func (it *it_CH) MonthWide(month time.Month) string {
161 return it.monthsWide[month]
164 // MonthsWide returns the locales wide months
165 func (it *it_CH) MonthsWide() []string {
166 return it.monthsWide[1:]
169 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
170 func (it *it_CH) WeekdayAbbreviated(weekday time.Weekday) string {
171 return it.daysAbbreviated[weekday]
174 // WeekdaysAbbreviated returns the locales abbreviated weekdays
175 func (it *it_CH) WeekdaysAbbreviated() []string {
176 return it.daysAbbreviated
179 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
180 func (it *it_CH) WeekdayNarrow(weekday time.Weekday) string {
181 return it.daysNarrow[weekday]
184 // WeekdaysNarrow returns the locales narrow weekdays
185 func (it *it_CH) WeekdaysNarrow() []string {
189 // WeekdayShort returns the locales short weekday given the 'weekday' provided
190 func (it *it_CH) WeekdayShort(weekday time.Weekday) string {
191 return it.daysShort[weekday]
194 // WeekdaysShort returns the locales short weekdays
195 func (it *it_CH) WeekdaysShort() []string {
199 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
200 func (it *it_CH) WeekdayWide(weekday time.Weekday) string {
201 return it.daysWide[weekday]
204 // WeekdaysWide returns the locales wide weekdays
205 func (it *it_CH) WeekdaysWide() []string {
209 // Decimal returns the decimal point of number
210 func (it *it_CH) Decimal() string {
214 // Group returns the group of number
215 func (it *it_CH) Group() string {
219 // Group returns the minus sign of number
220 func (it *it_CH) Minus() string {
224 // FmtNumber returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
225 func (it *it_CH) FmtNumber(num float64, v uint64) string {
227 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
228 l := len(s) + 2 + 3*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 for j := len(it.group) - 1; j >= 0; j-- {
244 b = append(b, it.group[j])
256 b = append(b, it.minus[0])
260 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
261 b[i], b[j] = b[j], b[i]
267 // FmtPercent returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v'
268 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
269 func (it *it_CH) FmtPercent(num float64, v uint64) string {
270 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
272 b := make([]byte, 0, l)
274 for i := len(s) - 1; i >= 0; i-- {
277 b = append(b, it.decimal[0])
285 b = append(b, it.minus[0])
289 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
290 b[i], b[j] = b[j], b[i]
293 b = append(b, it.percent...)
298 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
299 func (it *it_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
301 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
302 symbol := it.currencies[currency]
303 l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
306 b := make([]byte, 0, l)
308 for i := len(s) - 1; i >= 0; i-- {
311 b = append(b, it.decimal[0])
318 for j := len(it.group) - 1; j >= 0; j-- {
319 b = append(b, it.group[j])
330 for j := len(symbol) - 1; j >= 0; j-- {
331 b = append(b, symbol[j])
334 for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
335 b = append(b, it.currencyPositivePrefix[j])
339 b = append(b, it.minus[0])
343 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
344 b[i], b[j] = b[j], b[i]
350 b = append(b, it.decimal...)
353 for i := 0; i < 2-int(v); i++ {
361 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH'
362 // in accounting notation.
363 func (it *it_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
365 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
366 symbol := it.currencies[currency]
367 l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
370 b := make([]byte, 0, l)
372 for i := len(s) - 1; i >= 0; i-- {
375 b = append(b, it.decimal[0])
382 for j := len(it.group) - 1; j >= 0; j-- {
383 b = append(b, it.group[j])
396 for j := len(symbol) - 1; j >= 0; j-- {
397 b = append(b, symbol[j])
400 for j := len(it.currencyNegativePrefix) - 1; j >= 0; j-- {
401 b = append(b, it.currencyNegativePrefix[j])
404 b = append(b, it.minus[0])
408 for j := len(symbol) - 1; j >= 0; j-- {
409 b = append(b, symbol[j])
412 for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- {
413 b = append(b, it.currencyPositivePrefix[j])
419 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
420 b[i], b[j] = b[j], b[i]
426 b = append(b, it.decimal...)
429 for i := 0; i < 2-int(v); i++ {
437 // FmtDateShort returns the short date representation of 't' for 'it_CH'
438 func (it *it_CH) FmtDateShort(t time.Time) string {
440 b := make([]byte, 0, 32)
446 b = strconv.AppendInt(b, int64(t.Day()), 10)
447 b = append(b, []byte{0x2e}...)
453 b = strconv.AppendInt(b, int64(t.Month()), 10)
455 b = append(b, []byte{0x2e}...)
458 b = append(b, strconv.Itoa(t.Year())[2:]...)
460 b = append(b, strconv.Itoa(t.Year())[1:]...)
466 // FmtDateMedium returns the medium date representation of 't' for 'it_CH'
467 func (it *it_CH) FmtDateMedium(t time.Time) string {
469 b := make([]byte, 0, 32)
471 b = strconv.AppendInt(b, int64(t.Day()), 10)
472 b = append(b, []byte{0x20}...)
473 b = append(b, it.monthsAbbreviated[t.Month()]...)
474 b = append(b, []byte{0x20}...)
477 b = strconv.AppendInt(b, int64(t.Year()), 10)
479 b = strconv.AppendInt(b, int64(-t.Year()), 10)
485 // FmtDateLong returns the long date representation of 't' for 'it_CH'
486 func (it *it_CH) FmtDateLong(t time.Time) string {
488 b := make([]byte, 0, 32)
490 b = strconv.AppendInt(b, int64(t.Day()), 10)
491 b = append(b, []byte{0x20}...)
492 b = append(b, it.monthsWide[t.Month()]...)
493 b = append(b, []byte{0x20}...)
496 b = strconv.AppendInt(b, int64(t.Year()), 10)
498 b = strconv.AppendInt(b, int64(-t.Year()), 10)
504 // FmtDateFull returns the full date representation of 't' for 'it_CH'
505 func (it *it_CH) FmtDateFull(t time.Time) string {
507 b := make([]byte, 0, 32)
509 b = append(b, it.daysWide[t.Weekday()]...)
510 b = append(b, []byte{0x2c, 0x20}...)
511 b = strconv.AppendInt(b, int64(t.Day()), 10)
512 b = append(b, []byte{0x20}...)
513 b = append(b, it.monthsWide[t.Month()]...)
514 b = append(b, []byte{0x20}...)
517 b = strconv.AppendInt(b, int64(t.Year()), 10)
519 b = strconv.AppendInt(b, int64(-t.Year()), 10)
525 // FmtTimeShort returns the short time representation of 't' for 'it_CH'
526 func (it *it_CH) FmtTimeShort(t time.Time) string {
528 b := make([]byte, 0, 32)
534 b = strconv.AppendInt(b, int64(t.Hour()), 10)
535 b = append(b, it.timeSeparator...)
541 b = strconv.AppendInt(b, int64(t.Minute()), 10)
546 // FmtTimeMedium returns the medium time representation of 't' for 'it_CH'
547 func (it *it_CH) FmtTimeMedium(t time.Time) string {
549 b := make([]byte, 0, 32)
555 b = strconv.AppendInt(b, int64(t.Hour()), 10)
556 b = append(b, it.timeSeparator...)
562 b = strconv.AppendInt(b, int64(t.Minute()), 10)
563 b = append(b, it.timeSeparator...)
569 b = strconv.AppendInt(b, int64(t.Second()), 10)
574 // FmtTimeLong returns the long time representation of 't' for 'it_CH'
575 func (it *it_CH) FmtTimeLong(t time.Time) string {
577 b := make([]byte, 0, 32)
583 b = strconv.AppendInt(b, int64(t.Hour()), 10)
584 b = append(b, it.timeSeparator...)
590 b = strconv.AppendInt(b, int64(t.Minute()), 10)
591 b = append(b, it.timeSeparator...)
597 b = strconv.AppendInt(b, int64(t.Second()), 10)
598 b = append(b, []byte{0x20}...)
606 // FmtTimeFull returns the full time representation of 't' for 'it_CH'
607 func (it *it_CH) FmtTimeFull(t time.Time) string {
609 b := make([]byte, 0, 32)
615 b = strconv.AppendInt(b, int64(t.Hour()), 10)
616 b = append(b, it.timeSeparator...)
622 b = strconv.AppendInt(b, int64(t.Minute()), 10)
623 b = append(b, it.timeSeparator...)
629 b = strconv.AppendInt(b, int64(t.Second()), 10)
630 b = append(b, []byte{0x20}...)
634 if btz, ok := it.timezones[tz]; ok {
635 b = append(b, btz...)