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 currencyPositiveSuffix string
27 currencyNegativePrefix string
28 currencyNegativeSuffix string
29 monthsAbbreviated []string
32 daysAbbreviated []string
36 periodsAbbreviated []string
37 periodsNarrow []string
40 erasAbbreviated []string
43 timezones map[string]string
46 // New returns a new instance of translator for the 'lag_TZ' locale
47 func New() locales.Translator {
50 pluralsCardinal: []locales.PluralRule{1, 2, 6},
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 currencyPositivePrefix: " ",
56 currencyPositiveSuffix: "K",
57 currencyNegativePrefix: " ",
58 currencyNegativeSuffix: "K",
59 monthsAbbreviated: []string{"", "Fúngatɨ", "Naanɨ", "Keenda", "Ikúmi", "Inyambala", "Idwaata", "Mʉʉnchɨ", "Vɨɨrɨ", "Saatʉ", "Inyi", "Saano", "Sasatʉ"},
60 monthsNarrow: []string{"", "F", "N", "K", "I", "I", "I", "M", "V", "S", "I", "S", "S"},
61 monthsWide: []string{"", "Kʉfúngatɨ", "Kʉnaanɨ", "Kʉkeenda", "Kwiikumi", "Kwiinyambála", "Kwiidwaata", "Kʉmʉʉnchɨ", "Kʉvɨɨrɨ", "Kʉsaatʉ", "Kwiinyi", "Kʉsaano", "Kʉsasatʉ"},
62 daysAbbreviated: []string{"Píili", "Táatu", "Íne", "Táano", "Alh", "Ijm", "Móosi"},
63 daysNarrow: []string{"P", "T", "E", "O", "A", "I", "M"},
64 daysWide: []string{"Jumapíiri", "Jumatátu", "Jumaíne", "Jumatáano", "Alamíisi", "Ijumáa", "Jumamóosi"},
65 periodsAbbreviated: []string{"TOO", "MUU"},
66 periodsWide: []string{"TOO", "MUU"},
67 erasAbbreviated: []string{"KSA", "KA"},
68 erasNarrow: []string{"", ""},
69 erasWide: []string{"Kɨrɨsitʉ sɨ anavyaal", "Kɨrɨsitʉ akavyaalwe"},
70 timezones: map[string]string{"LHST": "LHST", "IST": "IST", "HNPMX": "HNPMX", "HNPM": "HNPM", "SRT": "SRT", "ACWDT": "ACWDT", "WIT": "WIT", "MESZ": "MESZ", "WEZ": "WEZ", "CHAST": "CHAST", "WITA": "WITA", "HAT": "HAT", "HKT": "HKT", "ECT": "ECT", "CST": "CST", "HADT": "HADT", "HEEG": "HEEG", "EDT": "EDT", "AWST": "AWST", "COT": "COT", "JDT": "JDT", "WART": "WART", "AST": "AST", "HNEG": "HNEG", "ACST": "ACST", "CHADT": "CHADT", "HEPM": "HEPM", "UYT": "UYT", "EAT": "EAT", "HEPMX": "HEPMX", "HNT": "HNT", "SGT": "SGT", "VET": "VET", "ChST": "ChST", "PDT": "PDT", "MDT": "MDT", "MEZ": "MEZ", "HAST": "HAST", "OEZ": "OEZ", "ARST": "ARST", "CLT": "CLT", "GYT": "GYT", "HNCU": "HNCU", "CDT": "CDT", "AWDT": "AWDT", "ACWST": "ACWST", "HENOMX": "HENOMX", "SAST": "SAST", "WAT": "WAT", "CLST": "CLST", "PST": "PST", "MST": "MST", "JST": "JST", "ADT": "ADT", "HNOG": "HNOG", "AKDT": "AKDT", "CAT": "CAT", "WIB": "WIB", "HECU": "HECU", "BOT": "BOT", "NZST": "NZST", "AEDT": "AEDT", "EST": "EST", "LHDT": "LHDT", "COST": "COST", "WESZ": "WESZ", "HEOG": "HEOG", "WAST": "WAST", "HKST": "HKST", "BT": "BT", "UYST": "UYST", "TMT": "TMT", "HNNOMX": "HNNOMX", "ART": "ART", "ACDT": "ACDT", "GMT": "GMT", "∅∅∅": "∅∅∅", "MYT": "MYT", "OESZ": "OESZ", "GFT": "GFT", "NZDT": "NZDT", "TMST": "TMST", "WARST": "WARST", "AEST": "AEST", "AKST": "AKST"},
74 // Locale returns the current translators string locale
75 func (lag *lag_TZ) Locale() string {
79 // PluralsCardinal returns the list of cardinal plural rules associated with 'lag_TZ'
80 func (lag *lag_TZ) PluralsCardinal() []locales.PluralRule {
81 return lag.pluralsCardinal
84 // PluralsOrdinal returns the list of ordinal plural rules associated with 'lag_TZ'
85 func (lag *lag_TZ) PluralsOrdinal() []locales.PluralRule {
86 return lag.pluralsOrdinal
89 // PluralsRange returns the list of range plural rules associated with 'lag_TZ'
90 func (lag *lag_TZ) PluralsRange() []locales.PluralRule {
91 return lag.pluralsRange
94 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lag_TZ'
95 func (lag *lag_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
101 return locales.PluralRuleZero
102 } else if (i == 0 || i == 1) && n != 0 {
103 return locales.PluralRuleOne
106 return locales.PluralRuleOther
109 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lag_TZ'
110 func (lag *lag_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
111 return locales.PluralRuleUnknown
114 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lag_TZ'
115 func (lag *lag_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
116 return locales.PluralRuleUnknown
119 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
120 func (lag *lag_TZ) MonthAbbreviated(month time.Month) string {
121 return lag.monthsAbbreviated[month]
124 // MonthsAbbreviated returns the locales abbreviated months
125 func (lag *lag_TZ) MonthsAbbreviated() []string {
126 return lag.monthsAbbreviated[1:]
129 // MonthNarrow returns the locales narrow month given the 'month' provided
130 func (lag *lag_TZ) MonthNarrow(month time.Month) string {
131 return lag.monthsNarrow[month]
134 // MonthsNarrow returns the locales narrow months
135 func (lag *lag_TZ) MonthsNarrow() []string {
136 return lag.monthsNarrow[1:]
139 // MonthWide returns the locales wide month given the 'month' provided
140 func (lag *lag_TZ) MonthWide(month time.Month) string {
141 return lag.monthsWide[month]
144 // MonthsWide returns the locales wide months
145 func (lag *lag_TZ) MonthsWide() []string {
146 return lag.monthsWide[1:]
149 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
150 func (lag *lag_TZ) WeekdayAbbreviated(weekday time.Weekday) string {
151 return lag.daysAbbreviated[weekday]
154 // WeekdaysAbbreviated returns the locales abbreviated weekdays
155 func (lag *lag_TZ) WeekdaysAbbreviated() []string {
156 return lag.daysAbbreviated
159 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
160 func (lag *lag_TZ) WeekdayNarrow(weekday time.Weekday) string {
161 return lag.daysNarrow[weekday]
164 // WeekdaysNarrow returns the locales narrow weekdays
165 func (lag *lag_TZ) WeekdaysNarrow() []string {
166 return lag.daysNarrow
169 // WeekdayShort returns the locales short weekday given the 'weekday' provided
170 func (lag *lag_TZ) WeekdayShort(weekday time.Weekday) string {
171 return lag.daysShort[weekday]
174 // WeekdaysShort returns the locales short weekdays
175 func (lag *lag_TZ) WeekdaysShort() []string {
179 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
180 func (lag *lag_TZ) WeekdayWide(weekday time.Weekday) string {
181 return lag.daysWide[weekday]
184 // WeekdaysWide returns the locales wide weekdays
185 func (lag *lag_TZ) WeekdaysWide() []string {
189 // Decimal returns the decimal point of number
190 func (lag *lag_TZ) Decimal() string {
194 // Group returns the group of number
195 func (lag *lag_TZ) Group() string {
199 // Group returns the minus sign of number
200 func (lag *lag_TZ) Minus() string {
204 // FmtNumber returns 'num' with digits/precision of 'v' for 'lag_TZ' and handles both Whole and Real numbers based on 'v'
205 func (lag *lag_TZ) FmtNumber(num float64, v uint64) string {
207 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
210 // FmtPercent returns 'num' with digits/precision of 'v' for 'lag_TZ' and handles both Whole and Real numbers based on 'v'
211 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
212 func (lag *lag_TZ) FmtPercent(num float64, v uint64) string {
213 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
216 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lag_TZ'
217 func (lag *lag_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string {
219 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
220 symbol := lag.currencies[currency]
221 l := len(s) + len(symbol) + 3
223 b := make([]byte, 0, l)
225 for i := len(s) - 1; i >= 0; i-- {
228 b = append(b, lag.decimal[0])
235 for j := len(symbol) - 1; j >= 0; j-- {
236 b = append(b, symbol[j])
239 for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- {
240 b = append(b, lag.currencyPositivePrefix[j])
244 b = append(b, lag.minus[0])
248 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
249 b[i], b[j] = b[j], b[i]
252 b = append(b, lag.currencyPositiveSuffix...)
257 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lag_TZ'
258 // in accounting notation.
259 func (lag *lag_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string {
261 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
262 symbol := lag.currencies[currency]
263 l := len(s) + len(symbol) + 3
265 b := make([]byte, 0, l)
267 for i := len(s) - 1; i >= 0; i-- {
270 b = append(b, lag.decimal[0])
279 for j := len(symbol) - 1; j >= 0; j-- {
280 b = append(b, symbol[j])
283 for j := len(lag.currencyNegativePrefix) - 1; j >= 0; j-- {
284 b = append(b, lag.currencyNegativePrefix[j])
287 b = append(b, lag.minus[0])
291 for j := len(symbol) - 1; j >= 0; j-- {
292 b = append(b, symbol[j])
295 for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- {
296 b = append(b, lag.currencyPositivePrefix[j])
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]
307 b = append(b, lag.currencyNegativeSuffix...)
310 b = append(b, lag.currencyPositiveSuffix...)
316 // FmtDateShort returns the short date representation of 't' for 'lag_TZ'
317 func (lag *lag_TZ) 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 'lag_TZ'
346 func (lag *lag_TZ) 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, lag.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 'lag_TZ'
365 func (lag *lag_TZ) 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, lag.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 'lag_TZ'
384 func (lag *lag_TZ) FmtDateFull(t time.Time) string {
386 b := make([]byte, 0, 32)
388 b = append(b, lag.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, lag.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 'lag_TZ'
405 func (lag *lag_TZ) FmtTimeShort(t time.Time) string {
407 b := make([]byte, 0, 32)
413 b = strconv.AppendInt(b, int64(t.Hour()), 10)
414 b = append(b, lag.timeSeparator...)
420 b = strconv.AppendInt(b, int64(t.Minute()), 10)
425 // FmtTimeMedium returns the medium time representation of 't' for 'lag_TZ'
426 func (lag *lag_TZ) FmtTimeMedium(t time.Time) string {
428 b := make([]byte, 0, 32)
434 b = strconv.AppendInt(b, int64(t.Hour()), 10)
435 b = append(b, lag.timeSeparator...)
441 b = strconv.AppendInt(b, int64(t.Minute()), 10)
442 b = append(b, lag.timeSeparator...)
448 b = strconv.AppendInt(b, int64(t.Second()), 10)
453 // FmtTimeLong returns the long time representation of 't' for 'lag_TZ'
454 func (lag *lag_TZ) FmtTimeLong(t time.Time) string {
456 b := make([]byte, 0, 32)
462 b = strconv.AppendInt(b, int64(t.Hour()), 10)
463 b = append(b, lag.timeSeparator...)
469 b = strconv.AppendInt(b, int64(t.Minute()), 10)
470 b = append(b, lag.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 'lag_TZ'
486 func (lag *lag_TZ) FmtTimeFull(t time.Time) string {
488 b := make([]byte, 0, 32)
494 b = strconv.AppendInt(b, int64(t.Hour()), 10)
495 b = append(b, lag.timeSeparator...)
501 b = strconv.AppendInt(b, int64(t.Minute()), 10)
502 b = append(b, lag.timeSeparator...)
508 b = strconv.AppendInt(b, int64(t.Second()), 10)
509 b = append(b, []byte{0x20}...)
513 if btz, ok := lag.timezones[tz]; ok {
514 b = append(b, btz...)