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