1 package cu_RU
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 cu_RU 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 percentSuffix string
22 perMille string
23 timeSeparator string
24 inifinity string
25 currencies []string
26 currencyPositiveSuffix string
27 currencyNegativeSuffix string
28 monthsAbbreviated []string
29 monthsNarrow []string
30 monthsWide []string
31 daysAbbreviated []string
32 daysNarrow []string
33 daysShort []string
34 daysWide []string
35 periodsAbbreviated []string
36 periodsNarrow []string
37 periodsShort []string
38 periodsWide []string
39 erasAbbreviated []string
40 erasNarrow []string
41 erasWide []string
42 timezones map[string]string
43 }
44
45
46 func New() locales.Translator {
47 return &cu_RU{
48 locale: "cu_RU",
49 pluralsCardinal: nil,
50 pluralsOrdinal: nil,
51 pluralsRange: nil,
52 decimal: ",",
53 group: " ",
54 minus: "-",
55 percent: "%",
56 timeSeparator: ":",
57 inifinity: "∞",
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", "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"},
59 percentSuffix: " ",
60 currencyPositiveSuffix: " ",
61 currencyNegativeSuffix: " ",
62 monthsAbbreviated: []string{"", "і҆аⷩ҇", "феⷡ҇", "маⷬ҇", "а҆пⷬ҇", "маꙵ", "і҆ꙋⷩ҇", "і҆ꙋⷧ҇", "а҆́ѵⷢ҇", "сеⷫ҇", "ѻ҆кⷮ", "ноеⷨ", "деⷦ҇"},
63 monthsNarrow: []string{"", "І҆", "Ф", "М", "А҆", "М", "І҆", "І҆", "А҆", "С", "Ѻ҆", "Н", "Д"},
64 monthsWide: []string{"", "і҆аннꙋа́рїа", "феврꙋа́рїа", "ма́рта", "а҆прі́ллїа", "ма́їа", "і҆ꙋ́нїа", "і҆ꙋ́лїа", "а҆́ѵгꙋста", "септе́мврїа", "ѻ҆ктѡ́врїа", "ное́мврїа", "деке́мврїа"},
65 daysAbbreviated: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"},
66 daysNarrow: []string{"Н", "П", "В", "С", "Ч", "П", "С"},
67 daysShort: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"},
68 daysWide: []string{"недѣ́лѧ", "понедѣ́льникъ", "вто́рникъ", "среда̀", "четверто́къ", "пѧто́къ", "сꙋббѡ́та"},
69 periodsAbbreviated: []string{"ДП", "ПП"},
70 periodsNarrow: []string{"ДП", "ПП"},
71 periodsWide: []string{"ДП", "ПП"},
72 erasAbbreviated: []string{"пре́дъ р.\u00a0х.", "ѿ р. х."},
73 erasNarrow: []string{"", ""},
74 erasWide: []string{"пре́дъ р.\u00a0х.", "по р.\u00a0х."},
75 timezones: map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "а҆тланті́ческое лѣ́тнее вре́мѧ", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "а҆тланті́ческое зи́мнее вре́мѧ", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "среднеамерїка́нское лѣ́тнее вре́мѧ", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "среднеамерїка́нское зи́мнее вре́мѧ", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "восточноамерїка́нское лѣ́тнее вре́мѧ", "EST": "восточноамерїка́нское зи́мнее вре́мѧ", "GFT": "GFT", "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": "а҆мерїка́нское наго́рнее лѣ́тнее вре́мѧ", "MESZ": "среднеєѵрѡпе́йское лѣ́тнее вре́мѧ", "MEZ": "среднеєѵрѡпе́йское зи́мнее вре́мѧ", "MST": "а҆мерїка́нское наго́рнее зи́мнее вре́мѧ", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "восточноєѵрѡпе́йское лѣ́тнее вре́мѧ", "OEZ": "восточноєѵрѡпе́йское зи́мнее вре́мѧ", "PDT": "тихоѻкеа́нское лѣ́тнее вре́мѧ", "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": "западноєѵрѡпе́йское лѣ́тнее вре́мѧ", "WEZ": "западноєѵрѡпе́йское зи́мнее вре́мѧ", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
76 }
77 }
78
79
80 func (cu *cu_RU) Locale() string {
81 return cu.locale
82 }
83
84
85 func (cu *cu_RU) PluralsCardinal() []locales.PluralRule {
86 return cu.pluralsCardinal
87 }
88
89
90 func (cu *cu_RU) PluralsOrdinal() []locales.PluralRule {
91 return cu.pluralsOrdinal
92 }
93
94
95 func (cu *cu_RU) PluralsRange() []locales.PluralRule {
96 return cu.pluralsRange
97 }
98
99
100 func (cu *cu_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
101 return locales.PluralRuleUnknown
102 }
103
104
105 func (cu *cu_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
106 return locales.PluralRuleUnknown
107 }
108
109
110 func (cu *cu_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
111 return locales.PluralRuleUnknown
112 }
113
114
115 func (cu *cu_RU) MonthAbbreviated(month time.Month) string {
116 return cu.monthsAbbreviated[month]
117 }
118
119
120 func (cu *cu_RU) MonthsAbbreviated() []string {
121 return cu.monthsAbbreviated[1:]
122 }
123
124
125 func (cu *cu_RU) MonthNarrow(month time.Month) string {
126 return cu.monthsNarrow[month]
127 }
128
129
130 func (cu *cu_RU) MonthsNarrow() []string {
131 return cu.monthsNarrow[1:]
132 }
133
134
135 func (cu *cu_RU) MonthWide(month time.Month) string {
136 return cu.monthsWide[month]
137 }
138
139
140 func (cu *cu_RU) MonthsWide() []string {
141 return cu.monthsWide[1:]
142 }
143
144
145 func (cu *cu_RU) WeekdayAbbreviated(weekday time.Weekday) string {
146 return cu.daysAbbreviated[weekday]
147 }
148
149
150 func (cu *cu_RU) WeekdaysAbbreviated() []string {
151 return cu.daysAbbreviated
152 }
153
154
155 func (cu *cu_RU) WeekdayNarrow(weekday time.Weekday) string {
156 return cu.daysNarrow[weekday]
157 }
158
159
160 func (cu *cu_RU) WeekdaysNarrow() []string {
161 return cu.daysNarrow
162 }
163
164
165 func (cu *cu_RU) WeekdayShort(weekday time.Weekday) string {
166 return cu.daysShort[weekday]
167 }
168
169
170 func (cu *cu_RU) WeekdaysShort() []string {
171 return cu.daysShort
172 }
173
174
175 func (cu *cu_RU) WeekdayWide(weekday time.Weekday) string {
176 return cu.daysWide[weekday]
177 }
178
179
180 func (cu *cu_RU) WeekdaysWide() []string {
181 return cu.daysWide
182 }
183
184
185 func (cu *cu_RU) Decimal() string {
186 return cu.decimal
187 }
188
189
190 func (cu *cu_RU) Group() string {
191 return cu.group
192 }
193
194
195 func (cu *cu_RU) Minus() string {
196 return cu.minus
197 }
198
199
200 func (cu *cu_RU) FmtNumber(num float64, v uint64) string {
201
202 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
203 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
204 count := 0
205 inWhole := v == 0
206 b := make([]byte, 0, l)
207
208 for i := len(s) - 1; i >= 0; i-- {
209
210 if s[i] == '.' {
211 b = append(b, cu.decimal[0])
212 inWhole = true
213 continue
214 }
215
216 if inWhole {
217 if count == 3 {
218 for j := len(cu.group) - 1; j >= 0; j-- {
219 b = append(b, cu.group[j])
220 }
221 count = 1
222 } else {
223 count++
224 }
225 }
226
227 b = append(b, s[i])
228 }
229
230 if num < 0 {
231 b = append(b, cu.minus[0])
232 }
233
234
235 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
236 b[i], b[j] = b[j], b[i]
237 }
238
239 return string(b)
240 }
241
242
243
244 func (cu *cu_RU) FmtPercent(num float64, v uint64) string {
245 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
246 l := len(s) + 5
247 b := make([]byte, 0, l)
248
249 for i := len(s) - 1; i >= 0; i-- {
250
251 if s[i] == '.' {
252 b = append(b, cu.decimal[0])
253 continue
254 }
255
256 b = append(b, s[i])
257 }
258
259 if num < 0 {
260 b = append(b, cu.minus[0])
261 }
262
263
264 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
265 b[i], b[j] = b[j], b[i]
266 }
267
268 b = append(b, cu.percentSuffix...)
269
270 b = append(b, cu.percent...)
271
272 return string(b)
273 }
274
275
276 func (cu *cu_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string {
277
278 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
279 symbol := cu.currencies[currency]
280 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
281 count := 0
282 inWhole := v == 0
283 b := make([]byte, 0, l)
284
285 for i := len(s) - 1; i >= 0; i-- {
286
287 if s[i] == '.' {
288 b = append(b, cu.decimal[0])
289 inWhole = true
290 continue
291 }
292
293 if inWhole {
294 if count == 3 {
295 for j := len(cu.group) - 1; j >= 0; j-- {
296 b = append(b, cu.group[j])
297 }
298 count = 1
299 } else {
300 count++
301 }
302 }
303
304 b = append(b, s[i])
305 }
306
307 if num < 0 {
308 b = append(b, cu.minus[0])
309 }
310
311
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
314 }
315
316 if int(v) < 2 {
317
318 if v == 0 {
319 b = append(b, cu.decimal...)
320 }
321
322 for i := 0; i < 2-int(v); i++ {
323 b = append(b, '0')
324 }
325 }
326
327 b = append(b, cu.currencyPositiveSuffix...)
328
329 b = append(b, symbol...)
330
331 return string(b)
332 }
333
334
335
336 func (cu *cu_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string {
337
338 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339 symbol := cu.currencies[currency]
340 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
341 count := 0
342 inWhole := v == 0
343 b := make([]byte, 0, l)
344
345 for i := len(s) - 1; i >= 0; i-- {
346
347 if s[i] == '.' {
348 b = append(b, cu.decimal[0])
349 inWhole = true
350 continue
351 }
352
353 if inWhole {
354 if count == 3 {
355 for j := len(cu.group) - 1; j >= 0; j-- {
356 b = append(b, cu.group[j])
357 }
358 count = 1
359 } else {
360 count++
361 }
362 }
363
364 b = append(b, s[i])
365 }
366
367 if num < 0 {
368
369 b = append(b, cu.minus[0])
370
371 }
372
373
374 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
375 b[i], b[j] = b[j], b[i]
376 }
377
378 if int(v) < 2 {
379
380 if v == 0 {
381 b = append(b, cu.decimal...)
382 }
383
384 for i := 0; i < 2-int(v); i++ {
385 b = append(b, '0')
386 }
387 }
388
389 if num < 0 {
390 b = append(b, cu.currencyNegativeSuffix...)
391 b = append(b, symbol...)
392 } else {
393
394 b = append(b, cu.currencyPositiveSuffix...)
395 b = append(b, symbol...)
396 }
397
398 return string(b)
399 }
400
401
402 func (cu *cu_RU) FmtDateShort(t time.Time) string {
403
404 b := make([]byte, 0, 32)
405
406 if t.Year() > 0 {
407 b = strconv.AppendInt(b, int64(t.Year()), 10)
408 } else {
409 b = strconv.AppendInt(b, int64(-t.Year()), 10)
410 }
411
412 b = append(b, []byte{0x2e}...)
413
414 if t.Month() < 10 {
415 b = append(b, '0')
416 }
417
418 b = strconv.AppendInt(b, int64(t.Month()), 10)
419
420 b = append(b, []byte{0x2e}...)
421
422 if t.Day() < 10 {
423 b = append(b, '0')
424 }
425
426 b = strconv.AppendInt(b, int64(t.Day()), 10)
427
428 return string(b)
429 }
430
431
432 func (cu *cu_RU) FmtDateMedium(t time.Time) string {
433
434 b := make([]byte, 0, 32)
435
436 if t.Year() > 0 {
437 b = strconv.AppendInt(b, int64(t.Year()), 10)
438 } else {
439 b = strconv.AppendInt(b, int64(-t.Year()), 10)
440 }
441
442 b = append(b, []byte{0x20}...)
443 b = append(b, cu.monthsAbbreviated[t.Month()]...)
444 b = append(b, []byte{0x20}...)
445 b = strconv.AppendInt(b, int64(t.Day()), 10)
446
447 return string(b)
448 }
449
450
451 func (cu *cu_RU) FmtDateLong(t time.Time) string {
452
453 b := make([]byte, 0, 32)
454
455 if t.Year() > 0 {
456 b = strconv.AppendInt(b, int64(t.Year()), 10)
457 } else {
458 b = strconv.AppendInt(b, int64(-t.Year()), 10)
459 }
460
461 b = append(b, []byte{0x20}...)
462 b = append(b, cu.monthsWide[t.Month()]...)
463 b = append(b, []byte{0x20}...)
464 b = strconv.AppendInt(b, int64(t.Day()), 10)
465
466 return string(b)
467 }
468
469
470 func (cu *cu_RU) FmtDateFull(t time.Time) string {
471
472 b := make([]byte, 0, 32)
473
474 b = append(b, cu.daysWide[t.Weekday()]...)
475 b = append(b, []byte{0x2c, 0x20}...)
476 b = strconv.AppendInt(b, int64(t.Day()), 10)
477 b = append(b, []byte{0x20}...)
478 b = append(b, cu.monthsWide[t.Month()]...)
479 b = append(b, []byte{0x20, 0xd0, 0xbb}...)
480 b = append(b, []byte{0x2e, 0x20}...)
481
482 if t.Year() > 0 {
483 b = strconv.AppendInt(b, int64(t.Year()), 10)
484 } else {
485 b = strconv.AppendInt(b, int64(-t.Year()), 10)
486 }
487
488 b = append(b, []byte{0x2e}...)
489
490 return string(b)
491 }
492
493
494 func (cu *cu_RU) FmtTimeShort(t time.Time) string {
495
496 b := make([]byte, 0, 32)
497
498 if t.Hour() < 10 {
499 b = append(b, '0')
500 }
501
502 b = strconv.AppendInt(b, int64(t.Hour()), 10)
503 b = append(b, cu.timeSeparator...)
504
505 if t.Minute() < 10 {
506 b = append(b, '0')
507 }
508
509 b = strconv.AppendInt(b, int64(t.Minute()), 10)
510
511 return string(b)
512 }
513
514
515 func (cu *cu_RU) FmtTimeMedium(t time.Time) string {
516
517 b := make([]byte, 0, 32)
518
519 if t.Hour() < 10 {
520 b = append(b, '0')
521 }
522
523 b = strconv.AppendInt(b, int64(t.Hour()), 10)
524 b = append(b, cu.timeSeparator...)
525
526 if t.Minute() < 10 {
527 b = append(b, '0')
528 }
529
530 b = strconv.AppendInt(b, int64(t.Minute()), 10)
531 b = append(b, cu.timeSeparator...)
532
533 if t.Second() < 10 {
534 b = append(b, '0')
535 }
536
537 b = strconv.AppendInt(b, int64(t.Second()), 10)
538
539 return string(b)
540 }
541
542
543 func (cu *cu_RU) FmtTimeLong(t time.Time) string {
544
545 b := make([]byte, 0, 32)
546
547 if t.Hour() < 10 {
548 b = append(b, '0')
549 }
550
551 b = strconv.AppendInt(b, int64(t.Hour()), 10)
552 b = append(b, cu.timeSeparator...)
553
554 if t.Minute() < 10 {
555 b = append(b, '0')
556 }
557
558 b = strconv.AppendInt(b, int64(t.Minute()), 10)
559 b = append(b, cu.timeSeparator...)
560
561 if t.Second() < 10 {
562 b = append(b, '0')
563 }
564
565 b = strconv.AppendInt(b, int64(t.Second()), 10)
566 b = append(b, []byte{0x20}...)
567
568 tz, _ := t.Zone()
569 b = append(b, tz...)
570
571 return string(b)
572 }
573
574
575 func (cu *cu_RU) FmtTimeFull(t time.Time) string {
576
577 b := make([]byte, 0, 32)
578
579 if t.Hour() < 10 {
580 b = append(b, '0')
581 }
582
583 b = strconv.AppendInt(b, int64(t.Hour()), 10)
584 b = append(b, cu.timeSeparator...)
585
586 if t.Minute() < 10 {
587 b = append(b, '0')
588 }
589
590 b = strconv.AppendInt(b, int64(t.Minute()), 10)
591 b = append(b, cu.timeSeparator...)
592
593 if t.Second() < 10 {
594 b = append(b, '0')
595 }
596
597 b = strconv.AppendInt(b, int64(t.Second()), 10)
598 b = append(b, []byte{0x20}...)
599
600 tz, _ := t.Zone()
601
602 if btz, ok := cu.timezones[tz]; ok {
603 b = append(b, btz...)
604 } else {
605 b = append(b, tz...)
606 }
607
608 return string(b)
609 }
610
View as plain text