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 'de_CH' 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 currencyPositivePrefix: " ",
60 currencyNegativePrefix: " ",
61 monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."},
62 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
63 monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"},
64 daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."},
65 daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"},
66 daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."},
67 daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"},
68 periodsAbbreviated: []string{"vorm.", "nachm."},
69 periodsNarrow: []string{"vm.", "nm."},
70 periodsWide: []string{"vorm.", "nachm."},
71 erasAbbreviated: []string{"v. Chr.", "n. Chr."},
72 erasNarrow: []string{"v. Chr.", "n. Chr."},
73 erasWide: []string{"v. Chr.", "n. Chr."},
74 timezones: map[string]string{"SAST": "Südafrikanische Zeit", "NZDT": "Neuseeland-Sommerzeit", "TMT": "Turkmenistan-Normalzeit", "AEST": "Ostaustralische Normalzeit", "HEOG": "Westgrönland-Sommerzeit", "ART": "Argentinische Normalzeit", "ADT": "Atlantik-Sommerzeit", "WAST": "Westafrikanische Sommerzeit", "HNEG": "Ostgrönland-Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "∅∅∅": "Amazonas-Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "AEDT": "Ostaustralische Sommerzeit", "HKST": "Hongkong-Sommerzeit", "ChST": "Chamorro-Zeit", "CHADT": "Chatham-Sommerzeit", "LHDT": "Lord-Howe-Sommerzeit", "WART": "Westargentinische Normalzeit", "WITA": "Zentralindonesische Zeit", "JDT": "Japanische Sommerzeit", "IST": "Indische Zeit", "SGT": "Singapur-Zeit", "BOT": "Bolivianische Zeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "HAST": "Hawaii-Aleuten-Normalzeit", "WESZ": "Westeuropäische Sommerzeit", "MST": "Macau-Normalzeit", "HKT": "Hongkong-Normalzeit", "CLT": "Chilenische Normalzeit", "ECT": "Ecuadorianische Zeit", "AKDT": "Alaska-Sommerzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "WAT": "Westafrikanische Normalzeit", "SRT": "Suriname-Zeit", "TMST": "Turkmenistan-Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "AWDT": "Westaustralische Sommerzeit", "VET": "Venezuela-Zeit", "JST": "Japanische Normalzeit", "WEZ": "Westeuropäische Normalzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "WIB": "Westindonesische Zeit", "CHAST": "Chatham-Normalzeit", "ARST": "Argentinische Sommerzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "GFT": "Französisch-Guayana-Zeit", "HAT": "Neufundland-Sommerzeit", "GYT": "Guyana-Zeit", "MYT": "Malaysische Zeit", "UYST": "Uruguayanische Sommerzeit", "AKST": "Alaska-Normalzeit", "CAT": "Zentralafrikanische Zeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "MDT": "Macau-Sommerzeit", "BT": "Bhutan-Zeit", "AWST": "Westaustralische Normalzeit", "HNOG": "Westgrönland-Normalzeit", "COT": "Kolumbianische Normalzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "HEEG": "Ostgrönland-Sommerzeit", "EAT": "Ostafrikanische Zeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "MEZ": "Mitteleuropäische Normalzeit", "MESZ": "Mitteleuropäische Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "AST": "Atlantik-Normalzeit", "COST": "Kolumbianische Sommerzeit", "HNCU": "Kubanische Normalzeit", "HECU": "Kubanische Sommerzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "WIT": "Ostindonesische Zeit", "LHST": "Lord-Howe-Normalzeit", "WARST": "Westargentinische Sommerzeit", "CLST": "Chilenische Sommerzeit", "HNT": "Neufundland-Normalzeit", "ACST": "Zentralaustralische Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "UYT": "Uruguyanische Normalzeit", "NZST": "Neuseeland-Normalzeit", "CST": "Nordamerikanische Inland-Normalzeit"},
78 // Locale returns the current translators string locale
79 func (de *de_CH) Locale() string {
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'de_CH'
84 func (de *de_CH) PluralsCardinal() []locales.PluralRule {
85 return de.pluralsCardinal
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'de_CH'
89 func (de *de_CH) PluralsOrdinal() []locales.PluralRule {
90 return de.pluralsOrdinal
93 // PluralsRange returns the list of range plural rules associated with 'de_CH'
94 func (de *de_CH) PluralsRange() []locales.PluralRule {
95 return de.pluralsRange
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_CH'
99 func (de *de_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 'de_CH'
112 func (de *de_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113 return locales.PluralRuleOther
116 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_CH'
117 func (de *de_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
119 start := de.CardinalPluralRule(num1, v1)
120 end := de.CardinalPluralRule(num2, v2)
122 if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
123 return locales.PluralRuleOther
124 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
125 return locales.PluralRuleOne
128 return locales.PluralRuleOther
132 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
133 func (de *de_CH) MonthAbbreviated(month time.Month) string {
134 return de.monthsAbbreviated[month]
137 // MonthsAbbreviated returns the locales abbreviated months
138 func (de *de_CH) MonthsAbbreviated() []string {
139 return de.monthsAbbreviated[1:]
142 // MonthNarrow returns the locales narrow month given the 'month' provided
143 func (de *de_CH) MonthNarrow(month time.Month) string {
144 return de.monthsNarrow[month]
147 // MonthsNarrow returns the locales narrow months
148 func (de *de_CH) MonthsNarrow() []string {
149 return de.monthsNarrow[1:]
152 // MonthWide returns the locales wide month given the 'month' provided
153 func (de *de_CH) MonthWide(month time.Month) string {
154 return de.monthsWide[month]
157 // MonthsWide returns the locales wide months
158 func (de *de_CH) MonthsWide() []string {
159 return de.monthsWide[1:]
162 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
163 func (de *de_CH) WeekdayAbbreviated(weekday time.Weekday) string {
164 return de.daysAbbreviated[weekday]
167 // WeekdaysAbbreviated returns the locales abbreviated weekdays
168 func (de *de_CH) WeekdaysAbbreviated() []string {
169 return de.daysAbbreviated
172 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
173 func (de *de_CH) WeekdayNarrow(weekday time.Weekday) string {
174 return de.daysNarrow[weekday]
177 // WeekdaysNarrow returns the locales narrow weekdays
178 func (de *de_CH) WeekdaysNarrow() []string {
182 // WeekdayShort returns the locales short weekday given the 'weekday' provided
183 func (de *de_CH) WeekdayShort(weekday time.Weekday) string {
184 return de.daysShort[weekday]
187 // WeekdaysShort returns the locales short weekdays
188 func (de *de_CH) WeekdaysShort() []string {
192 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
193 func (de *de_CH) WeekdayWide(weekday time.Weekday) string {
194 return de.daysWide[weekday]
197 // WeekdaysWide returns the locales wide weekdays
198 func (de *de_CH) WeekdaysWide() []string {
202 // Decimal returns the decimal point of number
203 func (de *de_CH) Decimal() string {
207 // Group returns the group of number
208 func (de *de_CH) Group() string {
212 // Group returns the minus sign of number
213 func (de *de_CH) Minus() string {
217 // FmtNumber returns 'num' with digits/precision of 'v' for 'de_CH' and handles both Whole and Real numbers based on 'v'
218 func (de *de_CH) FmtNumber(num float64, v uint64) string {
220 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
221 l := len(s) + 2 + 3*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, de.decimal[0])
236 for j := len(de.group) - 1; j >= 0; j-- {
237 b = append(b, de.group[j])
249 b = append(b, de.minus[0])
253 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
254 b[i], b[j] = b[j], b[i]
260 // FmtPercent returns 'num' with digits/precision of 'v' for 'de_CH' and handles both Whole and Real numbers based on 'v'
261 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
262 func (de *de_CH) FmtPercent(num float64, v uint64) string {
263 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265 b := make([]byte, 0, l)
267 for i := len(s) - 1; i >= 0; i-- {
270 b = append(b, de.decimal[0])
278 b = append(b, de.minus[0])
282 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
283 b[i], b[j] = b[j], b[i]
286 b = append(b, de.percent...)
291 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_CH'
292 func (de *de_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
294 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
295 symbol := de.currencies[currency]
296 l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
299 b := make([]byte, 0, l)
301 for i := len(s) - 1; i >= 0; i-- {
304 b = append(b, de.decimal[0])
311 for j := len(de.group) - 1; j >= 0; j-- {
312 b = append(b, de.group[j])
323 for j := len(symbol) - 1; j >= 0; j-- {
324 b = append(b, symbol[j])
327 for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- {
328 b = append(b, de.currencyPositivePrefix[j])
332 b = append(b, de.minus[0])
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, de.decimal...)
346 for i := 0; i < 2-int(v); i++ {
354 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_CH'
355 // in accounting notation.
356 func (de *de_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
358 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
359 symbol := de.currencies[currency]
360 l := len(s) + len(symbol) + 4 + 3*len(s[:len(s)-int(v)-1])/3
363 b := make([]byte, 0, l)
365 for i := len(s) - 1; i >= 0; i-- {
368 b = append(b, de.decimal[0])
375 for j := len(de.group) - 1; j >= 0; j-- {
376 b = append(b, de.group[j])
389 for j := len(symbol) - 1; j >= 0; j-- {
390 b = append(b, symbol[j])
393 for j := len(de.currencyNegativePrefix) - 1; j >= 0; j-- {
394 b = append(b, de.currencyNegativePrefix[j])
397 b = append(b, de.minus[0])
401 for j := len(symbol) - 1; j >= 0; j-- {
402 b = append(b, symbol[j])
405 for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- {
406 b = append(b, de.currencyPositivePrefix[j])
412 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
413 b[i], b[j] = b[j], b[i]
419 b = append(b, de.decimal...)
422 for i := 0; i < 2-int(v); i++ {
430 // FmtDateShort returns the short date representation of 't' for 'de_CH'
431 func (de *de_CH) FmtDateShort(t time.Time) string {
433 b := make([]byte, 0, 32)
439 b = strconv.AppendInt(b, int64(t.Day()), 10)
440 b = append(b, []byte{0x2e}...)
446 b = strconv.AppendInt(b, int64(t.Month()), 10)
448 b = append(b, []byte{0x2e}...)
451 b = append(b, strconv.Itoa(t.Year())[2:]...)
453 b = append(b, strconv.Itoa(t.Year())[1:]...)
459 // FmtDateMedium returns the medium date representation of 't' for 'de_CH'
460 func (de *de_CH) FmtDateMedium(t time.Time) string {
462 b := make([]byte, 0, 32)
468 b = strconv.AppendInt(b, int64(t.Day()), 10)
469 b = append(b, []byte{0x2e}...)
475 b = strconv.AppendInt(b, int64(t.Month()), 10)
477 b = append(b, []byte{0x2e}...)
480 b = strconv.AppendInt(b, int64(t.Year()), 10)
482 b = strconv.AppendInt(b, int64(-t.Year()), 10)
488 // FmtDateLong returns the long date representation of 't' for 'de_CH'
489 func (de *de_CH) FmtDateLong(t time.Time) string {
491 b := make([]byte, 0, 32)
493 b = strconv.AppendInt(b, int64(t.Day()), 10)
494 b = append(b, []byte{0x2e, 0x20}...)
495 b = append(b, de.monthsWide[t.Month()]...)
496 b = append(b, []byte{0x20}...)
499 b = strconv.AppendInt(b, int64(t.Year()), 10)
501 b = strconv.AppendInt(b, int64(-t.Year()), 10)
507 // FmtDateFull returns the full date representation of 't' for 'de_CH'
508 func (de *de_CH) FmtDateFull(t time.Time) string {
510 b := make([]byte, 0, 32)
512 b = append(b, de.daysWide[t.Weekday()]...)
513 b = append(b, []byte{0x2c, 0x20}...)
514 b = strconv.AppendInt(b, int64(t.Day()), 10)
515 b = append(b, []byte{0x2e, 0x20}...)
516 b = append(b, de.monthsWide[t.Month()]...)
517 b = append(b, []byte{0x20}...)
520 b = strconv.AppendInt(b, int64(t.Year()), 10)
522 b = strconv.AppendInt(b, int64(-t.Year()), 10)
528 // FmtTimeShort returns the short time representation of 't' for 'de_CH'
529 func (de *de_CH) FmtTimeShort(t time.Time) string {
531 b := make([]byte, 0, 32)
537 b = strconv.AppendInt(b, int64(t.Hour()), 10)
538 b = append(b, de.timeSeparator...)
544 b = strconv.AppendInt(b, int64(t.Minute()), 10)
549 // FmtTimeMedium returns the medium time representation of 't' for 'de_CH'
550 func (de *de_CH) FmtTimeMedium(t time.Time) string {
552 b := make([]byte, 0, 32)
558 b = strconv.AppendInt(b, int64(t.Hour()), 10)
559 b = append(b, de.timeSeparator...)
565 b = strconv.AppendInt(b, int64(t.Minute()), 10)
566 b = append(b, de.timeSeparator...)
572 b = strconv.AppendInt(b, int64(t.Second()), 10)
577 // FmtTimeLong returns the long time representation of 't' for 'de_CH'
578 func (de *de_CH) FmtTimeLong(t time.Time) string {
580 b := make([]byte, 0, 32)
586 b = strconv.AppendInt(b, int64(t.Hour()), 10)
587 b = append(b, de.timeSeparator...)
593 b = strconv.AppendInt(b, int64(t.Minute()), 10)
594 b = append(b, de.timeSeparator...)
600 b = strconv.AppendInt(b, int64(t.Second()), 10)
601 b = append(b, []byte{0x20}...)
609 // FmtTimeFull returns the full time representation of 't' for 'de_CH'
610 func (de *de_CH) FmtTimeFull(t time.Time) string {
612 b := make([]byte, 0, 32)
618 b = strconv.AppendInt(b, int64(t.Hour()), 10)
619 b = append(b, de.timeSeparator...)
625 b = strconv.AppendInt(b, int64(t.Minute()), 10)
626 b = append(b, de.timeSeparator...)
632 b = strconv.AppendInt(b, int64(t.Second()), 10)
633 b = append(b, []byte{0x20}...)
637 if btz, ok := de.timezones[tz]; ok {
638 b = append(b, btz...)