1 package wae_CH
2
3 import (
4 "math"
5 "strconv"
6 "time"
7
8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
10 )
11
12 type wae_CH struct {
13 locale string
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
17 decimal string
18 group string
19 minus string
20 percent string
21 perMille string
22 timeSeparator string
23 inifinity string
24 currencies []string
25 currencyPositivePrefix string
26 currencyPositiveSuffix string
27 currencyNegativePrefix string
28 currencyNegativeSuffix string
29 monthsAbbreviated []string
30 monthsNarrow []string
31 monthsWide []string
32 daysAbbreviated []string
33 daysNarrow []string
34 daysShort []string
35 daysWide []string
36 periodsAbbreviated []string
37 periodsNarrow []string
38 periodsShort []string
39 periodsWide []string
40 erasAbbreviated []string
41 erasNarrow []string
42 erasWide []string
43 timezones map[string]string
44 }
45
46
47 func New() locales.Translator {
48 return &wae_CH{
49 locale: "wae_CH",
50 pluralsCardinal: []locales.PluralRule{2, 6},
51 pluralsOrdinal: nil,
52 pluralsRange: nil,
53 decimal: ",",
54 group: "’",
55 timeSeparator: ":",
56 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", "CNH", "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", "MRU", "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", "STN", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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"},
57 currencyPositivePrefix: " ",
58 currencyPositiveSuffix: "K",
59 currencyNegativePrefix: " ",
60 currencyNegativeSuffix: "K",
61 monthsAbbreviated: []string{"", "Jen", "Hor", "Mär", "Abr", "Mei", "Brá", "Hei", "Öig", "Her", "Wím", "Win", "Chr"},
62 monthsNarrow: []string{"", "J", "H", "M", "A", "M", "B", "H", "Ö", "H", "W", "W", "C"},
63 monthsWide: []string{"", "Jenner", "Hornig", "Märze", "Abrille", "Meije", "Bráčet", "Heiwet", "Öigšte", "Herbštmánet", "Wímánet", "Wintermánet", "Chrištmánet"},
64 daysAbbreviated: []string{"Sun", "Män", "Ziš", "Mit", "Fró", "Fri", "Sam"},
65 daysNarrow: []string{"S", "M", "Z", "M", "F", "F", "S"},
66 daysWide: []string{"Sunntag", "Mäntag", "Zištag", "Mittwuč", "Fróntag", "Fritag", "Samštag"},
67 erasAbbreviated: []string{"v. Chr.", "n. Chr"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"", ""},
70 timezones: map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "Atlantiši Summerzit", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "Atlantiši Standardzit", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT", "EST": "EST", "GFT": "GFT", "GMT": "GMT", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "IST", "JDT": "JDT", "JST": "JST", "LHDT": "LHDT", "LHST": "LHST", "MDT": "MDT", "MESZ": "Mitteleuropäiši Summerzit", "MEZ": "Mitteleuropäiši Standardzit", "MST": "MST", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "Ošteuropäiši Summerzit", "OEZ": "Ošteuropäiši Standardzit", "PDT": "PDT", "PST": "PST", "SAST": "SAST", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "WAST", "WAT": "WAT", "WESZ": "Wešteuropäiši Summerzit", "WEZ": "Wešteuropäiši Standardzit", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
71 }
72 }
73
74
75 func (wae *wae_CH) Locale() string {
76 return wae.locale
77 }
78
79
80 func (wae *wae_CH) PluralsCardinal() []locales.PluralRule {
81 return wae.pluralsCardinal
82 }
83
84
85 func (wae *wae_CH) PluralsOrdinal() []locales.PluralRule {
86 return wae.pluralsOrdinal
87 }
88
89
90 func (wae *wae_CH) PluralsRange() []locales.PluralRule {
91 return wae.pluralsRange
92 }
93
94
95 func (wae *wae_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97 n := math.Abs(num)
98
99 if n == 1 {
100 return locales.PluralRuleOne
101 }
102
103 return locales.PluralRuleOther
104 }
105
106
107 func (wae *wae_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
108 return locales.PluralRuleUnknown
109 }
110
111
112 func (wae *wae_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
113 return locales.PluralRuleUnknown
114 }
115
116
117 func (wae *wae_CH) MonthAbbreviated(month time.Month) string {
118 return wae.monthsAbbreviated[month]
119 }
120
121
122 func (wae *wae_CH) MonthsAbbreviated() []string {
123 return wae.monthsAbbreviated[1:]
124 }
125
126
127 func (wae *wae_CH) MonthNarrow(month time.Month) string {
128 return wae.monthsNarrow[month]
129 }
130
131
132 func (wae *wae_CH) MonthsNarrow() []string {
133 return wae.monthsNarrow[1:]
134 }
135
136
137 func (wae *wae_CH) MonthWide(month time.Month) string {
138 return wae.monthsWide[month]
139 }
140
141
142 func (wae *wae_CH) MonthsWide() []string {
143 return wae.monthsWide[1:]
144 }
145
146
147 func (wae *wae_CH) WeekdayAbbreviated(weekday time.Weekday) string {
148 return wae.daysAbbreviated[weekday]
149 }
150
151
152 func (wae *wae_CH) WeekdaysAbbreviated() []string {
153 return wae.daysAbbreviated
154 }
155
156
157 func (wae *wae_CH) WeekdayNarrow(weekday time.Weekday) string {
158 return wae.daysNarrow[weekday]
159 }
160
161
162 func (wae *wae_CH) WeekdaysNarrow() []string {
163 return wae.daysNarrow
164 }
165
166
167 func (wae *wae_CH) WeekdayShort(weekday time.Weekday) string {
168 return wae.daysShort[weekday]
169 }
170
171
172 func (wae *wae_CH) WeekdaysShort() []string {
173 return wae.daysShort
174 }
175
176
177 func (wae *wae_CH) WeekdayWide(weekday time.Weekday) string {
178 return wae.daysWide[weekday]
179 }
180
181
182 func (wae *wae_CH) WeekdaysWide() []string {
183 return wae.daysWide
184 }
185
186
187 func (wae *wae_CH) Decimal() string {
188 return wae.decimal
189 }
190
191
192 func (wae *wae_CH) Group() string {
193 return wae.group
194 }
195
196
197 func (wae *wae_CH) Minus() string {
198 return wae.minus
199 }
200
201
202 func (wae *wae_CH) FmtNumber(num float64, v uint64) string {
203
204 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
205 }
206
207
208
209 func (wae *wae_CH) FmtPercent(num float64, v uint64) string {
210 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211 }
212
213
214 func (wae *wae_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
215
216 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
217 symbol := wae.currencies[currency]
218 l := len(s) + len(symbol) + 4
219
220 b := make([]byte, 0, l)
221
222 for i := len(s) - 1; i >= 0; i-- {
223
224 if s[i] == '.' {
225 b = append(b, wae.decimal[0])
226 continue
227 }
228
229 b = append(b, s[i])
230 }
231
232 for j := len(symbol) - 1; j >= 0; j-- {
233 b = append(b, symbol[j])
234 }
235
236 for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- {
237 b = append(b, wae.currencyPositivePrefix[j])
238 }
239
240 if num < 0 {
241 b = append(b, wae.minus[0])
242 }
243
244
245 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
246 b[i], b[j] = b[j], b[i]
247 }
248
249 b = append(b, wae.currencyPositiveSuffix...)
250
251 return string(b)
252 }
253
254
255
256 func (wae *wae_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
257
258 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
259 symbol := wae.currencies[currency]
260 l := len(s) + len(symbol) + 4
261
262 b := make([]byte, 0, l)
263
264 for i := len(s) - 1; i >= 0; i-- {
265
266 if s[i] == '.' {
267 b = append(b, wae.decimal[0])
268 continue
269 }
270
271 b = append(b, s[i])
272 }
273
274 if num < 0 {
275
276 for j := len(symbol) - 1; j >= 0; j-- {
277 b = append(b, symbol[j])
278 }
279
280 for j := len(wae.currencyNegativePrefix) - 1; j >= 0; j-- {
281 b = append(b, wae.currencyNegativePrefix[j])
282 }
283
284 b = append(b, wae.minus[0])
285
286 } else {
287
288 for j := len(symbol) - 1; j >= 0; j-- {
289 b = append(b, symbol[j])
290 }
291
292 for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- {
293 b = append(b, wae.currencyPositivePrefix[j])
294 }
295
296 }
297
298
299 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
300 b[i], b[j] = b[j], b[i]
301 }
302
303 if num < 0 {
304 b = append(b, wae.currencyNegativeSuffix...)
305 } else {
306
307 b = append(b, wae.currencyPositiveSuffix...)
308 }
309
310 return string(b)
311 }
312
313
314 func (wae *wae_CH) FmtDateShort(t time.Time) string {
315
316 b := make([]byte, 0, 32)
317
318 return string(b)
319 }
320
321
322 func (wae *wae_CH) FmtDateMedium(t time.Time) string {
323
324 b := make([]byte, 0, 32)
325
326 b = strconv.AppendInt(b, int64(t.Day()), 10)
327 b = append(b, []byte{0x2e, 0x20}...)
328 b = append(b, wae.monthsAbbreviated[t.Month()]...)
329 b = append(b, []byte{0x20}...)
330
331 if t.Year() > 0 {
332 b = strconv.AppendInt(b, int64(t.Year()), 10)
333 } else {
334 b = strconv.AppendInt(b, int64(-t.Year()), 10)
335 }
336
337 return string(b)
338 }
339
340
341 func (wae *wae_CH) FmtDateLong(t time.Time) string {
342
343 b := make([]byte, 0, 32)
344
345 b = strconv.AppendInt(b, int64(t.Day()), 10)
346 b = append(b, []byte{0x2e, 0x20}...)
347 b = append(b, wae.monthsWide[t.Month()]...)
348 b = append(b, []byte{0x20}...)
349
350 if t.Year() > 0 {
351 b = strconv.AppendInt(b, int64(t.Year()), 10)
352 } else {
353 b = strconv.AppendInt(b, int64(-t.Year()), 10)
354 }
355
356 return string(b)
357 }
358
359
360 func (wae *wae_CH) FmtDateFull(t time.Time) string {
361
362 b := make([]byte, 0, 32)
363
364 b = append(b, wae.daysWide[t.Weekday()]...)
365 b = append(b, []byte{0x2c, 0x20}...)
366 b = strconv.AppendInt(b, int64(t.Day()), 10)
367 b = append(b, []byte{0x2e, 0x20}...)
368 b = append(b, wae.monthsWide[t.Month()]...)
369 b = append(b, []byte{0x20}...)
370
371 if t.Year() > 0 {
372 b = strconv.AppendInt(b, int64(t.Year()), 10)
373 } else {
374 b = strconv.AppendInt(b, int64(-t.Year()), 10)
375 }
376
377 return string(b)
378 }
379
380
381 func (wae *wae_CH) FmtTimeShort(t time.Time) string {
382
383 b := make([]byte, 0, 32)
384
385 return string(b)
386 }
387
388
389 func (wae *wae_CH) FmtTimeMedium(t time.Time) string {
390
391 b := make([]byte, 0, 32)
392
393 return string(b)
394 }
395
396
397 func (wae *wae_CH) FmtTimeLong(t time.Time) string {
398
399 b := make([]byte, 0, 32)
400
401 return string(b)
402 }
403
404
405 func (wae *wae_CH) FmtTimeFull(t time.Time) string {
406
407 b := make([]byte, 0, 32)
408
409 return string(b)
410 }
411
View as plain text