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 'nmg' locale
45 func New() locales.Translator {
54 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"},
55 currencyPositiveSuffix: " ",
56 currencyNegativeSuffix: " ",
57 monthsAbbreviated: []string{"", "ng1", "ng2", "ng3", "ng4", "ng5", "ng6", "ng7", "ng8", "ng9", "ng10", "ng11", "kris"},
58 monthsWide: []string{"", "ngwɛn matáhra", "ngwɛn ńmba", "ngwɛn ńlal", "ngwɛn ńna", "ngwɛn ńtan", "ngwɛn ńtuó", "ngwɛn hɛmbuɛrí", "ngwɛn lɔmbi", "ngwɛn rɛbvuâ", "ngwɛn wum", "ngwɛn wum navǔr", "krísimin"},
59 daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "mbs", "sas"},
60 daysNarrow: []string{"s", "m", "s", "s", "s", "m", "s"},
61 daysWide: []string{"sɔ́ndɔ", "mɔ́ndɔ", "sɔ́ndɔ mafú mába", "sɔ́ndɔ mafú málal", "sɔ́ndɔ mafú mána", "mabágá má sukul", "sásadi"},
62 periodsAbbreviated: []string{"maná", "kugú"},
63 periodsWide: []string{"maná", "kugú"},
64 erasAbbreviated: []string{"BL", "PB"},
65 erasNarrow: []string{"", ""},
66 erasWide: []string{"Bó Lahlɛ̄", "Pfiɛ Burī"},
67 timezones: map[string]string{"HAT": "HAT", "ACWDT": "ACWDT", "LHST": "LHST", "VET": "VET", "AEDT": "AEDT", "COST": "COST", "WIB": "WIB", "UYST": "UYST", "HKT": "HKT", "HKST": "HKST", "MESZ": "MESZ", "OEZ": "OEZ", "LHDT": "LHDT", "AEST": "AEST", "ART": "ART", "ACST": "ACST", "GMT": "GMT", "PDT": "PDT", "MYT": "MYT", "JDT": "JDT", "HEOG": "HEOG", "COT": "COT", "HEPM": "HEPM", "HNOG": "HNOG", "HNEG": "HNEG", "PST": "PST", "MST": "MST", "SRT": "SRT", "JST": "JST", "HNCU": "HNCU", "HNPM": "HNPM", "HENOMX": "HENOMX", "IST": "IST", "WAT": "WAT", "AKST": "AKST", "WIT": "WIT", "TMT": "TMT", "TMST": "TMST", "SAST": "SAST", "HNT": "HNT", "CLT": "CLT", "CAT": "CAT", "WAST": "WAST", "CLST": "CLST", "SGT": "SGT", "HNPMX": "HNPMX", "BT": "BT", "MEZ": "MEZ", "HAST": "HAST", "GFT": "GFT", "EDT": "EDT", "AKDT": "AKDT", "CDT": "CDT", "MDT": "MDT", "HADT": "HADT", "NZDT": "NZDT", "OESZ": "OESZ", "EST": "EST", "ChST": "ChST", "HEPMX": "HEPMX", "WARST": "WARST", "GYT": "GYT", "WEZ": "WEZ", "AWDT": "AWDT", "AST": "AST", "ECT": "ECT", "∅∅∅": "∅∅∅", "HECU": "HECU", "NZST": "NZST", "ACDT": "ACDT", "AWST": "AWST", "ACWST": "ACWST", "ADT": "ADT", "ARST": "ARST", "HEEG": "HEEG", "WESZ": "WESZ", "CHAST": "CHAST", "CHADT": "CHADT", "BOT": "BOT", "CST": "CST", "UYT": "UYT", "WART": "WART", "HNNOMX": "HNNOMX", "WITA": "WITA", "EAT": "EAT"},
71 // Locale returns the current translators string locale
72 func (nmg *nmg) Locale() string {
76 // PluralsCardinal returns the list of cardinal plural rules associated with 'nmg'
77 func (nmg *nmg) PluralsCardinal() []locales.PluralRule {
78 return nmg.pluralsCardinal
81 // PluralsOrdinal returns the list of ordinal plural rules associated with 'nmg'
82 func (nmg *nmg) PluralsOrdinal() []locales.PluralRule {
83 return nmg.pluralsOrdinal
86 // PluralsRange returns the list of range plural rules associated with 'nmg'
87 func (nmg *nmg) PluralsRange() []locales.PluralRule {
88 return nmg.pluralsRange
91 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nmg'
92 func (nmg *nmg) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
93 return locales.PluralRuleUnknown
96 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nmg'
97 func (nmg *nmg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
98 return locales.PluralRuleUnknown
101 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nmg'
102 func (nmg *nmg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
103 return locales.PluralRuleUnknown
106 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
107 func (nmg *nmg) MonthAbbreviated(month time.Month) string {
108 return nmg.monthsAbbreviated[month]
111 // MonthsAbbreviated returns the locales abbreviated months
112 func (nmg *nmg) MonthsAbbreviated() []string {
113 return nmg.monthsAbbreviated[1:]
116 // MonthNarrow returns the locales narrow month given the 'month' provided
117 func (nmg *nmg) MonthNarrow(month time.Month) string {
118 return nmg.monthsNarrow[month]
121 // MonthsNarrow returns the locales narrow months
122 func (nmg *nmg) MonthsNarrow() []string {
126 // MonthWide returns the locales wide month given the 'month' provided
127 func (nmg *nmg) MonthWide(month time.Month) string {
128 return nmg.monthsWide[month]
131 // MonthsWide returns the locales wide months
132 func (nmg *nmg) MonthsWide() []string {
133 return nmg.monthsWide[1:]
136 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
137 func (nmg *nmg) WeekdayAbbreviated(weekday time.Weekday) string {
138 return nmg.daysAbbreviated[weekday]
141 // WeekdaysAbbreviated returns the locales abbreviated weekdays
142 func (nmg *nmg) WeekdaysAbbreviated() []string {
143 return nmg.daysAbbreviated
146 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
147 func (nmg *nmg) WeekdayNarrow(weekday time.Weekday) string {
148 return nmg.daysNarrow[weekday]
151 // WeekdaysNarrow returns the locales narrow weekdays
152 func (nmg *nmg) WeekdaysNarrow() []string {
153 return nmg.daysNarrow
156 // WeekdayShort returns the locales short weekday given the 'weekday' provided
157 func (nmg *nmg) WeekdayShort(weekday time.Weekday) string {
158 return nmg.daysShort[weekday]
161 // WeekdaysShort returns the locales short weekdays
162 func (nmg *nmg) WeekdaysShort() []string {
166 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
167 func (nmg *nmg) WeekdayWide(weekday time.Weekday) string {
168 return nmg.daysWide[weekday]
171 // WeekdaysWide returns the locales wide weekdays
172 func (nmg *nmg) WeekdaysWide() []string {
176 // Decimal returns the decimal point of number
177 func (nmg *nmg) Decimal() string {
181 // Group returns the group of number
182 func (nmg *nmg) Group() string {
186 // Group returns the minus sign of number
187 func (nmg *nmg) Minus() string {
191 // FmtNumber returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v'
192 func (nmg *nmg) FmtNumber(num float64, v uint64) string {
194 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
195 l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3
198 b := make([]byte, 0, l)
200 for i := len(s) - 1; i >= 0; i-- {
203 b = append(b, nmg.decimal[0])
210 for j := len(nmg.group) - 1; j >= 0; j-- {
211 b = append(b, nmg.group[j])
223 b = append(b, nmg.minus[0])
227 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
228 b[i], b[j] = b[j], b[i]
234 // FmtPercent returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v'
235 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
236 func (nmg *nmg) FmtPercent(num float64, v uint64) string {
237 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
239 b := make([]byte, 0, l)
241 for i := len(s) - 1; i >= 0; i-- {
244 b = append(b, nmg.decimal[0])
252 b = append(b, nmg.minus[0])
256 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
257 b[i], b[j] = b[j], b[i]
260 b = append(b, nmg.percent...)
265 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nmg'
266 func (nmg *nmg) FmtCurrency(num float64, v uint64, currency currency.Type) string {
268 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 symbol := nmg.currencies[currency]
270 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
273 b := make([]byte, 0, l)
275 for i := len(s) - 1; i >= 0; i-- {
278 b = append(b, nmg.decimal[0])
285 for j := len(nmg.group) - 1; j >= 0; j-- {
286 b = append(b, nmg.group[j])
298 b = append(b, nmg.minus[0])
302 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
303 b[i], b[j] = b[j], b[i]
309 b = append(b, nmg.decimal...)
312 for i := 0; i < 2-int(v); i++ {
317 b = append(b, nmg.currencyPositiveSuffix...)
319 b = append(b, symbol...)
324 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nmg'
325 // in accounting notation.
326 func (nmg *nmg) FmtAccounting(num float64, v uint64, currency currency.Type) string {
328 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
329 symbol := nmg.currencies[currency]
330 l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
333 b := make([]byte, 0, l)
335 for i := len(s) - 1; i >= 0; i-- {
338 b = append(b, nmg.decimal[0])
345 for j := len(nmg.group) - 1; j >= 0; j-- {
346 b = append(b, nmg.group[j])
359 b = append(b, nmg.minus[0])
364 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
365 b[i], b[j] = b[j], b[i]
371 b = append(b, nmg.decimal...)
374 for i := 0; i < 2-int(v); i++ {
380 b = append(b, nmg.currencyNegativeSuffix...)
381 b = append(b, symbol...)
384 b = append(b, nmg.currencyPositiveSuffix...)
385 b = append(b, symbol...)
391 // FmtDateShort returns the short date representation of 't' for 'nmg'
392 func (nmg *nmg) FmtDateShort(t time.Time) string {
394 b := make([]byte, 0, 32)
396 b = strconv.AppendInt(b, int64(t.Day()), 10)
397 b = append(b, []byte{0x2f}...)
398 b = strconv.AppendInt(b, int64(t.Month()), 10)
399 b = append(b, []byte{0x2f}...)
402 b = strconv.AppendInt(b, int64(t.Year()), 10)
404 b = strconv.AppendInt(b, int64(-t.Year()), 10)
410 // FmtDateMedium returns the medium date representation of 't' for 'nmg'
411 func (nmg *nmg) FmtDateMedium(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, nmg.monthsAbbreviated[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 // FmtDateLong returns the long date representation of 't' for 'nmg'
430 func (nmg *nmg) FmtDateLong(t time.Time) string {
432 b := make([]byte, 0, 32)
434 b = strconv.AppendInt(b, int64(t.Day()), 10)
435 b = append(b, []byte{0x20}...)
436 b = append(b, nmg.monthsWide[t.Month()]...)
437 b = append(b, []byte{0x20}...)
440 b = strconv.AppendInt(b, int64(t.Year()), 10)
442 b = strconv.AppendInt(b, int64(-t.Year()), 10)
448 // FmtDateFull returns the full date representation of 't' for 'nmg'
449 func (nmg *nmg) FmtDateFull(t time.Time) string {
451 b := make([]byte, 0, 32)
453 b = append(b, nmg.daysWide[t.Weekday()]...)
454 b = append(b, []byte{0x20}...)
455 b = strconv.AppendInt(b, int64(t.Day()), 10)
456 b = append(b, []byte{0x20}...)
457 b = append(b, nmg.monthsWide[t.Month()]...)
458 b = append(b, []byte{0x20}...)
461 b = strconv.AppendInt(b, int64(t.Year()), 10)
463 b = strconv.AppendInt(b, int64(-t.Year()), 10)
469 // FmtTimeShort returns the short time representation of 't' for 'nmg'
470 func (nmg *nmg) FmtTimeShort(t time.Time) string {
472 b := make([]byte, 0, 32)
478 b = strconv.AppendInt(b, int64(t.Hour()), 10)
479 b = append(b, nmg.timeSeparator...)
485 b = strconv.AppendInt(b, int64(t.Minute()), 10)
490 // FmtTimeMedium returns the medium time representation of 't' for 'nmg'
491 func (nmg *nmg) FmtTimeMedium(t time.Time) string {
493 b := make([]byte, 0, 32)
499 b = strconv.AppendInt(b, int64(t.Hour()), 10)
500 b = append(b, nmg.timeSeparator...)
506 b = strconv.AppendInt(b, int64(t.Minute()), 10)
507 b = append(b, nmg.timeSeparator...)
513 b = strconv.AppendInt(b, int64(t.Second()), 10)
518 // FmtTimeLong returns the long time representation of 't' for 'nmg'
519 func (nmg *nmg) FmtTimeLong(t time.Time) string {
521 b := make([]byte, 0, 32)
527 b = strconv.AppendInt(b, int64(t.Hour()), 10)
528 b = append(b, nmg.timeSeparator...)
534 b = strconv.AppendInt(b, int64(t.Minute()), 10)
535 b = append(b, nmg.timeSeparator...)
541 b = strconv.AppendInt(b, int64(t.Second()), 10)
542 b = append(b, []byte{0x20}...)
550 // FmtTimeFull returns the full time representation of 't' for 'nmg'
551 func (nmg *nmg) FmtTimeFull(t time.Time) string {
553 b := make([]byte, 0, 32)
559 b = strconv.AppendInt(b, int64(t.Hour()), 10)
560 b = append(b, nmg.timeSeparator...)
566 b = strconv.AppendInt(b, int64(t.Minute()), 10)
567 b = append(b, nmg.timeSeparator...)
573 b = strconv.AppendInt(b, int64(t.Second()), 10)
574 b = append(b, []byte{0x20}...)
578 if btz, ok := nmg.timezones[tz]; ok {
579 b = append(b, btz...)