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 'ps_AF' 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{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"},
62 monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
63 monthsWide: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"},
64 daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"},
65 daysShort: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"},
66 daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"},
67 periodsAbbreviated: []string{"غ.م.", "غ.و."},
68 periodsNarrow: []string{"غ.م.", "غ.و."},
69 periodsWide: []string{"غ.م.", "غ.و."},
70 erasAbbreviated: []string{"له میلاد وړاندې", "م."},
71 erasNarrow: []string{"", ""},
72 erasWide: []string{"له میلاد څخه وړاندې", "له میلاد څخه وروسته"},
73 timezones: map[string]string{"MEZ": "MEZ", "HADT": "HADT", "LHDT": "LHDT", "HEEG": "HEEG", "VET": "VET", "CLST": "CLST", "WESZ": "د لودیځې اورپا د اوړي وخت", "MDT": "MDT", "UYT": "UYT", "NZST": "NZST", "HNNOMX": "HNNOMX", "OEZ": "OEZ", "PST": "PST", "BOT": "BOT", "NZDT": "NZDT", "HNOG": "HNOG", "AKST": "AKST", "ACDT": "ACDT", "HNPMX": "HNPMX", "CAT": "CAT", "WEZ": "د لودیځې اروپا معیاري وخت", "CDT": "CDT", "∅∅∅": "∅∅∅", "WIT": "WIT", "WITA": "WITA", "OESZ": "OESZ", "AWDT": "AWDT", "AST": "AST", "WAT": "WAT", "HNT": "HNT", "HEPM": "HEPM", "CST": "CST", "LHST": "LHST", "HEOG": "HEOG", "EDT": "EDT", "AKDT": "AKDT", "CLT": "CLT", "ECT": "ECT", "ACWST": "ACWST", "ACWDT": "ACWDT", "MYT": "MYT", "WARST": "WARST", "WAST": "WAST", "BT": "BT", "EST": "EST", "PDT": "PDT", "CHAST": "CHAST", "CHADT": "CHADT", "HNPM": "HNPM", "COT": "COT", "GFT": "GFT", "MESZ": "MESZ", "TMT": "TMT", "HENOMX": "HENOMX", "JST": "JST", "ARST": "ARST", "SRT": "SRT", "AEDT": "AEDT", "HNEG": "HNEG", "HAT": "HAT", "WIB": "WIB", "HAST": "HAST", "IST": "IST", "ART": "ART", "GYT": "GYT", "TMST": "TMST", "JDT": "JDT", "HKT": "HKT", "HKST": "HKST", "HECU": "HECU", "ADT": "ADT", "AEST": "AEST", "COST": "COST", "SGT": "SGT", "UYST": "UYST", "SAST": "SAST", "MST": "MST", "ACST": "ACST", "GMT": "گرينويچ وخت", "HEPMX": "HEPMX", "AWST": "AWST", "WART": "WART", "EAT": "EAT", "ChST": "ChST", "HNCU": "HNCU"},
77 // Locale returns the current translators string locale
78 func (ps *ps_AF) Locale() string {
82 // PluralsCardinal returns the list of cardinal plural rules associated with 'ps_AF'
83 func (ps *ps_AF) PluralsCardinal() []locales.PluralRule {
84 return ps.pluralsCardinal
87 // PluralsOrdinal returns the list of ordinal plural rules associated with 'ps_AF'
88 func (ps *ps_AF) PluralsOrdinal() []locales.PluralRule {
89 return ps.pluralsOrdinal
92 // PluralsRange returns the list of range plural rules associated with 'ps_AF'
93 func (ps *ps_AF) PluralsRange() []locales.PluralRule {
94 return ps.pluralsRange
97 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ps_AF'
98 func (ps *ps_AF) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
103 return locales.PluralRuleOne
106 return locales.PluralRuleOther
109 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ps_AF'
110 func (ps *ps_AF) 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 'ps_AF'
115 func (ps *ps_AF) 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 (ps *ps_AF) MonthAbbreviated(month time.Month) string {
121 return ps.monthsAbbreviated[month]
124 // MonthsAbbreviated returns the locales abbreviated months
125 func (ps *ps_AF) MonthsAbbreviated() []string {
126 return ps.monthsAbbreviated[1:]
129 // MonthNarrow returns the locales narrow month given the 'month' provided
130 func (ps *ps_AF) MonthNarrow(month time.Month) string {
131 return ps.monthsNarrow[month]
134 // MonthsNarrow returns the locales narrow months
135 func (ps *ps_AF) MonthsNarrow() []string {
136 return ps.monthsNarrow[1:]
139 // MonthWide returns the locales wide month given the 'month' provided
140 func (ps *ps_AF) MonthWide(month time.Month) string {
141 return ps.monthsWide[month]
144 // MonthsWide returns the locales wide months
145 func (ps *ps_AF) MonthsWide() []string {
146 return ps.monthsWide[1:]
149 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
150 func (ps *ps_AF) WeekdayAbbreviated(weekday time.Weekday) string {
151 return ps.daysAbbreviated[weekday]
154 // WeekdaysAbbreviated returns the locales abbreviated weekdays
155 func (ps *ps_AF) WeekdaysAbbreviated() []string {
156 return ps.daysAbbreviated
159 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
160 func (ps *ps_AF) WeekdayNarrow(weekday time.Weekday) string {
161 return ps.daysNarrow[weekday]
164 // WeekdaysNarrow returns the locales narrow weekdays
165 func (ps *ps_AF) WeekdaysNarrow() []string {
169 // WeekdayShort returns the locales short weekday given the 'weekday' provided
170 func (ps *ps_AF) WeekdayShort(weekday time.Weekday) string {
171 return ps.daysShort[weekday]
174 // WeekdaysShort returns the locales short weekdays
175 func (ps *ps_AF) WeekdaysShort() []string {
179 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
180 func (ps *ps_AF) WeekdayWide(weekday time.Weekday) string {
181 return ps.daysWide[weekday]
184 // WeekdaysWide returns the locales wide weekdays
185 func (ps *ps_AF) WeekdaysWide() []string {
189 // Decimal returns the decimal point of number
190 func (ps *ps_AF) Decimal() string {
194 // Group returns the group of number
195 func (ps *ps_AF) Group() string {
199 // Group returns the minus sign of number
200 func (ps *ps_AF) Minus() string {
204 // FmtNumber returns 'num' with digits/precision of 'v' for 'ps_AF' and handles both Whole and Real numbers based on 'v'
205 func (ps *ps_AF) FmtNumber(num float64, v uint64) string {
207 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
208 l := len(s) + 9 + 2*len(s[:len(s)-int(v)-1])/3
211 b := make([]byte, 0, l)
213 for i := len(s) - 1; i >= 0; i-- {
216 for j := len(ps.decimal) - 1; j >= 0; j-- {
217 b = append(b, ps.decimal[j])
225 for j := len(ps.group) - 1; j >= 0; j-- {
226 b = append(b, ps.group[j])
238 for j := len(ps.minus) - 1; j >= 0; j-- {
239 b = append(b, ps.minus[j])
244 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
245 b[i], b[j] = b[j], b[i]
251 // FmtPercent returns 'num' with digits/precision of 'v' for 'ps_AF' and handles both Whole and Real numbers based on 'v'
252 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
253 func (ps *ps_AF) FmtPercent(num float64, v uint64) string {
254 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
256 b := make([]byte, 0, l)
258 for i := len(s) - 1; i >= 0; i-- {
261 for j := len(ps.decimal) - 1; j >= 0; j-- {
262 b = append(b, ps.decimal[j])
271 for j := len(ps.minus) - 1; j >= 0; j-- {
272 b = append(b, ps.minus[j])
277 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
278 b[i], b[j] = b[j], b[i]
281 b = append(b, ps.percent...)
286 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ps_AF'
287 func (ps *ps_AF) FmtCurrency(num float64, v uint64, currency currency.Type) string {
289 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
290 symbol := ps.currencies[currency]
291 l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3
294 b := make([]byte, 0, l)
296 for i := len(s) - 1; i >= 0; i-- {
299 for j := len(ps.decimal) - 1; j >= 0; j-- {
300 b = append(b, ps.decimal[j])
308 for j := len(ps.group) - 1; j >= 0; j-- {
309 b = append(b, ps.group[j])
321 for j := len(ps.minus) - 1; j >= 0; j-- {
322 b = append(b, ps.minus[j])
327 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
328 b[i], b[j] = b[j], b[i]
334 b = append(b, ps.decimal...)
337 for i := 0; i < 2-int(v); i++ {
342 b = append(b, ps.currencyPositiveSuffix...)
344 b = append(b, symbol...)
349 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ps_AF'
350 // in accounting notation.
351 func (ps *ps_AF) FmtAccounting(num float64, v uint64, currency currency.Type) string {
353 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
354 symbol := ps.currencies[currency]
355 l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3
358 b := make([]byte, 0, l)
360 for i := len(s) - 1; i >= 0; i-- {
363 for j := len(ps.decimal) - 1; j >= 0; j-- {
364 b = append(b, ps.decimal[j])
372 for j := len(ps.group) - 1; j >= 0; j-- {
373 b = append(b, ps.group[j])
386 for j := len(ps.minus) - 1; j >= 0; j-- {
387 b = append(b, ps.minus[j])
393 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
394 b[i], b[j] = b[j], b[i]
400 b = append(b, ps.decimal...)
403 for i := 0; i < 2-int(v); i++ {
409 b = append(b, ps.currencyNegativeSuffix...)
410 b = append(b, symbol...)
413 b = append(b, ps.currencyPositiveSuffix...)
414 b = append(b, symbol...)
420 // FmtDateShort returns the short date representation of 't' for 'ps_AF'
421 func (ps *ps_AF) FmtDateShort(t time.Time) string {
423 b := make([]byte, 0, 32)
426 b = strconv.AppendInt(b, int64(t.Year()), 10)
428 b = strconv.AppendInt(b, int64(-t.Year()), 10)
431 b = append(b, []byte{0x2f}...)
432 b = strconv.AppendInt(b, int64(t.Month()), 10)
433 b = append(b, []byte{0x2f}...)
434 b = strconv.AppendInt(b, int64(t.Day()), 10)
439 // FmtDateMedium returns the medium date representation of 't' for 'ps_AF'
440 func (ps *ps_AF) FmtDateMedium(t time.Time) string {
442 b := make([]byte, 0, 32)
445 b = strconv.AppendInt(b, int64(t.Year()), 10)
447 b = strconv.AppendInt(b, int64(-t.Year()), 10)
450 b = append(b, []byte{0x20}...)
451 b = append(b, ps.monthsAbbreviated[t.Month()]...)
452 b = append(b, []byte{0x20}...)
453 b = strconv.AppendInt(b, int64(t.Day()), 10)
458 // FmtDateLong returns the long date representation of 't' for 'ps_AF'
459 func (ps *ps_AF) FmtDateLong(t time.Time) string {
461 b := make([]byte, 0, 32)
463 b = append(b, []byte{0xd8, 0xaf, 0x20}...)
466 b = strconv.AppendInt(b, int64(t.Year()), 10)
468 b = strconv.AppendInt(b, int64(-t.Year()), 10)
471 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
472 b = append(b, ps.monthsWide[t.Month()]...)
473 b = append(b, []byte{0x20}...)
474 b = strconv.AppendInt(b, int64(t.Day()), 10)
479 // FmtDateFull returns the full date representation of 't' for 'ps_AF'
480 func (ps *ps_AF) FmtDateFull(t time.Time) string {
482 b := make([]byte, 0, 32)
484 b = append(b, ps.daysWide[t.Weekday()]...)
485 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
488 b = strconv.AppendInt(b, int64(t.Year()), 10)
490 b = strconv.AppendInt(b, int64(-t.Year()), 10)
493 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
494 b = append(b, ps.monthsWide[t.Month()]...)
495 b = append(b, []byte{0x20}...)
496 b = strconv.AppendInt(b, int64(t.Day()), 10)
501 // FmtTimeShort returns the short time representation of 't' for 'ps_AF'
502 func (ps *ps_AF) FmtTimeShort(t time.Time) string {
504 b := make([]byte, 0, 32)
506 b = strconv.AppendInt(b, int64(t.Hour()), 10)
507 b = append(b, ps.timeSeparator...)
513 b = strconv.AppendInt(b, int64(t.Minute()), 10)
518 // FmtTimeMedium returns the medium time representation of 't' for 'ps_AF'
519 func (ps *ps_AF) FmtTimeMedium(t time.Time) string {
521 b := make([]byte, 0, 32)
523 b = strconv.AppendInt(b, int64(t.Hour()), 10)
524 b = append(b, ps.timeSeparator...)
530 b = strconv.AppendInt(b, int64(t.Minute()), 10)
531 b = append(b, ps.timeSeparator...)
537 b = strconv.AppendInt(b, int64(t.Second()), 10)
542 // FmtTimeLong returns the long time representation of 't' for 'ps_AF'
543 func (ps *ps_AF) FmtTimeLong(t time.Time) string {
545 b := make([]byte, 0, 32)
547 b = strconv.AppendInt(b, int64(t.Hour()), 10)
548 b = append(b, ps.timeSeparator...)
554 b = strconv.AppendInt(b, int64(t.Minute()), 10)
555 b = append(b, ps.timeSeparator...)
561 b = strconv.AppendInt(b, int64(t.Second()), 10)
562 b = append(b, []byte{0x20, 0x28}...)
567 b = append(b, []byte{0x29}...)
572 // FmtTimeFull returns the full time representation of 't' for 'ps_AF'
573 func (ps *ps_AF) FmtTimeFull(t time.Time) string {
575 b := make([]byte, 0, 32)
577 b = strconv.AppendInt(b, int64(t.Hour()), 10)
578 b = append(b, ps.timeSeparator...)
584 b = strconv.AppendInt(b, int64(t.Minute()), 10)
585 b = append(b, ps.timeSeparator...)
591 b = strconv.AppendInt(b, int64(t.Second()), 10)
592 b = append(b, []byte{0x20, 0x28}...)
596 if btz, ok := ps.timezones[tz]; ok {
597 b = append(b, btz...)
602 b = append(b, []byte{0x29}...)