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