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 monthsAbbreviated []string
28 daysAbbreviated []string
32 periodsAbbreviated []string
33 periodsNarrow []string
36 erasAbbreviated []string
39 timezones map[string]string
42 // New returns a new instance of translator for the 'luo' locale
43 func New() locales.Translator {
50 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", "Ksh", "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"},
51 monthsAbbreviated: []string{"", "DAC", "DAR", "DAD", "DAN", "DAH", "DAU", "DAO", "DAB", "DOC", "DAP", "DGI", "DAG"},
52 monthsNarrow: []string{"", "C", "R", "D", "N", "B", "U", "B", "B", "C", "P", "C", "P"},
53 monthsWide: []string{"", "Dwe mar Achiel", "Dwe mar Ariyo", "Dwe mar Adek", "Dwe mar Ang’wen", "Dwe mar Abich", "Dwe mar Auchiel", "Dwe mar Abiriyo", "Dwe mar Aboro", "Dwe mar Ochiko", "Dwe mar Apar", "Dwe mar gi achiel", "Dwe mar Apar gi ariyo"},
54 daysAbbreviated: []string{"JMP", "WUT", "TAR", "TAD", "TAN", "TAB", "NGS"},
55 daysNarrow: []string{"J", "W", "T", "T", "T", "T", "N"},
56 daysWide: []string{"Jumapil", "Wuok Tich", "Tich Ariyo", "Tich Adek", "Tich Ang’wen", "Tich Abich", "Ngeso"},
57 periodsAbbreviated: []string{"OD", "OT"},
58 periodsWide: []string{"OD", "OT"},
59 erasAbbreviated: []string{"BC", "AD"},
60 erasNarrow: []string{"", ""},
61 erasWide: []string{"Kapok Kristo obiro", "Ka Kristo osebiro"},
62 timezones: map[string]string{"∅∅∅": "∅∅∅", "EDT": "EDT", "AKST": "AKST", "JST": "JST", "HNT": "HNT", "CDT": "CDT", "LHST": "LHST", "HEEG": "HEEG", "GFT": "GFT", "AKDT": "AKDT", "ACST": "ACST", "ECT": "ECT", "AST": "AST", "AEDT": "AEDT", "CAT": "CAT", "HNNOMX": "HNNOMX", "ART": "ART", "HAT": "HAT", "CLST": "CLST", "GYT": "GYT", "NZDT": "NZDT", "WART": "WART", "ADT": "ADT", "HNOG": "HNOG", "WAST": "WAST", "MDT": "MDT", "AWST": "AWST", "UYST": "UYST", "ARST": "ARST", "HEOG": "HEOG", "ACWST": "ACWST", "MEZ": "MEZ", "OEZ": "OEZ", "HENOMX": "HENOMX", "EAT": "EAT", "HNEG": "HNEG", "WESZ": "WESZ", "HECU": "HECU", "WITA": "WITA", "HKST": "HKST", "WEZ": "WEZ", "GMT": "GMT", "AEST": "AEST", "WAT": "WAT", "HNPM": "HNPM", "BOT": "BOT", "TMST": "TMST", "TMT": "TMT", "UYT": "UYT", "HAST": "HAST", "CLT": "CLT", "EST": "EST", "ACDT": "ACDT", "SGT": "SGT", "BT": "BT", "MYT": "MYT", "HADT": "HADT", "OESZ": "OESZ", "CHAST": "CHAST", "AWDT": "AWDT", "SRT": "SRT", "CHADT": "CHADT", "ACWDT": "ACWDT", "WIT": "WIT", "JDT": "JDT", "HEPM": "HEPM", "NZST": "NZST", "IST": "IST", "SAST": "SAST", "HKT": "HKT", "HEPMX": "HEPMX", "WIB": "WIB", "PST": "PST", "LHDT": "LHDT", "VET": "VET", "CST": "CST", "MST": "MST", "COT": "COT", "COST": "COST", "ChST": "ChST", "HNPMX": "HNPMX", "PDT": "PDT", "HNCU": "HNCU", "MESZ": "MESZ", "WARST": "WARST"},
66 // Locale returns the current translators string locale
67 func (luo *luo) Locale() string {
71 // PluralsCardinal returns the list of cardinal plural rules associated with 'luo'
72 func (luo *luo) PluralsCardinal() []locales.PluralRule {
73 return luo.pluralsCardinal
76 // PluralsOrdinal returns the list of ordinal plural rules associated with 'luo'
77 func (luo *luo) PluralsOrdinal() []locales.PluralRule {
78 return luo.pluralsOrdinal
81 // PluralsRange returns the list of range plural rules associated with 'luo'
82 func (luo *luo) PluralsRange() []locales.PluralRule {
83 return luo.pluralsRange
86 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'luo'
87 func (luo *luo) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
88 return locales.PluralRuleUnknown
91 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'luo'
92 func (luo *luo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
93 return locales.PluralRuleUnknown
96 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'luo'
97 func (luo *luo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
98 return locales.PluralRuleUnknown
101 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
102 func (luo *luo) MonthAbbreviated(month time.Month) string {
103 return luo.monthsAbbreviated[month]
106 // MonthsAbbreviated returns the locales abbreviated months
107 func (luo *luo) MonthsAbbreviated() []string {
108 return luo.monthsAbbreviated[1:]
111 // MonthNarrow returns the locales narrow month given the 'month' provided
112 func (luo *luo) MonthNarrow(month time.Month) string {
113 return luo.monthsNarrow[month]
116 // MonthsNarrow returns the locales narrow months
117 func (luo *luo) MonthsNarrow() []string {
118 return luo.monthsNarrow[1:]
121 // MonthWide returns the locales wide month given the 'month' provided
122 func (luo *luo) MonthWide(month time.Month) string {
123 return luo.monthsWide[month]
126 // MonthsWide returns the locales wide months
127 func (luo *luo) MonthsWide() []string {
128 return luo.monthsWide[1:]
131 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
132 func (luo *luo) WeekdayAbbreviated(weekday time.Weekday) string {
133 return luo.daysAbbreviated[weekday]
136 // WeekdaysAbbreviated returns the locales abbreviated weekdays
137 func (luo *luo) WeekdaysAbbreviated() []string {
138 return luo.daysAbbreviated
141 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
142 func (luo *luo) WeekdayNarrow(weekday time.Weekday) string {
143 return luo.daysNarrow[weekday]
146 // WeekdaysNarrow returns the locales narrow weekdays
147 func (luo *luo) WeekdaysNarrow() []string {
148 return luo.daysNarrow
151 // WeekdayShort returns the locales short weekday given the 'weekday' provided
152 func (luo *luo) WeekdayShort(weekday time.Weekday) string {
153 return luo.daysShort[weekday]
156 // WeekdaysShort returns the locales short weekdays
157 func (luo *luo) WeekdaysShort() []string {
161 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
162 func (luo *luo) WeekdayWide(weekday time.Weekday) string {
163 return luo.daysWide[weekday]
166 // WeekdaysWide returns the locales wide weekdays
167 func (luo *luo) WeekdaysWide() []string {
171 // Decimal returns the decimal point of number
172 func (luo *luo) Decimal() string {
176 // Group returns the group of number
177 func (luo *luo) Group() string {
181 // Group returns the minus sign of number
182 func (luo *luo) Minus() string {
186 // FmtNumber returns 'num' with digits/precision of 'v' for 'luo' and handles both Whole and Real numbers based on 'v'
187 func (luo *luo) FmtNumber(num float64, v uint64) string {
189 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
192 // FmtPercent returns 'num' with digits/precision of 'v' for 'luo' and handles both Whole and Real numbers based on 'v'
193 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
194 func (luo *luo) FmtPercent(num float64, v uint64) string {
195 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
198 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'luo'
199 func (luo *luo) FmtCurrency(num float64, v uint64, currency currency.Type) string {
201 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
202 symbol := luo.currencies[currency]
203 l := len(s) + len(symbol) + 0
206 b := make([]byte, 0, l)
208 for i := len(s) - 1; i >= 0; i-- {
211 b = append(b, luo.decimal[0])
218 b = append(b, luo.group[0])
229 b = append(b, luo.minus[0])
233 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
234 b[i], b[j] = b[j], b[i]
240 b = append(b, luo.decimal...)
243 for i := 0; i < 2-int(v); i++ {
248 b = append(b, symbol...)
253 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'luo'
254 // in accounting notation.
255 func (luo *luo) FmtAccounting(num float64, v uint64, currency currency.Type) string {
257 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
258 symbol := luo.currencies[currency]
259 l := len(s) + len(symbol) + 0
262 b := make([]byte, 0, l)
264 for i := len(s) - 1; i >= 0; i-- {
267 b = append(b, luo.decimal[0])
274 b = append(b, luo.group[0])
286 b = append(b, luo.minus[0])
291 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
292 b[i], b[j] = b[j], b[i]
298 b = append(b, luo.decimal...)
301 for i := 0; i < 2-int(v); i++ {
307 b = append(b, symbol...)
310 b = append(b, symbol...)
316 // FmtDateShort returns the short date representation of 't' for 'luo'
317 func (luo *luo) FmtDateShort(t time.Time) string {
319 b := make([]byte, 0, 32)
325 b = strconv.AppendInt(b, int64(t.Day()), 10)
326 b = append(b, []byte{0x2f}...)
332 b = strconv.AppendInt(b, int64(t.Month()), 10)
334 b = append(b, []byte{0x2f}...)
337 b = strconv.AppendInt(b, int64(t.Year()), 10)
339 b = strconv.AppendInt(b, int64(-t.Year()), 10)
345 // FmtDateMedium returns the medium date representation of 't' for 'luo'
346 func (luo *luo) FmtDateMedium(t time.Time) string {
348 b := make([]byte, 0, 32)
350 b = strconv.AppendInt(b, int64(t.Day()), 10)
351 b = append(b, []byte{0x20}...)
352 b = append(b, luo.monthsAbbreviated[t.Month()]...)
353 b = append(b, []byte{0x20}...)
356 b = strconv.AppendInt(b, int64(t.Year()), 10)
358 b = strconv.AppendInt(b, int64(-t.Year()), 10)
364 // FmtDateLong returns the long date representation of 't' for 'luo'
365 func (luo *luo) FmtDateLong(t time.Time) string {
367 b := make([]byte, 0, 32)
369 b = strconv.AppendInt(b, int64(t.Day()), 10)
370 b = append(b, []byte{0x20}...)
371 b = append(b, luo.monthsWide[t.Month()]...)
372 b = append(b, []byte{0x20}...)
375 b = strconv.AppendInt(b, int64(t.Year()), 10)
377 b = strconv.AppendInt(b, int64(-t.Year()), 10)
383 // FmtDateFull returns the full date representation of 't' for 'luo'
384 func (luo *luo) FmtDateFull(t time.Time) string {
386 b := make([]byte, 0, 32)
388 b = append(b, luo.daysWide[t.Weekday()]...)
389 b = append(b, []byte{0x2c, 0x20}...)
390 b = strconv.AppendInt(b, int64(t.Day()), 10)
391 b = append(b, []byte{0x20}...)
392 b = append(b, luo.monthsWide[t.Month()]...)
393 b = append(b, []byte{0x20}...)
396 b = strconv.AppendInt(b, int64(t.Year()), 10)
398 b = strconv.AppendInt(b, int64(-t.Year()), 10)
404 // FmtTimeShort returns the short time representation of 't' for 'luo'
405 func (luo *luo) FmtTimeShort(t time.Time) string {
407 b := make([]byte, 0, 32)
413 b = strconv.AppendInt(b, int64(t.Hour()), 10)
414 b = append(b, luo.timeSeparator...)
420 b = strconv.AppendInt(b, int64(t.Minute()), 10)
425 // FmtTimeMedium returns the medium time representation of 't' for 'luo'
426 func (luo *luo) FmtTimeMedium(t time.Time) string {
428 b := make([]byte, 0, 32)
434 b = strconv.AppendInt(b, int64(t.Hour()), 10)
435 b = append(b, luo.timeSeparator...)
441 b = strconv.AppendInt(b, int64(t.Minute()), 10)
442 b = append(b, luo.timeSeparator...)
448 b = strconv.AppendInt(b, int64(t.Second()), 10)
453 // FmtTimeLong returns the long time representation of 't' for 'luo'
454 func (luo *luo) FmtTimeLong(t time.Time) string {
456 b := make([]byte, 0, 32)
462 b = strconv.AppendInt(b, int64(t.Hour()), 10)
463 b = append(b, luo.timeSeparator...)
469 b = strconv.AppendInt(b, int64(t.Minute()), 10)
470 b = append(b, luo.timeSeparator...)
476 b = strconv.AppendInt(b, int64(t.Second()), 10)
477 b = append(b, []byte{0x20}...)
485 // FmtTimeFull returns the full time representation of 't' for 'luo'
486 func (luo *luo) FmtTimeFull(t time.Time) string {
488 b := make([]byte, 0, 32)
494 b = strconv.AppendInt(b, int64(t.Hour()), 10)
495 b = append(b, luo.timeSeparator...)
501 b = strconv.AppendInt(b, int64(t.Minute()), 10)
502 b = append(b, luo.timeSeparator...)
508 b = strconv.AppendInt(b, int64(t.Second()), 10)
509 b = append(b, []byte{0x20}...)
513 if btz, ok := luo.timezones[tz]; ok {
514 b = append(b, btz...)