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 'naq' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 3, 6},
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", "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", "$", "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{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
52 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
53 monthsWide: []string{"", "ǃKhanni", "ǃKhanǀgôab", "ǀKhuuǁkhâb", "ǃHôaǂkhaib", "ǃKhaitsâb", "Gamaǀaeb", "ǂKhoesaob", "Aoǁkhuumûǁkhâb", "Taraǀkhuumûǁkhâb", "ǂNûǁnâiseb", "ǀHooǂgaeb", "Hôasoreǁkhâb"},
54 daysAbbreviated: []string{"Son", "Ma", "De", "Wu", "Do", "Fr", "Sat"},
55 daysNarrow: []string{"S", "M", "E", "W", "D", "F", "A"},
56 daysWide: []string{"Sontaxtsees", "Mantaxtsees", "Denstaxtsees", "Wunstaxtsees", "Dondertaxtsees", "Fraitaxtsees", "Satertaxtsees"},
57 periodsAbbreviated: []string{"ǁgoagas", "ǃuias"},
58 periodsWide: []string{"ǁgoagas", "ǃuias"},
59 erasAbbreviated: []string{"BC", "AD"},
60 erasNarrow: []string{"", ""},
61 erasWide: []string{"Xristub aiǃâ", "Xristub khaoǃgâ"},
62 timezones: map[string]string{"MST": "MST", "MEZ": "MEZ", "OESZ": "OESZ", "EDT": "EDT", "BT": "BT", "WIB": "WIB", "CHADT": "CHADT", "HNCU": "HNCU", "TMST": "TMST", "HNNOMX": "HNNOMX", "WITA": "WITA", "WAST": "WAST", "ChST": "ChST", "SGT": "SGT", "CLT": "CLT", "WARST": "WARST", "HAT": "HAT", "WESZ": "WESZ", "SRT": "SRT", "TMT": "TMT", "IST": "IST", "HNOG": "HNOG", "CHAST": "CHAST", "PST": "PST", "CDT": "CDT", "HENOMX": "HENOMX", "LHDT": "LHDT", "HNT": "HNT", "HKT": "HKT", "WEZ": "WEZ", "HNPMX": "HNPMX", "BOT": "BOT", "MDT": "MDT", "HAST": "HAST", "HADT": "HADT", "WART": "WART", "HEPM": "HEPM", "ECT": "ECT", "AKDT": "AKDT", "NZST": "NZST", "WAT": "WAT", "GFT": "GFT", "ACWST": "ACWST", "UYST": "UYST", "OEZ": "OEZ", "AST": "AST", "HEOG": "HEOG", "HEEG": "HEEG", "CLST": "CLST", "EST": "EST", "UYT": "UYT", "CST": "CST", "MESZ": "MESZ", "NZDT": "NZDT", "JST": "JST", "ART": "ART", "SAST": "SAST", "GMT": "GMT", "AEST": "AEST", "HNEG": "HNEG", "ACST": "ACST", "VET": "VET", "EAT": "EAT", "GYT": "GYT", "HEPMX": "HEPMX", "HECU": "HECU", "HNPM": "HNPM", "AWST": "AWST", "WIT": "WIT", "ADT": "ADT", "COT": "COT", "CAT": "CAT", "PDT": "PDT", "ACWDT": "ACWDT", "JDT": "JDT", "LHST": "LHST", "AKST": "AKST", "AWDT": "AWDT", "ARST": "ARST", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "HKST": "HKST", "COST": "COST", "ACDT": "ACDT", "MYT": "MYT"},
66 // Locale returns the current translators string locale
67 func (naq *naq) Locale() string {
71 // PluralsCardinal returns the list of cardinal plural rules associated with 'naq'
72 func (naq *naq) PluralsCardinal() []locales.PluralRule {
73 return naq.pluralsCardinal
76 // PluralsOrdinal returns the list of ordinal plural rules associated with 'naq'
77 func (naq *naq) PluralsOrdinal() []locales.PluralRule {
78 return naq.pluralsOrdinal
81 // PluralsRange returns the list of range plural rules associated with 'naq'
82 func (naq *naq) PluralsRange() []locales.PluralRule {
83 return naq.pluralsRange
86 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'naq'
87 func (naq *naq) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
92 return locales.PluralRuleOne
94 return locales.PluralRuleTwo
97 return locales.PluralRuleOther
100 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'naq'
101 func (naq *naq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
102 return locales.PluralRuleUnknown
105 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'naq'
106 func (naq *naq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
107 return locales.PluralRuleUnknown
110 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
111 func (naq *naq) MonthAbbreviated(month time.Month) string {
112 return naq.monthsAbbreviated[month]
115 // MonthsAbbreviated returns the locales abbreviated months
116 func (naq *naq) MonthsAbbreviated() []string {
117 return naq.monthsAbbreviated[1:]
120 // MonthNarrow returns the locales narrow month given the 'month' provided
121 func (naq *naq) MonthNarrow(month time.Month) string {
122 return naq.monthsNarrow[month]
125 // MonthsNarrow returns the locales narrow months
126 func (naq *naq) MonthsNarrow() []string {
127 return naq.monthsNarrow[1:]
130 // MonthWide returns the locales wide month given the 'month' provided
131 func (naq *naq) MonthWide(month time.Month) string {
132 return naq.monthsWide[month]
135 // MonthsWide returns the locales wide months
136 func (naq *naq) MonthsWide() []string {
137 return naq.monthsWide[1:]
140 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
141 func (naq *naq) WeekdayAbbreviated(weekday time.Weekday) string {
142 return naq.daysAbbreviated[weekday]
145 // WeekdaysAbbreviated returns the locales abbreviated weekdays
146 func (naq *naq) WeekdaysAbbreviated() []string {
147 return naq.daysAbbreviated
150 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
151 func (naq *naq) WeekdayNarrow(weekday time.Weekday) string {
152 return naq.daysNarrow[weekday]
155 // WeekdaysNarrow returns the locales narrow weekdays
156 func (naq *naq) WeekdaysNarrow() []string {
157 return naq.daysNarrow
160 // WeekdayShort returns the locales short weekday given the 'weekday' provided
161 func (naq *naq) WeekdayShort(weekday time.Weekday) string {
162 return naq.daysShort[weekday]
165 // WeekdaysShort returns the locales short weekdays
166 func (naq *naq) WeekdaysShort() []string {
170 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
171 func (naq *naq) WeekdayWide(weekday time.Weekday) string {
172 return naq.daysWide[weekday]
175 // WeekdaysWide returns the locales wide weekdays
176 func (naq *naq) WeekdaysWide() []string {
180 // Decimal returns the decimal point of number
181 func (naq *naq) Decimal() string {
185 // Group returns the group of number
186 func (naq *naq) Group() string {
190 // Group returns the minus sign of number
191 func (naq *naq) Minus() string {
195 // FmtNumber returns 'num' with digits/precision of 'v' for 'naq' and handles both Whole and Real numbers based on 'v'
196 func (naq *naq) FmtNumber(num float64, v uint64) string {
198 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
201 // FmtPercent returns 'num' with digits/precision of 'v' for 'naq' and handles both Whole and Real numbers based on 'v'
202 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
203 func (naq *naq) FmtPercent(num float64, v uint64) string {
204 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
207 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'naq'
208 func (naq *naq) FmtCurrency(num float64, v uint64, currency currency.Type) string {
210 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
211 symbol := naq.currencies[currency]
212 l := len(s) + len(symbol) + 0
215 b := make([]byte, 0, l)
217 for i := len(s) - 1; i >= 0; i-- {
220 b = append(b, naq.decimal[0])
227 b = append(b, naq.group[0])
237 for j := len(symbol) - 1; j >= 0; j-- {
238 b = append(b, symbol[j])
242 b = append(b, naq.minus[0])
246 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
247 b[i], b[j] = b[j], b[i]
253 b = append(b, naq.decimal...)
256 for i := 0; i < 2-int(v); i++ {
264 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'naq'
265 // in accounting notation.
266 func (naq *naq) FmtAccounting(num float64, v uint64, currency currency.Type) string {
268 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
269 symbol := naq.currencies[currency]
270 l := len(s) + len(symbol) + 0
273 b := make([]byte, 0, l)
275 for i := len(s) - 1; i >= 0; i-- {
278 b = append(b, naq.decimal[0])
285 b = append(b, naq.group[0])
297 for j := len(symbol) - 1; j >= 0; j-- {
298 b = append(b, symbol[j])
301 b = append(b, naq.minus[0])
305 for j := len(symbol) - 1; j >= 0; j-- {
306 b = append(b, symbol[j])
312 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
313 b[i], b[j] = b[j], b[i]
319 b = append(b, naq.decimal...)
322 for i := 0; i < 2-int(v); i++ {
330 // FmtDateShort returns the short date representation of 't' for 'naq'
331 func (naq *naq) FmtDateShort(t time.Time) string {
333 b := make([]byte, 0, 32)
339 b = strconv.AppendInt(b, int64(t.Day()), 10)
340 b = append(b, []byte{0x2f}...)
346 b = strconv.AppendInt(b, int64(t.Month()), 10)
348 b = append(b, []byte{0x2f}...)
351 b = strconv.AppendInt(b, int64(t.Year()), 10)
353 b = strconv.AppendInt(b, int64(-t.Year()), 10)
359 // FmtDateMedium returns the medium date representation of 't' for 'naq'
360 func (naq *naq) FmtDateMedium(t time.Time) string {
362 b := make([]byte, 0, 32)
364 b = strconv.AppendInt(b, int64(t.Day()), 10)
365 b = append(b, []byte{0x20}...)
366 b = append(b, naq.monthsAbbreviated[t.Month()]...)
367 b = append(b, []byte{0x20}...)
370 b = strconv.AppendInt(b, int64(t.Year()), 10)
372 b = strconv.AppendInt(b, int64(-t.Year()), 10)
378 // FmtDateLong returns the long date representation of 't' for 'naq'
379 func (naq *naq) FmtDateLong(t time.Time) string {
381 b := make([]byte, 0, 32)
383 b = strconv.AppendInt(b, int64(t.Day()), 10)
384 b = append(b, []byte{0x20}...)
385 b = append(b, naq.monthsWide[t.Month()]...)
386 b = append(b, []byte{0x20}...)
389 b = strconv.AppendInt(b, int64(t.Year()), 10)
391 b = strconv.AppendInt(b, int64(-t.Year()), 10)
397 // FmtDateFull returns the full date representation of 't' for 'naq'
398 func (naq *naq) FmtDateFull(t time.Time) string {
400 b := make([]byte, 0, 32)
402 b = append(b, naq.daysWide[t.Weekday()]...)
403 b = append(b, []byte{0x2c, 0x20}...)
404 b = strconv.AppendInt(b, int64(t.Day()), 10)
405 b = append(b, []byte{0x20}...)
406 b = append(b, naq.monthsWide[t.Month()]...)
407 b = append(b, []byte{0x20}...)
410 b = strconv.AppendInt(b, int64(t.Year()), 10)
412 b = strconv.AppendInt(b, int64(-t.Year()), 10)
418 // FmtTimeShort returns the short time representation of 't' for 'naq'
419 func (naq *naq) FmtTimeShort(t time.Time) string {
421 b := make([]byte, 0, 32)
429 b = strconv.AppendInt(b, int64(h), 10)
430 b = append(b, naq.timeSeparator...)
436 b = strconv.AppendInt(b, int64(t.Minute()), 10)
437 b = append(b, []byte{0x20}...)
440 b = append(b, naq.periodsAbbreviated[0]...)
442 b = append(b, naq.periodsAbbreviated[1]...)
448 // FmtTimeMedium returns the medium time representation of 't' for 'naq'
449 func (naq *naq) FmtTimeMedium(t time.Time) string {
451 b := make([]byte, 0, 32)
459 b = strconv.AppendInt(b, int64(h), 10)
460 b = append(b, naq.timeSeparator...)
466 b = strconv.AppendInt(b, int64(t.Minute()), 10)
467 b = append(b, naq.timeSeparator...)
473 b = strconv.AppendInt(b, int64(t.Second()), 10)
474 b = append(b, []byte{0x20}...)
477 b = append(b, naq.periodsAbbreviated[0]...)
479 b = append(b, naq.periodsAbbreviated[1]...)
485 // FmtTimeLong returns the long time representation of 't' for 'naq'
486 func (naq *naq) FmtTimeLong(t time.Time) string {
488 b := make([]byte, 0, 32)
496 b = strconv.AppendInt(b, int64(h), 10)
497 b = append(b, naq.timeSeparator...)
503 b = strconv.AppendInt(b, int64(t.Minute()), 10)
504 b = append(b, naq.timeSeparator...)
510 b = strconv.AppendInt(b, int64(t.Second()), 10)
511 b = append(b, []byte{0x20}...)
514 b = append(b, naq.periodsAbbreviated[0]...)
516 b = append(b, naq.periodsAbbreviated[1]...)
519 b = append(b, []byte{0x20}...)
527 // FmtTimeFull returns the full time representation of 't' for 'naq'
528 func (naq *naq) FmtTimeFull(t time.Time) string {
530 b := make([]byte, 0, 32)
538 b = strconv.AppendInt(b, int64(h), 10)
539 b = append(b, naq.timeSeparator...)
545 b = strconv.AppendInt(b, int64(t.Minute()), 10)
546 b = append(b, naq.timeSeparator...)
552 b = strconv.AppendInt(b, int64(t.Second()), 10)
553 b = append(b, []byte{0x20}...)
556 b = append(b, naq.periodsAbbreviated[0]...)
558 b = append(b, naq.periodsAbbreviated[1]...)
561 b = append(b, []byte{0x20}...)
565 if btz, ok := naq.timezones[tz]; ok {
566 b = append(b, btz...)