1 package ps_AF
2
3 import (
4 "math"
5 "strconv"
6 "time"
7
8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
10 )
11
12 type ps_AF struct {
13 locale string
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
17 decimal string
18 group string
19 minus string
20 percent string
21 perMille string
22 timeSeparator string
23 inifinity string
24 currencies []string
25 currencyPositiveSuffix string
26 currencyNegativeSuffix string
27 monthsAbbreviated []string
28 monthsNarrow []string
29 monthsWide []string
30 daysAbbreviated []string
31 daysNarrow []string
32 daysShort []string
33 daysWide []string
34 periodsAbbreviated []string
35 periodsNarrow []string
36 periodsShort []string
37 periodsWide []string
38 erasAbbreviated []string
39 erasNarrow []string
40 erasWide []string
41 timezones map[string]string
42 }
43
44
45 func New() locales.Translator {
46 return &ps_AF{
47 locale: "ps_AF",
48 pluralsCardinal: []locales.PluralRule{2, 6},
49 pluralsOrdinal: []locales.PluralRule{6},
50 pluralsRange: []locales.PluralRule{2, 6},
51 percent: "٪",
52 perMille: "؉",
53 timeSeparator: ":",
54 inifinity: "∞",
55 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", "CNH", "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", "MRU", "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", "STN", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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"},
56 currencyPositiveSuffix: " ",
57 currencyNegativeSuffix: " ",
58 monthsAbbreviated: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سېپتمبر", "اکتوبر", "نومبر", "دسمبر"},
59 monthsNarrow: []string{"", "ج", "ف", "م", "ا", "م", "ج", "ج", "ا", "س", "ا", "ن", "د"},
60 monthsWide: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سېپتمبر", "اکتوبر", "نومبر", "دسمبر"},
61 daysAbbreviated: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"},
62 daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
63 daysShort: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"},
64 daysWide: []string{"يونۍ", "دونۍ", "درېنۍ", "څلرنۍ", "پينځنۍ", "جمعه", "اونۍ"},
65 periodsAbbreviated: []string{"غ.م.", "غ.و."},
66 periodsNarrow: []string{"غ.م.", "غ.و."},
67 periodsWide: []string{"غ.م.", "غ.و."},
68 erasAbbreviated: []string{"له میلاد وړاندې", "م."},
69 erasNarrow: []string{"", ""},
70 erasWide: []string{"له میلاد څخه وړاندې", "له میلاد څخه وروسته"},
71 timezones: map[string]string{"ACDT": "آسترالوي مرکزي د ورځې روښانه وخت", "ACST": "آسترالوي مرکزي معياري وخت", "ACWDT": "آسترالوي مرکزي لوېديځ د ورځې روښانه وخت", "ACWST": "آسترالوي مرکزي لوېديځ معياري وخت", "ADT": "اتلانتیک د رڼا ورځې وخت", "AEDT": "آسترالوي ختيځ د ورځې روښانه وخت", "AEST": "آسترالوي ختيځ معياري وخت", "AKDT": "الاسکا د ورځې روښانه وخت", "AKST": "الاسکا معياري وخت", "ARST": "ارجنټاین اوړي وخت", "ART": "ارجنټاین معیاری وخت", "AST": "اتلانتیک معياري وخت", "AWDT": "آسترالوي لوېديځ د ورځې روښانه وخت", "AWST": "آسترالوي لوېديځ معياري وخت", "BOT": "بولیویا وخت", "BT": "بهوټان وخت", "CAT": "منځنی افريقا وخت", "CDT": "مرکزي د ورځې روښانه وخت", "CHADT": "چاتام د ورځې روښانه وخت", "CHAST": "چاتام معياري وخت", "CLST": "چلی اوړي وخت", "CLT": "چلی معیاری وخت", "COST": "کولمبیا اوړي وخت", "COT": "کولمبیا معیاری وخت", "CST": "مرکزي معياري وخت", "ChST": "چمارو معياري وخت", "EAT": "ختيځ افريقا وخت", "ECT": "د اکوادور وخت", "EDT": "ختيځ د رڼا ورځې وخت", "EST": "ختيځ معياري وخت", "GFT": "د فرانسوي ګانا وخت", "GMT": "ګرينويچ معياري وخت", "GST": "خلیج معياري وخت", "GYT": "د ګوانانا وخت", "HADT": "هوایی الیوتین رڼا ورځې وخت", "HAST": "هوایی الیوتین معیاری وخت", "HAT": "نيو فاونډلېنډ د ورځې روښانه وخت", "HECU": "کیوبا د رڼا ورځې وخت", "HEEG": "د ختیځ ګرینلینډ اوړي وخت", "HENOMX": "د شمال لویدیځ مکسیکو رڼا ورځې وخت", "HEOG": "لویدیځ ګرینلینډ اوړي وخت", "HEPM": "سینټ پییرا و ميکلين رڼا ورځې وخت", "HEPMX": "مکسیکن پیسفک رڼا ورځې وخت", "HKST": "هانګ کانګ اوړي وخت", "HKT": "هانګ کانګ معياري وخت", "HNCU": "کیوبا معياري وخت", "HNEG": "د ختیځ ګرینلینډ معياري وخت", "HNNOMX": "د شمال لویدیځ مکسیکو معیاري وخت", "HNOG": "لویدیځ ګرینلینډ معياري وخت", "HNPM": "سینټ پییرا و ميکلين معیاری وخت", "HNPMX": "مکسیکن پیسفک معیاری وخت", "HNT": "د نوي فیلډلینډ معیاری وخت", "IST": "هند معیاري وخت", "JDT": "جاپان د ورځې روښانه وخت", "JST": "جاپان معياري وخت", "LHDT": "لارډ هوي د ورځې روښانه وخت", "LHST": "لارډ هوي معياري وخت", "MDT": "د غره د رڼا ورځې وخت", "MESZ": "وسطي اروپايي د اوړي وخت", "MEZ": "د مرکزي اروپا معیاري وخت", "MST": "د غره معياري وخت", "MYT": "ملائیشیا وخت", "NZDT": "نيوزي لېنډ د ورځې روښانه وخت", "NZST": "نيوزي لېنډ معياري وخت", "OESZ": "ختيځ اروپايي اوړي وخت", "OEZ": "ختيځ اروپايي معياري وخت", "PDT": "پیسفک د رڼا ورځې وخت", "PST": "د پیسفک معياري وخت", "SAST": "جنوبي افريقا معياري وخت", "SGT": "سنګاپور معیاري وخت", "SRT": "سورینام وخت", "TMST": "ترکمنستان اوړي وخت", "TMT": "ترکمنستان معياري وخت", "UYST": "یوروګوای اوړي وخت", "UYT": "یوروګوای معياري وخت", "VET": "وینزویلا وخت", "WARST": "لوېديځ ارجنټاين اوړي وخت", "WART": "لوېديځ ارجنټاين معياري وخت", "WAST": "د افریقا افریقا لویدیځ وخت", "WAT": "لویدیځ افریقایي معیاري وخت", "WESZ": "لوېديځ اروپايي اوړي وخت", "WEZ": "لوېديځ اروپايي معياري وخت", "WIB": "لویدیځ اندونیزیا وخت", "WIT": "اندونیزیا وخت", "WITA": "مرکزي ادونيزيا وخت", "∅∅∅": "برسلیا اوړي وخت"},
72 }
73 }
74
75
76 func (ps *ps_AF) Locale() string {
77 return ps.locale
78 }
79
80
81 func (ps *ps_AF) PluralsCardinal() []locales.PluralRule {
82 return ps.pluralsCardinal
83 }
84
85
86 func (ps *ps_AF) PluralsOrdinal() []locales.PluralRule {
87 return ps.pluralsOrdinal
88 }
89
90
91 func (ps *ps_AF) PluralsRange() []locales.PluralRule {
92 return ps.pluralsRange
93 }
94
95
96 func (ps *ps_AF) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
97
98 n := math.Abs(num)
99
100 if n == 1 {
101 return locales.PluralRuleOne
102 }
103
104 return locales.PluralRuleOther
105 }
106
107
108 func (ps *ps_AF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
109 return locales.PluralRuleOther
110 }
111
112
113 func (ps *ps_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
114
115 start := ps.CardinalPluralRule(num1, v1)
116 end := ps.CardinalPluralRule(num2, v2)
117
118 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
119 return locales.PluralRuleOne
120 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
121 return locales.PluralRuleOther
122 }
123
124 return locales.PluralRuleOther
125
126 }
127
128
129 func (ps *ps_AF) MonthAbbreviated(month time.Month) string {
130 return ps.monthsAbbreviated[month]
131 }
132
133
134 func (ps *ps_AF) MonthsAbbreviated() []string {
135 return ps.monthsAbbreviated[1:]
136 }
137
138
139 func (ps *ps_AF) MonthNarrow(month time.Month) string {
140 return ps.monthsNarrow[month]
141 }
142
143
144 func (ps *ps_AF) MonthsNarrow() []string {
145 return ps.monthsNarrow[1:]
146 }
147
148
149 func (ps *ps_AF) MonthWide(month time.Month) string {
150 return ps.monthsWide[month]
151 }
152
153
154 func (ps *ps_AF) MonthsWide() []string {
155 return ps.monthsWide[1:]
156 }
157
158
159 func (ps *ps_AF) WeekdayAbbreviated(weekday time.Weekday) string {
160 return ps.daysAbbreviated[weekday]
161 }
162
163
164 func (ps *ps_AF) WeekdaysAbbreviated() []string {
165 return ps.daysAbbreviated
166 }
167
168
169 func (ps *ps_AF) WeekdayNarrow(weekday time.Weekday) string {
170 return ps.daysNarrow[weekday]
171 }
172
173
174 func (ps *ps_AF) WeekdaysNarrow() []string {
175 return ps.daysNarrow
176 }
177
178
179 func (ps *ps_AF) WeekdayShort(weekday time.Weekday) string {
180 return ps.daysShort[weekday]
181 }
182
183
184 func (ps *ps_AF) WeekdaysShort() []string {
185 return ps.daysShort
186 }
187
188
189 func (ps *ps_AF) WeekdayWide(weekday time.Weekday) string {
190 return ps.daysWide[weekday]
191 }
192
193
194 func (ps *ps_AF) WeekdaysWide() []string {
195 return ps.daysWide
196 }
197
198
199 func (ps *ps_AF) Decimal() string {
200 return ps.decimal
201 }
202
203
204 func (ps *ps_AF) Group() string {
205 return ps.group
206 }
207
208
209 func (ps *ps_AF) Minus() string {
210 return ps.minus
211 }
212
213
214 func (ps *ps_AF) FmtNumber(num float64, v uint64) string {
215
216 return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
217 }
218
219
220
221 func (ps *ps_AF) FmtPercent(num float64, v uint64) string {
222 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
223 l := len(s) + 2
224 b := make([]byte, 0, l)
225
226 for i := len(s) - 1; i >= 0; i-- {
227
228 if s[i] == '.' {
229 b = append(b, ps.decimal[0])
230 continue
231 }
232
233 b = append(b, s[i])
234 }
235
236 if num < 0 {
237 b = append(b, ps.minus[0])
238 }
239
240
241 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
242 b[i], b[j] = b[j], b[i]
243 }
244
245 b = append(b, ps.percent...)
246
247 return string(b)
248 }
249
250
251 func (ps *ps_AF) FmtCurrency(num float64, v uint64, currency currency.Type) string {
252
253 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
254 symbol := ps.currencies[currency]
255 l := len(s) + len(symbol) + 2
256 count := 0
257 inWhole := v == 0
258 b := make([]byte, 0, l)
259
260 for i := len(s) - 1; i >= 0; i-- {
261
262 if s[i] == '.' {
263 b = append(b, ps.decimal[0])
264 inWhole = true
265 continue
266 }
267
268 if inWhole {
269 if count == 3 {
270 b = append(b, ps.group[0])
271 count = 1
272 } else {
273 count++
274 }
275 }
276
277 b = append(b, s[i])
278 }
279
280 if num < 0 {
281 b = append(b, ps.minus[0])
282 }
283
284
285 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
286 b[i], b[j] = b[j], b[i]
287 }
288
289 if int(v) < 2 {
290
291 if v == 0 {
292 b = append(b, ps.decimal...)
293 }
294
295 for i := 0; i < 2-int(v); i++ {
296 b = append(b, '0')
297 }
298 }
299
300 b = append(b, ps.currencyPositiveSuffix...)
301
302 b = append(b, symbol...)
303
304 return string(b)
305 }
306
307
308
309 func (ps *ps_AF) FmtAccounting(num float64, v uint64, currency currency.Type) string {
310
311 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
312 symbol := ps.currencies[currency]
313 l := len(s) + len(symbol) + 2
314 count := 0
315 inWhole := v == 0
316 b := make([]byte, 0, l)
317
318 for i := len(s) - 1; i >= 0; i-- {
319
320 if s[i] == '.' {
321 b = append(b, ps.decimal[0])
322 inWhole = true
323 continue
324 }
325
326 if inWhole {
327 if count == 3 {
328 b = append(b, ps.group[0])
329 count = 1
330 } else {
331 count++
332 }
333 }
334
335 b = append(b, s[i])
336 }
337
338 if num < 0 {
339
340 b = append(b, ps.minus[0])
341
342 }
343
344
345 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
346 b[i], b[j] = b[j], b[i]
347 }
348
349 if int(v) < 2 {
350
351 if v == 0 {
352 b = append(b, ps.decimal...)
353 }
354
355 for i := 0; i < 2-int(v); i++ {
356 b = append(b, '0')
357 }
358 }
359
360 if num < 0 {
361 b = append(b, ps.currencyNegativeSuffix...)
362 b = append(b, symbol...)
363 } else {
364
365 b = append(b, ps.currencyPositiveSuffix...)
366 b = append(b, symbol...)
367 }
368
369 return string(b)
370 }
371
372
373 func (ps *ps_AF) FmtDateShort(t time.Time) string {
374
375 b := make([]byte, 0, 32)
376
377 if t.Year() > 0 {
378 b = strconv.AppendInt(b, int64(t.Year()), 10)
379 } else {
380 b = strconv.AppendInt(b, int64(-t.Year()), 10)
381 }
382
383 b = append(b, []byte{0x2f}...)
384 b = strconv.AppendInt(b, int64(t.Month()), 10)
385 b = append(b, []byte{0x2f}...)
386 b = strconv.AppendInt(b, int64(t.Day()), 10)
387
388 return string(b)
389 }
390
391
392 func (ps *ps_AF) FmtDateMedium(t time.Time) string {
393
394 b := make([]byte, 0, 32)
395
396 if t.Year() > 0 {
397 b = strconv.AppendInt(b, int64(t.Year()), 10)
398 } else {
399 b = strconv.AppendInt(b, int64(-t.Year()), 10)
400 }
401
402 b = append(b, []byte{0x20}...)
403 b = append(b, ps.monthsAbbreviated[t.Month()]...)
404 b = append(b, []byte{0x20}...)
405 b = strconv.AppendInt(b, int64(t.Day()), 10)
406
407 return string(b)
408 }
409
410
411 func (ps *ps_AF) FmtDateLong(t time.Time) string {
412
413 b := make([]byte, 0, 32)
414
415 b = append(b, []byte{0xd8, 0xaf, 0x20}...)
416
417 if t.Year() > 0 {
418 b = strconv.AppendInt(b, int64(t.Year()), 10)
419 } else {
420 b = strconv.AppendInt(b, int64(-t.Year()), 10)
421 }
422
423 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
424 b = append(b, ps.monthsWide[t.Month()]...)
425 b = append(b, []byte{0x20}...)
426 b = strconv.AppendInt(b, int64(t.Day()), 10)
427
428 return string(b)
429 }
430
431
432 func (ps *ps_AF) FmtDateFull(t time.Time) string {
433
434 b := make([]byte, 0, 32)
435
436 b = append(b, ps.daysWide[t.Weekday()]...)
437 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
438
439 if t.Year() > 0 {
440 b = strconv.AppendInt(b, int64(t.Year()), 10)
441 } else {
442 b = strconv.AppendInt(b, int64(-t.Year()), 10)
443 }
444
445 b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...)
446 b = append(b, ps.monthsWide[t.Month()]...)
447 b = append(b, []byte{0x20}...)
448 b = strconv.AppendInt(b, int64(t.Day()), 10)
449
450 return string(b)
451 }
452
453
454 func (ps *ps_AF) FmtTimeShort(t time.Time) string {
455
456 b := make([]byte, 0, 32)
457
458 b = strconv.AppendInt(b, int64(t.Hour()), 10)
459 b = append(b, ps.timeSeparator...)
460
461 if t.Minute() < 10 {
462 b = append(b, '0')
463 }
464
465 b = strconv.AppendInt(b, int64(t.Minute()), 10)
466
467 return string(b)
468 }
469
470
471 func (ps *ps_AF) FmtTimeMedium(t time.Time) string {
472
473 b := make([]byte, 0, 32)
474
475 b = strconv.AppendInt(b, int64(t.Hour()), 10)
476 b = append(b, ps.timeSeparator...)
477
478 if t.Minute() < 10 {
479 b = append(b, '0')
480 }
481
482 b = strconv.AppendInt(b, int64(t.Minute()), 10)
483 b = append(b, ps.timeSeparator...)
484
485 if t.Second() < 10 {
486 b = append(b, '0')
487 }
488
489 b = strconv.AppendInt(b, int64(t.Second()), 10)
490
491 return string(b)
492 }
493
494
495 func (ps *ps_AF) FmtTimeLong(t time.Time) string {
496
497 b := make([]byte, 0, 32)
498
499 b = strconv.AppendInt(b, int64(t.Hour()), 10)
500 b = append(b, ps.timeSeparator...)
501
502 if t.Minute() < 10 {
503 b = append(b, '0')
504 }
505
506 b = strconv.AppendInt(b, int64(t.Minute()), 10)
507 b = append(b, ps.timeSeparator...)
508
509 if t.Second() < 10 {
510 b = append(b, '0')
511 }
512
513 b = strconv.AppendInt(b, int64(t.Second()), 10)
514 b = append(b, []byte{0x20, 0x28}...)
515
516 tz, _ := t.Zone()
517 b = append(b, tz...)
518
519 b = append(b, []byte{0x29}...)
520
521 return string(b)
522 }
523
524
525 func (ps *ps_AF) FmtTimeFull(t time.Time) string {
526
527 b := make([]byte, 0, 32)
528
529 b = strconv.AppendInt(b, int64(t.Hour()), 10)
530 b = append(b, ps.timeSeparator...)
531
532 if t.Minute() < 10 {
533 b = append(b, '0')
534 }
535
536 b = strconv.AppendInt(b, int64(t.Minute()), 10)
537 b = append(b, ps.timeSeparator...)
538
539 if t.Second() < 10 {
540 b = append(b, '0')
541 }
542
543 b = strconv.AppendInt(b, int64(t.Second()), 10)
544 b = append(b, []byte{0x20, 0x28}...)
545
546 tz, _ := t.Zone()
547
548 if btz, ok := ps.timezones[tz]; ok {
549 b = append(b, btz...)
550 } else {
551 b = append(b, tz...)
552 }
553
554 b = append(b, []byte{0x29}...)
555
556 return string(b)
557 }
558
View as plain text