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 currencyPositiveSuffix string
26 currencyNegativeSuffix 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 'ln_CD' locale
45 func New() locales.Translator {
48 pluralsCardinal: []locales.PluralRule{2, 6},
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", "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"},
59 currencyPositiveSuffix: " ",
60 currencyNegativeSuffix: " ",
61 monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"},
62 monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"},
63 monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"},
64 daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"},
65 daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"},
66 daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"},
67 periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"},
68 periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"},
69 erasAbbreviated: []string{"libóso ya", "nsima ya Y"},
70 erasNarrow: []string{"", ""},
71 erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"},
72 timezones: map[string]string{"PDT": "PDT", "OESZ": "OESZ", "MST": "MST", "HNOG": "HNOG", "CLT": "CLT", "EDT": "EDT", "GYT": "GYT", "ACDT": "ACDT", "HEOG": "HEOG", "COST": "COST", "AWDT": "AWDT", "UYT": "UYT", "NZDT": "NZDT", "HNNOMX": "HNNOMX", "AEST": "AEST", "AWST": "AWST", "MESZ": "MESZ", "JDT": "JDT", "MDT": "MDT", "WAST": "WAST", "HKT": "HKT", "SRT": "SRT", "NZST": "NZST", "AST": "AST", "ART": "ART", "CLST": "CLST", "AKST": "AKST", "SGT": "SGT", "HEPM": "HEPM", "WARST": "WARST", "HENOMX": "HENOMX", "CST": "CST", "WIT": "WIT", "HAST": "HAST", "IST": "IST", "COT": "COT", "HNT": "HNT", "HECU": "HECU", "BOT": "BOT", "ARST": "ARST", "HAT": "HAT", "ACWST": "ACWST", "HADT": "HADT", "VET": "VET", "OEZ": "OEZ", "LHST": "LHST", "∅∅∅": "∅∅∅", "CHADT": "CHADT", "MYT": "MYT", "WART": "WART", "WITA": "WITA", "WEZ": "WEZ", "HNPMX": "HNPMX", "BT": "BT", "ACWDT": "ACWDT", "MEZ": "MEZ", "ADT": "ADT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "WESZ": "WESZ", "HEPMX": "HEPMX", "CDT": "CDT", "TMST": "TMST", "HEEG": "HEEG", "GFT": "GFT", "ECT": "ECT", "GMT": "Ntángo ya Londoni", "HNCU": "HNCU", "HNPM": "HNPM", "TMT": "TMT", "JST": "JST", "LHDT": "LHDT", "ACST": "ACST", "CAT": "Ntángo ya Lubumbashi", "WIB": "WIB", "ChST": "ChST", "UYST": "UYST", "SAST": "Ntángo ya Afríka ya Sidi", "AKDT": "AKDT", "AEDT": "AEDT", "HNEG": "HNEG", "WAT": "WAT", "HKST": "HKST", "EST": "EST", "PST": "PST", "CHAST": "CHAST"},
76 // Locale returns the current translators string locale
77 func (ln *ln_CD) Locale() string {
81 // PluralsCardinal returns the list of cardinal plural rules associated with 'ln_CD'
82 func (ln *ln_CD) PluralsCardinal() []locales.PluralRule {
83 return ln.pluralsCardinal
86 // PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_CD'
87 func (ln *ln_CD) PluralsOrdinal() []locales.PluralRule {
88 return ln.pluralsOrdinal
91 // PluralsRange returns the list of range plural rules associated with 'ln_CD'
92 func (ln *ln_CD) PluralsRange() []locales.PluralRule {
93 return ln.pluralsRange
96 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD'
97 func (ln *ln_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
101 if n >= 0 && n <= 1 {
102 return locales.PluralRuleOne
105 return locales.PluralRuleOther
108 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD'
109 func (ln *ln_CD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
110 return locales.PluralRuleUnknown
113 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln_CD'
114 func (ln *ln_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
115 return locales.PluralRuleUnknown
118 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
119 func (ln *ln_CD) MonthAbbreviated(month time.Month) string {
120 return ln.monthsAbbreviated[month]
123 // MonthsAbbreviated returns the locales abbreviated months
124 func (ln *ln_CD) MonthsAbbreviated() []string {
125 return ln.monthsAbbreviated[1:]
128 // MonthNarrow returns the locales narrow month given the 'month' provided
129 func (ln *ln_CD) MonthNarrow(month time.Month) string {
130 return ln.monthsNarrow[month]
133 // MonthsNarrow returns the locales narrow months
134 func (ln *ln_CD) MonthsNarrow() []string {
135 return ln.monthsNarrow[1:]
138 // MonthWide returns the locales wide month given the 'month' provided
139 func (ln *ln_CD) MonthWide(month time.Month) string {
140 return ln.monthsWide[month]
143 // MonthsWide returns the locales wide months
144 func (ln *ln_CD) MonthsWide() []string {
145 return ln.monthsWide[1:]
148 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
149 func (ln *ln_CD) WeekdayAbbreviated(weekday time.Weekday) string {
150 return ln.daysAbbreviated[weekday]
153 // WeekdaysAbbreviated returns the locales abbreviated weekdays
154 func (ln *ln_CD) WeekdaysAbbreviated() []string {
155 return ln.daysAbbreviated
158 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
159 func (ln *ln_CD) WeekdayNarrow(weekday time.Weekday) string {
160 return ln.daysNarrow[weekday]
163 // WeekdaysNarrow returns the locales narrow weekdays
164 func (ln *ln_CD) WeekdaysNarrow() []string {
168 // WeekdayShort returns the locales short weekday given the 'weekday' provided
169 func (ln *ln_CD) WeekdayShort(weekday time.Weekday) string {
170 return ln.daysShort[weekday]
173 // WeekdaysShort returns the locales short weekdays
174 func (ln *ln_CD) WeekdaysShort() []string {
178 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
179 func (ln *ln_CD) WeekdayWide(weekday time.Weekday) string {
180 return ln.daysWide[weekday]
183 // WeekdaysWide returns the locales wide weekdays
184 func (ln *ln_CD) WeekdaysWide() []string {
188 // Decimal returns the decimal point of number
189 func (ln *ln_CD) Decimal() string {
193 // Group returns the group of number
194 func (ln *ln_CD) Group() string {
198 // Group returns the minus sign of number
199 func (ln *ln_CD) Minus() string {
203 // FmtNumber returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v'
204 func (ln *ln_CD) FmtNumber(num float64, v uint64) string {
206 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
207 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
210 b := make([]byte, 0, l)
212 for i := len(s) - 1; i >= 0; i-- {
215 b = append(b, ln.decimal[0])
222 b = append(b, ln.group[0])
233 b = append(b, ln.minus[0])
237 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
238 b[i], b[j] = b[j], b[i]
244 // FmtPercent returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v'
245 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
246 func (ln *ln_CD) FmtPercent(num float64, v uint64) string {
247 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD'
251 func (ln *ln_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string {
253 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
254 symbol := ln.currencies[currency]
255 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
258 b := make([]byte, 0, l)
260 for i := len(s) - 1; i >= 0; i-- {
263 b = append(b, ln.decimal[0])
270 b = append(b, ln.group[0])
281 b = append(b, ln.minus[0])
285 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
286 b[i], b[j] = b[j], b[i]
292 b = append(b, ln.decimal...)
295 for i := 0; i < 2-int(v); i++ {
300 b = append(b, ln.currencyPositiveSuffix...)
302 b = append(b, symbol...)
307 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD'
308 // in accounting notation.
309 func (ln *ln_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string {
311 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
312 symbol := ln.currencies[currency]
313 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
316 b := make([]byte, 0, l)
318 for i := len(s) - 1; i >= 0; i-- {
321 b = append(b, ln.decimal[0])
328 b = append(b, ln.group[0])
340 b = append(b, ln.minus[0])
345 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
346 b[i], b[j] = b[j], b[i]
352 b = append(b, ln.decimal...)
355 for i := 0; i < 2-int(v); i++ {
361 b = append(b, ln.currencyNegativeSuffix...)
362 b = append(b, symbol...)
365 b = append(b, ln.currencyPositiveSuffix...)
366 b = append(b, symbol...)
372 // FmtDateShort returns the short date representation of 't' for 'ln_CD'
373 func (ln *ln_CD) FmtDateShort(t time.Time) string {
375 b := make([]byte, 0, 32)
377 b = strconv.AppendInt(b, int64(t.Day()), 10)
378 b = append(b, []byte{0x2f}...)
379 b = strconv.AppendInt(b, int64(t.Month()), 10)
380 b = append(b, []byte{0x2f}...)
383 b = strconv.AppendInt(b, int64(t.Year()), 10)
385 b = strconv.AppendInt(b, int64(-t.Year()), 10)
391 // FmtDateMedium returns the medium date representation of 't' for 'ln_CD'
392 func (ln *ln_CD) FmtDateMedium(t time.Time) string {
394 b := make([]byte, 0, 32)
396 b = strconv.AppendInt(b, int64(t.Day()), 10)
397 b = append(b, []byte{0x20}...)
398 b = append(b, ln.monthsAbbreviated[t.Month()]...)
399 b = append(b, []byte{0x20}...)
402 b = strconv.AppendInt(b, int64(t.Year()), 10)
404 b = strconv.AppendInt(b, int64(-t.Year()), 10)
410 // FmtDateLong returns the long date representation of 't' for 'ln_CD'
411 func (ln *ln_CD) FmtDateLong(t time.Time) string {
413 b := make([]byte, 0, 32)
415 b = strconv.AppendInt(b, int64(t.Day()), 10)
416 b = append(b, []byte{0x20}...)
417 b = append(b, ln.monthsWide[t.Month()]...)
418 b = append(b, []byte{0x20}...)
421 b = strconv.AppendInt(b, int64(t.Year()), 10)
423 b = strconv.AppendInt(b, int64(-t.Year()), 10)
429 // FmtDateFull returns the full date representation of 't' for 'ln_CD'
430 func (ln *ln_CD) FmtDateFull(t time.Time) string {
432 b := make([]byte, 0, 32)
434 b = append(b, ln.daysWide[t.Weekday()]...)
435 b = append(b, []byte{0x20}...)
436 b = strconv.AppendInt(b, int64(t.Day()), 10)
437 b = append(b, []byte{0x20}...)
438 b = append(b, ln.monthsWide[t.Month()]...)
439 b = append(b, []byte{0x20}...)
442 b = strconv.AppendInt(b, int64(t.Year()), 10)
444 b = strconv.AppendInt(b, int64(-t.Year()), 10)
450 // FmtTimeShort returns the short time representation of 't' for 'ln_CD'
451 func (ln *ln_CD) FmtTimeShort(t time.Time) string {
453 b := make([]byte, 0, 32)
459 b = strconv.AppendInt(b, int64(t.Hour()), 10)
460 b = append(b, ln.timeSeparator...)
466 b = strconv.AppendInt(b, int64(t.Minute()), 10)
471 // FmtTimeMedium returns the medium time representation of 't' for 'ln_CD'
472 func (ln *ln_CD) FmtTimeMedium(t time.Time) string {
474 b := make([]byte, 0, 32)
480 b = strconv.AppendInt(b, int64(t.Hour()), 10)
481 b = append(b, ln.timeSeparator...)
487 b = strconv.AppendInt(b, int64(t.Minute()), 10)
488 b = append(b, ln.timeSeparator...)
494 b = strconv.AppendInt(b, int64(t.Second()), 10)
499 // FmtTimeLong returns the long time representation of 't' for 'ln_CD'
500 func (ln *ln_CD) FmtTimeLong(t time.Time) string {
502 b := make([]byte, 0, 32)
508 b = strconv.AppendInt(b, int64(t.Hour()), 10)
509 b = append(b, ln.timeSeparator...)
515 b = strconv.AppendInt(b, int64(t.Minute()), 10)
516 b = append(b, ln.timeSeparator...)
522 b = strconv.AppendInt(b, int64(t.Second()), 10)
523 b = append(b, []byte{0x20}...)
531 // FmtTimeFull returns the full time representation of 't' for 'ln_CD'
532 func (ln *ln_CD) FmtTimeFull(t time.Time) string {
534 b := make([]byte, 0, 32)
540 b = strconv.AppendInt(b, int64(t.Hour()), 10)
541 b = append(b, ln.timeSeparator...)
547 b = strconv.AppendInt(b, int64(t.Minute()), 10)
548 b = append(b, ln.timeSeparator...)
554 b = strconv.AppendInt(b, int64(t.Second()), 10)
555 b = append(b, []byte{0x20}...)
559 if btz, ok := ln.timezones[tz]; ok {
560 b = append(b, btz...)