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 'kok' locale
45 func New() locales.Translator {
52 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"},
53 currencyPositivePrefix: " ",
54 currencyNegativePrefix: " ",
55 monthsWide: []string{"", "जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ओगस्ट", "सेप्टेंबर", "ओक्टोबर", "नोव्हेंबर", "डिसेंबर"},
56 daysAbbreviated: []string{"रवि", "सोम", "मंगळ", "बुध", "गुरु", "शुक्र", "शनि"},
57 daysWide: []string{"आदित्यवार", "सोमवार", "मंगळार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"},
58 periodsAbbreviated: []string{"म.पू.", "म.नं."},
59 periodsWide: []string{"म.पू.", "म.नं."},
60 erasAbbreviated: []string{"क्रिस्तपूर्व", "क्रिस्तशखा"},
61 erasNarrow: []string{"", ""},
62 erasWide: []string{"", ""},
63 timezones: map[string]string{"SAST": "SAST", "CHAST": "CHAST", "BOT": "BOT", "WIT": "WIT", "VET": "VET", "HENOMX": "HENOMX", "IST": "भारतीय समय", "WAST": "WAST", "HKST": "HKST", "WIB": "WIB", "MST": "MST", "AST": "AST", "PST": "PST", "PDT": "PDT", "UYST": "UYST", "HNEG": "HNEG", "ACDT": "ACDT", "JDT": "JDT", "GYT": "GYT", "HNCU": "HNCU", "JST": "JST", "TMT": "TMT", "OEZ": "OEZ", "HNOG": "HNOG", "HEEG": "HEEG", "UYT": "UYT", "ACWST": "ACWST", "EDT": "EDT", "HNPM": "HNPM", "MYT": "MYT", "HAT": "HAT", "ECT": "ECT", "AKST": "AKST", "CDT": "CDT", "ARST": "ARST", "HEOG": "HEOG", "ADT": "ADT", "HNT": "HNT", "NZST": "NZST", "GMT": "GMT", "MDT": "MDT", "HAST": "HAST", "WART": "WART", "AWDT": "AWDT", "MEZ": "MEZ", "COST": "COST", "AKDT": "AKDT", "CAT": "CAT", "ChST": "ChST", "AEST": "AEST", "HADT": "HADT", "TMST": "TMST", "HNNOMX": "HNNOMX", "OESZ": "OESZ", "CLT": "CLT", "EST": "EST", "HECU": "HECU", "ACWDT": "ACWDT", "LHST": "LHST", "EAT": "EAT", "HEPM": "HEPM", "BT": "BT", "AWST": "AWST", "HNPMX": "HNPMX", "CST": "CST", "MESZ": "MESZ", "WARST": "WARST", "ART": "ART", "CLST": "CLST", "∅∅∅": "∅∅∅", "SGT": "SGT", "WITA": "WITA", "WESZ": "WESZ", "SRT": "SRT", "NZDT": "NZDT", "LHDT": "LHDT", "AEDT": "AEDT", "HKT": "HKT", "COT": "COT", "GFT": "GFT", "CHADT": "CHADT", "WAT": "WAT", "ACST": "ACST", "WEZ": "WEZ", "HEPMX": "HEPMX"},
67 // Locale returns the current translators string locale
68 func (kok *kok) Locale() string {
72 // PluralsCardinal returns the list of cardinal plural rules associated with 'kok'
73 func (kok *kok) PluralsCardinal() []locales.PluralRule {
74 return kok.pluralsCardinal
77 // PluralsOrdinal returns the list of ordinal plural rules associated with 'kok'
78 func (kok *kok) PluralsOrdinal() []locales.PluralRule {
79 return kok.pluralsOrdinal
82 // PluralsRange returns the list of range plural rules associated with 'kok'
83 func (kok *kok) PluralsRange() []locales.PluralRule {
84 return kok.pluralsRange
87 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kok'
88 func (kok *kok) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
89 return locales.PluralRuleUnknown
92 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kok'
93 func (kok *kok) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
94 return locales.PluralRuleUnknown
97 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kok'
98 func (kok *kok) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
99 return locales.PluralRuleUnknown
102 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
103 func (kok *kok) MonthAbbreviated(month time.Month) string {
104 return kok.monthsAbbreviated[month]
107 // MonthsAbbreviated returns the locales abbreviated months
108 func (kok *kok) MonthsAbbreviated() []string {
112 // MonthNarrow returns the locales narrow month given the 'month' provided
113 func (kok *kok) MonthNarrow(month time.Month) string {
114 return kok.monthsNarrow[month]
117 // MonthsNarrow returns the locales narrow months
118 func (kok *kok) MonthsNarrow() []string {
122 // MonthWide returns the locales wide month given the 'month' provided
123 func (kok *kok) MonthWide(month time.Month) string {
124 return kok.monthsWide[month]
127 // MonthsWide returns the locales wide months
128 func (kok *kok) MonthsWide() []string {
129 return kok.monthsWide[1:]
132 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
133 func (kok *kok) WeekdayAbbreviated(weekday time.Weekday) string {
134 return kok.daysAbbreviated[weekday]
137 // WeekdaysAbbreviated returns the locales abbreviated weekdays
138 func (kok *kok) WeekdaysAbbreviated() []string {
139 return kok.daysAbbreviated
142 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
143 func (kok *kok) WeekdayNarrow(weekday time.Weekday) string {
144 return kok.daysNarrow[weekday]
147 // WeekdaysNarrow returns the locales narrow weekdays
148 func (kok *kok) WeekdaysNarrow() []string {
149 return kok.daysNarrow
152 // WeekdayShort returns the locales short weekday given the 'weekday' provided
153 func (kok *kok) WeekdayShort(weekday time.Weekday) string {
154 return kok.daysShort[weekday]
157 // WeekdaysShort returns the locales short weekdays
158 func (kok *kok) WeekdaysShort() []string {
162 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
163 func (kok *kok) WeekdayWide(weekday time.Weekday) string {
164 return kok.daysWide[weekday]
167 // WeekdaysWide returns the locales wide weekdays
168 func (kok *kok) WeekdaysWide() []string {
172 // Decimal returns the decimal point of number
173 func (kok *kok) Decimal() string {
177 // Group returns the group of number
178 func (kok *kok) Group() string {
182 // Group returns the minus sign of number
183 func (kok *kok) Minus() string {
187 // FmtNumber returns 'num' with digits/precision of 'v' for 'kok' and handles both Whole and Real numbers based on 'v'
188 func (kok *kok) FmtNumber(num float64, v uint64) string {
190 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
197 b := make([]byte, 0, l)
199 for i := len(s) - 1; i >= 0; i-- {
202 b = append(b, kok.decimal[0])
209 if count == groupThreshold {
210 b = append(b, kok.group[0])
226 b = append(b, kok.minus[0])
230 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
231 b[i], b[j] = b[j], b[i]
237 // FmtPercent returns 'num' with digits/precision of 'v' for 'kok' and handles both Whole and Real numbers based on 'v'
238 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
239 func (kok *kok) FmtPercent(num float64, v uint64) string {
240 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
242 b := make([]byte, 0, l)
244 for i := len(s) - 1; i >= 0; i-- {
247 b = append(b, kok.decimal[0])
255 b = append(b, kok.minus[0])
259 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
260 b[i], b[j] = b[j], b[i]
263 b = append(b, kok.percent...)
268 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kok'
269 func (kok *kok) FmtCurrency(num float64, v uint64, currency currency.Type) string {
271 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
272 symbol := kok.currencies[currency]
273 l := len(s) + len(symbol) + 2
279 b := make([]byte, 0, l)
281 for i := len(s) - 1; i >= 0; i-- {
284 b = append(b, kok.decimal[0])
291 if count == groupThreshold {
292 b = append(b, kok.group[0])
307 for j := len(symbol) - 1; j >= 0; j-- {
308 b = append(b, symbol[j])
311 for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- {
312 b = append(b, kok.currencyPositivePrefix[j])
316 b = append(b, kok.minus[0])
320 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
321 b[i], b[j] = b[j], b[i]
327 b = append(b, kok.decimal...)
330 for i := 0; i < 2-int(v); i++ {
338 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kok'
339 // in accounting notation.
340 func (kok *kok) FmtAccounting(num float64, v uint64, currency currency.Type) string {
342 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
343 symbol := kok.currencies[currency]
344 l := len(s) + len(symbol) + 2
350 b := make([]byte, 0, l)
352 for i := len(s) - 1; i >= 0; i-- {
355 b = append(b, kok.decimal[0])
362 if count == groupThreshold {
363 b = append(b, kok.group[0])
380 for j := len(symbol) - 1; j >= 0; j-- {
381 b = append(b, symbol[j])
384 for j := len(kok.currencyNegativePrefix) - 1; j >= 0; j-- {
385 b = append(b, kok.currencyNegativePrefix[j])
388 b = append(b, kok.minus[0])
392 for j := len(symbol) - 1; j >= 0; j-- {
393 b = append(b, symbol[j])
396 for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- {
397 b = append(b, kok.currencyPositivePrefix[j])
403 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
404 b[i], b[j] = b[j], b[i]
410 b = append(b, kok.decimal...)
413 for i := 0; i < 2-int(v); i++ {
421 // FmtDateShort returns the short date representation of 't' for 'kok'
422 func (kok *kok) FmtDateShort(t time.Time) string {
424 b := make([]byte, 0, 32)
426 b = strconv.AppendInt(b, int64(t.Day()), 10)
427 b = append(b, []byte{0x2d}...)
428 b = strconv.AppendInt(b, int64(t.Month()), 10)
429 b = append(b, []byte{0x2d}...)
432 b = append(b, strconv.Itoa(t.Year())[2:]...)
434 b = append(b, strconv.Itoa(t.Year())[1:]...)
440 // FmtDateMedium returns the medium date representation of 't' for 'kok'
441 func (kok *kok) FmtDateMedium(t time.Time) string {
443 b := make([]byte, 0, 32)
449 b = strconv.AppendInt(b, int64(t.Day()), 10)
450 b = append(b, []byte{0x2d}...)
456 b = strconv.AppendInt(b, int64(t.Month()), 10)
458 b = append(b, []byte{0x2d}...)
461 b = strconv.AppendInt(b, int64(t.Year()), 10)
463 b = strconv.AppendInt(b, int64(-t.Year()), 10)
469 // FmtDateLong returns the long date representation of 't' for 'kok'
470 func (kok *kok) FmtDateLong(t time.Time) string {
472 b := make([]byte, 0, 32)
474 b = strconv.AppendInt(b, int64(t.Day()), 10)
475 b = append(b, []byte{0x20}...)
476 b = append(b, kok.monthsWide[t.Month()]...)
477 b = append(b, []byte{0x20}...)
480 b = strconv.AppendInt(b, int64(t.Year()), 10)
482 b = strconv.AppendInt(b, int64(-t.Year()), 10)
488 // FmtDateFull returns the full date representation of 't' for 'kok'
489 func (kok *kok) FmtDateFull(t time.Time) string {
491 b := make([]byte, 0, 32)
493 b = append(b, kok.daysWide[t.Weekday()]...)
494 b = append(b, []byte{0x20}...)
495 b = strconv.AppendInt(b, int64(t.Day()), 10)
496 b = append(b, []byte{0x20}...)
497 b = append(b, kok.monthsWide[t.Month()]...)
498 b = append(b, []byte{0x20}...)
501 b = strconv.AppendInt(b, int64(t.Year()), 10)
503 b = strconv.AppendInt(b, int64(-t.Year()), 10)
509 // FmtTimeShort returns the short time representation of 't' for 'kok'
510 func (kok *kok) FmtTimeShort(t time.Time) string {
512 b := make([]byte, 0, 32)
520 b = strconv.AppendInt(b, int64(h), 10)
521 b = append(b, kok.timeSeparator...)
527 b = strconv.AppendInt(b, int64(t.Minute()), 10)
528 b = append(b, []byte{0x20}...)
531 b = append(b, kok.periodsAbbreviated[0]...)
533 b = append(b, kok.periodsAbbreviated[1]...)
539 // FmtTimeMedium returns the medium time representation of 't' for 'kok'
540 func (kok *kok) FmtTimeMedium(t time.Time) string {
542 b := make([]byte, 0, 32)
550 b = strconv.AppendInt(b, int64(h), 10)
551 b = append(b, kok.timeSeparator...)
557 b = strconv.AppendInt(b, int64(t.Minute()), 10)
558 b = append(b, kok.timeSeparator...)
564 b = strconv.AppendInt(b, int64(t.Second()), 10)
565 b = append(b, []byte{0x20}...)
568 b = append(b, kok.periodsAbbreviated[0]...)
570 b = append(b, kok.periodsAbbreviated[1]...)
576 // FmtTimeLong returns the long time representation of 't' for 'kok'
577 func (kok *kok) FmtTimeLong(t time.Time) string {
579 b := make([]byte, 0, 32)
587 b = strconv.AppendInt(b, int64(h), 10)
588 b = append(b, kok.timeSeparator...)
594 b = strconv.AppendInt(b, int64(t.Minute()), 10)
595 b = append(b, kok.timeSeparator...)
601 b = strconv.AppendInt(b, int64(t.Second()), 10)
602 b = append(b, []byte{0x20}...)
605 b = append(b, kok.periodsAbbreviated[0]...)
607 b = append(b, kok.periodsAbbreviated[1]...)
610 b = append(b, []byte{0x20}...)
618 // FmtTimeFull returns the full time representation of 't' for 'kok'
619 func (kok *kok) FmtTimeFull(t time.Time) string {
621 b := make([]byte, 0, 32)
629 b = strconv.AppendInt(b, int64(h), 10)
630 b = append(b, kok.timeSeparator...)
636 b = strconv.AppendInt(b, int64(t.Minute()), 10)
637 b = append(b, kok.timeSeparator...)
643 b = strconv.AppendInt(b, int64(t.Second()), 10)
644 b = append(b, []byte{0x20}...)
647 b = append(b, kok.periodsAbbreviated[0]...)
649 b = append(b, kok.periodsAbbreviated[1]...)
652 b = append(b, []byte{0x20}...)
656 if btz, ok := kok.timezones[tz]; ok {
657 b = append(b, btz...)