ff.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. package ff
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ff struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal []byte
  15. group []byte
  16. minus []byte
  17. percent []byte
  18. perMille []byte
  19. timeSeparator []byte
  20. inifinity []byte
  21. currencies [][]byte // idx = enum of currency code
  22. currencyPositiveSuffix []byte
  23. currencyNegativeSuffix []byte
  24. monthsAbbreviated [][]byte
  25. monthsNarrow [][]byte
  26. monthsWide [][]byte
  27. daysAbbreviated [][]byte
  28. daysNarrow [][]byte
  29. daysShort [][]byte
  30. daysWide [][]byte
  31. periodsAbbreviated [][]byte
  32. periodsNarrow [][]byte
  33. periodsShort [][]byte
  34. periodsWide [][]byte
  35. erasAbbreviated [][]byte
  36. erasNarrow [][]byte
  37. erasWide [][]byte
  38. timezones map[string][]byte
  39. }
  40. // New returns a new instance of translator for the 'ff' locale
  41. func New() locales.Translator {
  42. return &ff{
  43. locale: "ff",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: []byte{0x2c},
  48. group: []byte{0xc2, 0xa0},
  49. minus: []byte{},
  50. percent: []byte{},
  51. perMille: []byte{},
  52. timeSeparator: []byte{0x3a},
  53. currencies: [][]uint8{{0x41, 0x44, 0x50, 0x20}, {0x41, 0x45, 0x44, 0x20}, {0x41, 0x46, 0x41, 0x20}, {0x41, 0x46, 0x4e, 0x20}, {0x41, 0x4c, 0x4b, 0x20}, {0x41, 0x4c, 0x4c, 0x20}, {0x41, 0x4d, 0x44, 0x20}, {0x41, 0x4e, 0x47, 0x20}, {0x41, 0x4f, 0x41, 0x20}, {0x41, 0x4f, 0x4b, 0x20}, {0x41, 0x4f, 0x4e, 0x20}, {0x41, 0x4f, 0x52, 0x20}, {0x41, 0x52, 0x41, 0x20}, {0x41, 0x52, 0x4c, 0x20}, {0x41, 0x52, 0x4d, 0x20}, {0x41, 0x52, 0x50, 0x20}, {0x41, 0x52, 0x53, 0x20}, {0x41, 0x54, 0x53, 0x20}, {0x41, 0x55, 0x44, 0x20}, {0x41, 0x57, 0x47, 0x20}, {0x41, 0x5a, 0x4d, 0x20}, {0x41, 0x5a, 0x4e, 0x20}, {0x42, 0x41, 0x44, 0x20}, {0x42, 0x41, 0x4d, 0x20}, {0x42, 0x41, 0x4e, 0x20}, {0x42, 0x42, 0x44, 0x20}, {0x42, 0x44, 0x54, 0x20}, {0x42, 0x45, 0x43, 0x20}, {0x42, 0x45, 0x46, 0x20}, {0x42, 0x45, 0x4c, 0x20}, {0x42, 0x47, 0x4c, 0x20}, {0x42, 0x47, 0x4d, 0x20}, {0x42, 0x47, 0x4e, 0x20}, {0x42, 0x47, 0x4f, 0x20}, {0x42, 0x48, 0x44, 0x20}, {0x42, 0x49, 0x46, 0x20}, {0x42, 0x4d, 0x44, 0x20}, {0x42, 0x4e, 0x44, 0x20}, {0x42, 0x4f, 0x42, 0x20}, {0x42, 0x4f, 0x4c, 0x20}, {0x42, 0x4f, 0x50, 0x20}, {0x42, 0x4f, 0x56, 0x20}, {0x42, 0x52, 0x42, 0x20}, {0x42, 0x52, 0x43, 0x20}, {0x42, 0x52, 0x45, 0x20}, {0x42, 0x52, 0x4c, 0x20}, {0x42, 0x52, 0x4e, 0x20}, {0x42, 0x52, 0x52, 0x20}, {0x42, 0x52, 0x5a, 0x20}, {0x42, 0x53, 0x44, 0x20}, {0x42, 0x54, 0x4e, 0x20}, {0x42, 0x55, 0x4b, 0x20}, {0x42, 0x57, 0x50, 0x20}, {0x42, 0x59, 0x42, 0x20}, {0x42, 0x59, 0x52, 0x20}, {0x42, 0x5a, 0x44, 0x20}, {0x43, 0x41, 0x44, 0x20}, {0x43, 0x44, 0x46, 0x20}, {0x43, 0x48, 0x45, 0x20}, {0x43, 0x48, 0x46, 0x20}, {0x43, 0x48, 0x57, 0x20}, {0x43, 0x4c, 0x45, 0x20}, {0x43, 0x4c, 0x46, 0x20}, {0x43, 0x4c, 0x50, 0x20}, {0x43, 0x4e, 0x58, 0x20}, {0x43, 0x4e, 0x59, 0x20}, {0x43, 0x4f, 0x50, 0x20}, {0x43, 0x4f, 0x55, 0x20}, {0x43, 0x52, 0x43, 0x20}, {0x43, 0x53, 0x44, 0x20}, {0x43, 0x53, 0x4b, 0x20}, {0x43, 0x55, 0x43, 0x20}, {0x43, 0x55, 0x50, 0x20}, {0x43, 0x56, 0x45, 0x20}, {0x43, 0x59, 0x50, 0x20}, {0x43, 0x5a, 0x4b, 0x20}, {0x44, 0x44, 0x4d, 0x20}, {0x44, 0x45, 0x4d, 0x20}, {0x44, 0x4a, 0x46, 0x20}, {0x44, 0x4b, 0x4b, 0x20}, {0x44, 0x4f, 0x50, 0x20}, {0x44, 0x5a, 0x44, 0x20}, {0x45, 0x43, 0x53, 0x20}, {0x45, 0x43, 0x56, 0x20}, {0x45, 0x45, 0x4b, 0x20}, {0x45, 0x47, 0x50, 0x20}, {0x45, 0x52, 0x4e, 0x20}, {0x45, 0x53, 0x41, 0x20}, {0x45, 0x53, 0x42, 0x20}, {0x45, 0x53, 0x50, 0x20}, {0x45, 0x54, 0x42, 0x20}, {0x45, 0x55, 0x52, 0x20}, {0x46, 0x49, 0x4d, 0x20}, {0x46, 0x4a, 0x44, 0x20}, {0x46, 0x4b, 0x50, 0x20}, {0x46, 0x52, 0x46, 0x20}, {0x47, 0x42, 0x50, 0x20}, {0x47, 0x45, 0x4b, 0x20}, {0x47, 0x45, 0x4c, 0x20}, {0x47, 0x48, 0x43, 0x20}, {0x47, 0x48, 0x53, 0x20}, {0x47, 0x49, 0x50, 0x20}, {0x47, 0x4d, 0x44, 0x20}, {0x47, 0x4e, 0x46, 0x20}, {0x47, 0x4e, 0x53, 0x20}, {0x47, 0x51, 0x45, 0x20}, {0x47, 0x52, 0x44, 0x20}, {0x47, 0x54, 0x51, 0x20}, {0x47, 0x57, 0x45, 0x20}, {0x47, 0x57, 0x50, 0x20}, {0x47, 0x59, 0x44, 0x20}, {0x48, 0x4b, 0x44, 0x20}, {0x48, 0x4e, 0x4c, 0x20}, {0x48, 0x52, 0x44, 0x20}, {0x48, 0x52, 0x4b, 0x20}, {0x48, 0x54, 0x47, 0x20}, {0x48, 0x55, 0x46, 0x20}, {0x49, 0x44, 0x52, 0x20}, {0x49, 0x45, 0x50, 0x20}, {0x49, 0x4c, 0x50, 0x20}, {0x49, 0x4c, 0x52, 0x20}, {0x49, 0x4c, 0x53, 0x20}, {0x49, 0x4e, 0x52, 0x20}, {0x49, 0x51, 0x44, 0x20}, {0x49, 0x52, 0x52, 0x20}, {0x49, 0x53, 0x4a, 0x20}, {0x49, 0x53, 0x4b, 0x20}, {0x49, 0x54, 0x4c, 0x20}, {0x4a, 0x4d, 0x44, 0x20}, {0x4a, 0x4f, 0x44, 0x20}, {0x4a, 0x50, 0x59, 0x20}, {0x4b, 0x45, 0x53, 0x20}, {0x4b, 0x47, 0x53, 0x20}, {0x4b, 0x48, 0x52, 0x20}, {0x4b, 0x4d, 0x46, 0x20}, {0x4b, 0x50, 0x57, 0x20}, {0x4b, 0x52, 0x48, 0x20}, {0x4b, 0x52, 0x4f, 0x20}, {0x4b, 0x52, 0x57, 0x20}, {0x4b, 0x57, 0x44, 0x20}, {0x4b, 0x59, 0x44, 0x20}, {0x4b, 0x5a, 0x54, 0x20}, {0x4c, 0x41, 0x4b, 0x20}, {0x4c, 0x42, 0x50, 0x20}, {0x4c, 0x4b, 0x52, 0x20}, {0x4c, 0x52, 0x44, 0x20}, {0x4c, 0x53, 0x4c, 0x20}, {0x4c, 0x54, 0x4c, 0x20}, {0x4c, 0x54, 0x54, 0x20}, {0x4c, 0x55, 0x43, 0x20}, {0x4c, 0x55, 0x46, 0x20}, {0x4c, 0x55, 0x4c, 0x20}, {0x4c, 0x56, 0x4c, 0x20}, {0x4c, 0x56, 0x52, 0x20}, {0x4c, 0x59, 0x44, 0x20}, {0x4d, 0x41, 0x44, 0x20}, {0x4d, 0x41, 0x46, 0x20}, {0x4d, 0x43, 0x46, 0x20}, {0x4d, 0x44, 0x43, 0x20}, {0x4d, 0x44, 0x4c, 0x20}, {0x4d, 0x47, 0x41, 0x20}, {0x4d, 0x47, 0x46, 0x20}, {0x4d, 0x4b, 0x44, 0x20}, {0x4d, 0x4b, 0x4e, 0x20}, {0x4d, 0x4c, 0x46, 0x20}, {0x4d, 0x4d, 0x4b, 0x20}, {0x4d, 0x4e, 0x54, 0x20}, {0x4d, 0x4f, 0x50, 0x20}, {0x4d, 0x52, 0x4f, 0x20}, {0x4d, 0x54, 0x4c, 0x20}, {0x4d, 0x54, 0x50, 0x20}, {0x4d, 0x55, 0x52, 0x20}, {0x4d, 0x56, 0x50, 0x20}, {0x4d, 0x56, 0x52, 0x20}, {0x4d, 0x57, 0x4b, 0x20}, {0x4d, 0x58, 0x4e, 0x20}, {0x4d, 0x58, 0x50, 0x20}, {0x4d, 0x58, 0x56, 0x20}, {0x4d, 0x59, 0x52, 0x20}, {0x4d, 0x5a, 0x45, 0x20}, {0x4d, 0x5a, 0x4d, 0x20}, {0x4d, 0x5a, 0x4e, 0x20}, {0x4e, 0x41, 0x44, 0x20}, {0x4e, 0x47, 0x4e, 0x20}, {0x4e, 0x49, 0x43, 0x20}, {0x4e, 0x49, 0x4f, 0x20}, {0x4e, 0x4c, 0x47, 0x20}, {0x4e, 0x4f, 0x4b, 0x20}, {0x4e, 0x50, 0x52, 0x20}, {0x4e, 0x5a, 0x44, 0x20}, {0x4f, 0x4d, 0x52, 0x20}, {0x50, 0x41, 0x42, 0x20}, {0x50, 0x45, 0x49, 0x20}, {0x50, 0x45, 0x4e, 0x20}, {0x50, 0x45, 0x53, 0x20}, {0x50, 0x47, 0x4b, 0x20}, {0x50, 0x48, 0x50, 0x20}, {0x50, 0x4b, 0x52, 0x20}, {0x50, 0x4c, 0x4e, 0x20}, {0x50, 0x4c, 0x5a, 0x20}, {0x50, 0x54, 0x45, 0x20}, {0x50, 0x59, 0x47, 0x20}, {0x51, 0x41, 0x52, 0x20}, {0x52, 0x48, 0x44, 0x20}, {0x52, 0x4f, 0x4c, 0x20}, {0x52, 0x4f, 0x4e, 0x20}, {0x52, 0x53, 0x44, 0x20}, {0x52, 0x55, 0x42, 0x20}, {0x52, 0x55, 0x52, 0x20}, {0x52, 0x57, 0x46, 0x20}, {0x53, 0x41, 0x52, 0x20}, {0x53, 0x42, 0x44, 0x20}, {0x53, 0x43, 0x52, 0x20}, {0x53, 0x44, 0x44, 0x20}, {0x53, 0x44, 0x47, 0x20}, {0x53, 0x44, 0x50, 0x20}, {0x53, 0x45, 0x4b, 0x20}, {0x53, 0x47, 0x44, 0x20}, {0x53, 0x48, 0x50, 0x20}, {0x53, 0x49, 0x54, 0x20}, {0x53, 0x4b, 0x4b, 0x20}, {0x53, 0x4c, 0x4c, 0x20}, {0x53, 0x4f, 0x53, 0x20}, {0x53, 0x52, 0x44, 0x20}, {0x53, 0x52, 0x47, 0x20}, {0x53, 0x53, 0x50, 0x20}, {0x53, 0x54, 0x44, 0x20}, {0x53, 0x55, 0x52, 0x20}, {0x53, 0x56, 0x43, 0x20}, {0x53, 0x59, 0x50, 0x20}, {0x53, 0x5a, 0x4c, 0x20}, {0x54, 0x48, 0x42, 0x20}, {0x54, 0x4a, 0x52, 0x20}, {0x54, 0x4a, 0x53, 0x20}, {0x54, 0x4d, 0x4d, 0x20}, {0x54, 0x4d, 0x54, 0x20}, {0x54, 0x4e, 0x44, 0x20}, {0x54, 0x4f, 0x50, 0x20}, {0x54, 0x50, 0x45, 0x20}, {0x54, 0x52, 0x4c, 0x20}, {0x54, 0x52, 0x59, 0x20}, {0x54, 0x54, 0x44, 0x20}, {0x54, 0x57, 0x44, 0x20}, {0x54, 0x5a, 0x53, 0x20}, {0x55, 0x41, 0x48, 0x20}, {0x55, 0x41, 0x4b, 0x20}, {0x55, 0x47, 0x53, 0x20}, {0x55, 0x47, 0x58, 0x20}, {0x55, 0x53, 0x44, 0x20}, {0x55, 0x53, 0x4e, 0x20}, {0x55, 0x53, 0x53, 0x20}, {0x55, 0x59, 0x49, 0x20}, {0x55, 0x59, 0x50, 0x20}, {0x55, 0x59, 0x55, 0x20}, {0x55, 0x5a, 0x53, 0x20}, {0x56, 0x45, 0x42, 0x20}, {0x56, 0x45, 0x46, 0x20}, {0x56, 0x4e, 0x44, 0x20}, {0x56, 0x4e, 0x4e, 0x20}, {0x56, 0x55, 0x56, 0x20}, {0x57, 0x53, 0x54, 0x20}, {0x58, 0x41, 0x46, 0x20}, {0x58, 0x41, 0x47, 0x20}, {0x58, 0x41, 0x55, 0x20}, {0x58, 0x42, 0x41, 0x20}, {0x58, 0x42, 0x42, 0x20}, {0x58, 0x42, 0x43, 0x20}, {0x58, 0x42, 0x44, 0x20}, {0x58, 0x43, 0x44, 0x20}, {0x58, 0x44, 0x52, 0x20}, {0x58, 0x45, 0x55, 0x20}, {0x58, 0x46, 0x4f, 0x20}, {0x58, 0x46, 0x55, 0x20}, {0x58, 0x4f, 0x46, 0x20}, {0x58, 0x50, 0x44, 0x20}, {0x58, 0x50, 0x46, 0x20}, {0x58, 0x50, 0x54, 0x20}, {0x58, 0x52, 0x45, 0x20}, {0x58, 0x53, 0x55, 0x20}, {0x58, 0x54, 0x53, 0x20}, {0x58, 0x55, 0x41, 0x20}, {0x58, 0x58, 0x58, 0x20}, {0x59, 0x44, 0x44, 0x20}, {0x59, 0x45, 0x52, 0x20}, {0x59, 0x55, 0x44, 0x20}, {0x59, 0x55, 0x4d, 0x20}, {0x59, 0x55, 0x4e, 0x20}, {0x59, 0x55, 0x52, 0x20}, {0x5a, 0x41, 0x4c, 0x20}, {0x5a, 0x41, 0x52, 0x20}, {0x5a, 0x4d, 0x4b, 0x20}, {0x5a, 0x4d, 0x57, 0x20}, {0x5a, 0x52, 0x4e, 0x20}, {0x5a, 0x52, 0x5a, 0x20}, {0x5a, 0x57, 0x44, 0x20}, {0x5a, 0x57, 0x4c, 0x20}, {0x5a, 0x57, 0x52, 0x20}},
  54. currencyPositiveSuffix: []byte{0xc2, 0xa0},
  55. currencyNegativeSuffix: []byte{0xc2, 0xa0},
  56. monthsAbbreviated: [][]uint8{[]uint8(nil), {0x73, 0x69, 0x69}, {0x63, 0x6f, 0x6c}, {0x6d, 0x62, 0x6f}, {0x73, 0x65, 0x65}, {0x64, 0x75, 0x75}, {0x6b, 0x6f, 0x72}, {0x6d, 0x6f, 0x72}, {0x6a, 0x75, 0x6b}, {0x73, 0x6c, 0x74}, {0x79, 0x61, 0x72}, {0x6a, 0x6f, 0x6c}, {0x62, 0x6f, 0x77}},
  57. monthsNarrow: [][]uint8{[]uint8(nil), {0x73}, {0x63}, {0x6d}, {0x73}, {0x64}, {0x6b}, {0x6d}, {0x6a}, {0x73}, {0x79}, {0x6a}, {0x62}},
  58. monthsWide: [][]uint8{[]uint8(nil), {0x73, 0x69, 0x69, 0x6c, 0x6f}, {0x63, 0x6f, 0x6c, 0x74, 0x65}, {0x6d, 0x62, 0x6f, 0x6f, 0x79}, {0x73, 0x65, 0x65, 0xc9, 0x97, 0x74, 0x6f}, {0x64, 0x75, 0x75, 0x6a, 0x61, 0x6c}, {0x6b, 0x6f, 0x72, 0x73, 0x65}, {0x6d, 0x6f, 0x72, 0x73, 0x6f}, {0x6a, 0x75, 0x6b, 0x6f}, {0x73, 0x69, 0x69, 0x6c, 0x74, 0x6f}, {0x79, 0x61, 0x72, 0x6b, 0x6f, 0x6d, 0x61, 0x61}, {0x6a, 0x6f, 0x6c, 0x61, 0x6c}, {0x62, 0x6f, 0x77, 0x74, 0x65}},
  59. daysAbbreviated: [][]uint8{{0x64, 0x65, 0x77}, {0x61, 0x61, 0xc9, 0x93}, {0x6d, 0x61, 0x77}, {0x6e, 0x6a, 0x65}, {0x6e, 0x61, 0x61}, {0x6d, 0x77, 0x64}, {0x68, 0x62, 0x69}},
  60. daysNarrow: [][]uint8{{0x64}, {0x61}, {0x6d}, {0x6e}, {0x6e}, {0x6d}, {0x68}},
  61. daysWide: [][]uint8{{0x64, 0x65, 0x77, 0x6f}, {0x61, 0x61, 0xc9, 0x93, 0x6e, 0x64, 0x65}, {0x6d, 0x61, 0x77, 0x62, 0x61, 0x61, 0x72, 0x65}, {0x6e, 0x6a, 0x65, 0x73, 0x6c, 0x61, 0x61, 0x72, 0x65}, {0x6e, 0x61, 0x61, 0x73, 0x61, 0x61, 0x6e, 0x64, 0x65}, {0x6d, 0x61, 0x77, 0x6e, 0x64, 0x65}, {0x68, 0x6f, 0x6f, 0x72, 0x65, 0x2d, 0x62, 0x69, 0x69, 0x72}},
  62. periodsAbbreviated: [][]uint8{{0x73, 0x75, 0x62, 0x61, 0x6b, 0x61}, {0x6b, 0x69, 0x6b, 0x69, 0x69, 0xc9, 0x97, 0x65}},
  63. periodsWide: [][]uint8{{0x73, 0x75, 0x62, 0x61, 0x6b, 0x61}, {0x6b, 0x69, 0x6b, 0x69, 0x69, 0xc9, 0x97, 0x65}},
  64. erasAbbreviated: [][]uint8{{0x48, 0x2d, 0x49}, {0x43, 0x2d, 0x49}},
  65. erasNarrow: [][]uint8{[]uint8(nil), []uint8(nil)},
  66. erasWide: [][]uint8{{0x48, 0x61, 0x64, 0x65, 0x20, 0x49, 0x69, 0x73, 0x61}, {0x43, 0x61, 0x67, 0x67, 0x61, 0x6c, 0x20, 0x49, 0x69, 0x73, 0x61}},
  67. timezones: map[string][]uint8{"COT": {0x43, 0x4f, 0x54}, "CHADT": {0x43, 0x48, 0x41, 0x44, 0x54}, "CLST": {0x43, 0x4c, 0x53, 0x54}, "IST": {0x49, 0x53, 0x54}, "AST": {0x41, 0x53, 0x54}, "ACDT": {0x41, 0x43, 0x44, 0x54}, "TMST": {0x54, 0x4d, 0x53, 0x54}, "CDT": {0x43, 0x44, 0x54}, "MEZ": {0x4d, 0x45, 0x5a}, "ARST": {0x41, 0x52, 0x53, 0x54}, "ADT": {0x41, 0x44, 0x54}, "LHDT": {0x4c, 0x48, 0x44, 0x54}, "SRT": {0x53, 0x52, 0x54}, "EAT": {0x45, 0x41, 0x54}, "JST": {0x4a, 0x53, 0x54}, "GFT": {0x47, 0x46, 0x54}, "COST": {0x43, 0x4f, 0x53, 0x54}, "AEDT": {0x41, 0x45, 0x44, 0x54}, "WIB": {0x57, 0x49, 0x42}, "OESZ": {0x4f, 0x45, 0x53, 0x5a}, "EST": {0x45, 0x53, 0x54}, "HAT": {0x48, 0x41, 0x54}, "HKST": {0x48, 0x4b, 0x53, 0x54}, "GYT": {0x47, 0x59, 0x54}, "BT": {0x42, 0x54}, "WITA": {0x57, 0x49, 0x54, 0x41}, "HADT": {0x48, 0x41, 0x44, 0x54}, "MST": {0x4d, 0x53, 0x54}, "GMT": {0x47, 0x4d, 0x54}, "UYST": {0x55, 0x59, 0x53, 0x54}, "WEZ": {0x57, 0x45, 0x5a}, "WESZ": {0x57, 0x45, 0x53, 0x5a}, "PDT": {0x50, 0x44, 0x54}, "UYT": {0x55, 0x59, 0x54}, "WIT": {0x57, 0x49, 0x54}, "HAST": {0x48, 0x41, 0x53, 0x54}, "PST": {0x50, 0x53, 0x54}, "AEST": {0x41, 0x45, 0x53, 0x54}, "MDT": {0x4d, 0x44, 0x54}, "OEZ": {0x4f, 0x45, 0x5a}, "CLT": {0x43, 0x4c, 0x54}, "AKST": {0x41, 0x4b, 0x53, 0x54}, "NZST": {0x4e, 0x5a, 0x53, 0x54}, "∅∅∅": {0xe2, 0x88, 0x85, 0xe2, 0x88, 0x85, 0xe2, 0x88, 0x85}, "ACST": {0x41, 0x43, 0x53, 0x54}, "ChST": {0x43, 0x68, 0x53, 0x54}, "ACWST": {0x41, 0x43, 0x57, 0x53, 0x54}, "MESZ": {0x4d, 0x45, 0x53, 0x5a}, "AWST": {0x41, 0x57, 0x53, 0x54}, "CHAST": {0x43, 0x48, 0x41, 0x53, 0x54}, "HNT": {0x48, 0x4e, 0x54}, "WARST": {0x57, 0x41, 0x52, 0x53, 0x54}, "LHST": {0x4c, 0x48, 0x53, 0x54}, "CST": {0x43, 0x53, 0x54}, "SAST": {0x53, 0x41, 0x53, 0x54}, "BOT": {0x42, 0x4f, 0x54}, "ACWDT": {0x41, 0x43, 0x57, 0x44, 0x54}, "HKT": {0x48, 0x4b, 0x54}, "AWDT": {0x41, 0x57, 0x44, 0x54}, "CAT": {0x43, 0x41, 0x54}, "AKDT": {0x41, 0x4b, 0x44, 0x54}, "EDT": {0x45, 0x44, 0x54}, "NZDT": {0x4e, 0x5a, 0x44, 0x54}, "VET": {0x56, 0x45, 0x54}, "WAST": {0x57, 0x41, 0x53, 0x54}, "SGT": {0x53, 0x47, 0x54}, "ART": {0x41, 0x52, 0x54}, "JDT": {0x4a, 0x44, 0x54}, "WART": {0x57, 0x41, 0x52, 0x54}, "ECT": {0x45, 0x43, 0x54}, "TMT": {0x54, 0x4d, 0x54}, "MYT": {0x4d, 0x59, 0x54}, "WAT": {0x57, 0x41, 0x54}},
  68. }
  69. }
  70. // Locale returns the current translators string locale
  71. func (ff *ff) Locale() string {
  72. return ff.locale
  73. }
  74. // PluralsCardinal returns the list of cardinal plural rules associated with 'ff'
  75. func (ff *ff) PluralsCardinal() []locales.PluralRule {
  76. return ff.pluralsCardinal
  77. }
  78. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ff'
  79. func (ff *ff) PluralsOrdinal() []locales.PluralRule {
  80. return ff.pluralsOrdinal
  81. }
  82. // PluralsRange returns the list of range plural rules associated with 'ff'
  83. func (ff *ff) PluralsRange() []locales.PluralRule {
  84. return ff.pluralsRange
  85. }
  86. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff'
  87. func (ff *ff) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  88. n := math.Abs(num)
  89. i := int64(n)
  90. if i == 0 || i == 1 {
  91. return locales.PluralRuleOne
  92. }
  93. return locales.PluralRuleOther
  94. }
  95. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff'
  96. func (ff *ff) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  97. return locales.PluralRuleUnknown
  98. }
  99. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff'
  100. func (ff *ff) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  101. return locales.PluralRuleUnknown
  102. }
  103. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  104. func (ff *ff) MonthAbbreviated(month time.Month) []byte {
  105. return ff.monthsAbbreviated[month]
  106. }
  107. // MonthsAbbreviated returns the locales abbreviated months
  108. func (ff *ff) MonthsAbbreviated() [][]byte {
  109. return ff.monthsAbbreviated[1:]
  110. }
  111. // MonthNarrow returns the locales narrow month given the 'month' provided
  112. func (ff *ff) MonthNarrow(month time.Month) []byte {
  113. return ff.monthsNarrow[month]
  114. }
  115. // MonthsNarrow returns the locales narrow months
  116. func (ff *ff) MonthsNarrow() [][]byte {
  117. return ff.monthsNarrow[1:]
  118. }
  119. // MonthWide returns the locales wide month given the 'month' provided
  120. func (ff *ff) MonthWide(month time.Month) []byte {
  121. return ff.monthsWide[month]
  122. }
  123. // MonthsWide returns the locales wide months
  124. func (ff *ff) MonthsWide() [][]byte {
  125. return ff.monthsWide[1:]
  126. }
  127. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  128. func (ff *ff) WeekdayAbbreviated(weekday time.Weekday) []byte {
  129. return ff.daysAbbreviated[weekday]
  130. }
  131. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  132. func (ff *ff) WeekdaysAbbreviated() [][]byte {
  133. return ff.daysAbbreviated
  134. }
  135. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  136. func (ff *ff) WeekdayNarrow(weekday time.Weekday) []byte {
  137. return ff.daysNarrow[weekday]
  138. }
  139. // WeekdaysNarrow returns the locales narrow weekdays
  140. func (ff *ff) WeekdaysNarrow() [][]byte {
  141. return ff.daysNarrow
  142. }
  143. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  144. func (ff *ff) WeekdayShort(weekday time.Weekday) []byte {
  145. return ff.daysShort[weekday]
  146. }
  147. // WeekdaysShort returns the locales short weekdays
  148. func (ff *ff) WeekdaysShort() [][]byte {
  149. return ff.daysShort
  150. }
  151. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  152. func (ff *ff) WeekdayWide(weekday time.Weekday) []byte {
  153. return ff.daysWide[weekday]
  154. }
  155. // WeekdaysWide returns the locales wide weekdays
  156. func (ff *ff) WeekdaysWide() [][]byte {
  157. return ff.daysWide
  158. }
  159. // FmtNumber returns 'num' with digits/precision of 'v' for 'ff' and handles both Whole and Real numbers based on 'v'
  160. // returned as a []byte just in case the caller wishes to add more and can help
  161. // avoid allocations; otherwise just cast as string.
  162. func (ff *ff) FmtNumber(num float64, v uint64) []byte {
  163. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  164. return []byte(s)
  165. }
  166. // FmtPercent returns 'num' with digits/precision of 'v' for 'ff' and handles both Whole and Real numbers based on 'v'
  167. // returned as a []byte just in case the caller wishes to add more and can help
  168. // avoid allocations; otherwise just cast as string.
  169. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  170. func (ff *ff) FmtPercent(num float64, v uint64) []byte {
  171. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  172. return []byte(s)
  173. }
  174. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff'
  175. // returned as a []byte just in case the caller wishes to add more and can help
  176. // avoid allocations; otherwise just cast as string.
  177. func (ff *ff) FmtCurrency(num float64, v uint64, currency currency.Type) []byte {
  178. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  179. symbol := ff.currencies[currency]
  180. l := len(s) + len(ff.decimal) + len(ff.group)*len(s[:len(s)-int(v)-1])/3
  181. count := 0
  182. inWhole := v == 0
  183. b := make([]byte, 0, l)
  184. for i := len(s) - 1; i >= 0; i-- {
  185. if s[i] == '.' {
  186. b = append(b, ff.decimal[0])
  187. inWhole = true
  188. continue
  189. }
  190. if inWhole {
  191. if count == 3 {
  192. for j := len(ff.group) - 1; j >= 0; j-- {
  193. b = append(b, ff.group[j])
  194. }
  195. count = 1
  196. } else {
  197. count++
  198. }
  199. }
  200. b = append(b, s[i])
  201. }
  202. if num < 0 {
  203. for j := len(ff.minus) - 1; j >= 0; j-- {
  204. b = append(b, ff.minus[j])
  205. }
  206. }
  207. // reverse
  208. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  209. b[i], b[j] = b[j], b[i]
  210. }
  211. if int(v) < 2 {
  212. if v == 0 {
  213. b = append(b, ff.decimal...)
  214. }
  215. for i := 0; i < 2-int(v); i++ {
  216. b = append(b, '0')
  217. }
  218. }
  219. b = append(b, ff.currencyPositiveSuffix...)
  220. b = append(b, symbol...)
  221. return b
  222. }
  223. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff'
  224. // in accounting notation. returned as a []byte just in case the caller wishes to add more and can help
  225. // avoid allocations; otherwise just cast as string.
  226. func (ff *ff) FmtAccounting(num float64, v uint64, currency currency.Type) []byte {
  227. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  228. symbol := ff.currencies[currency]
  229. l := len(s) + len(ff.decimal) + len(ff.group)*len(s[:len(s)-int(v)-1])/3
  230. count := 0
  231. inWhole := v == 0
  232. b := make([]byte, 0, l)
  233. for i := len(s) - 1; i >= 0; i-- {
  234. if s[i] == '.' {
  235. b = append(b, ff.decimal[0])
  236. inWhole = true
  237. continue
  238. }
  239. if inWhole {
  240. if count == 3 {
  241. for j := len(ff.group) - 1; j >= 0; j-- {
  242. b = append(b, ff.group[j])
  243. }
  244. count = 1
  245. } else {
  246. count++
  247. }
  248. }
  249. b = append(b, s[i])
  250. }
  251. if num < 0 {
  252. for j := len(ff.minus) - 1; j >= 0; j-- {
  253. b = append(b, ff.minus[j])
  254. }
  255. }
  256. // reverse
  257. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  258. b[i], b[j] = b[j], b[i]
  259. }
  260. if int(v) < 2 {
  261. if v == 0 {
  262. b = append(b, ff.decimal...)
  263. }
  264. for i := 0; i < 2-int(v); i++ {
  265. b = append(b, '0')
  266. }
  267. }
  268. if num < 0 {
  269. b = append(b, ff.currencyNegativeSuffix...)
  270. b = append(b, symbol...)
  271. } else {
  272. b = append(b, ff.currencyPositiveSuffix...)
  273. b = append(b, symbol...)
  274. }
  275. return b
  276. }
  277. // FmtDateShort returns the short date representation of 't' for 'ff'
  278. // returned as a []byte just in case the caller wishes to add more and can help
  279. // avoid allocations; otherwise just cast as string.
  280. func (ff *ff) FmtDateShort(t time.Time) []byte {
  281. b := make([]byte, 0, 32)
  282. b = strconv.AppendInt(b, int64(t.Day()), 10)
  283. b = append(b, []byte{0x2f}...)
  284. b = strconv.AppendInt(b, int64(t.Month()), 10)
  285. b = append(b, []byte{0x2f}...)
  286. b = strconv.AppendInt(b, int64(t.Year()), 10)
  287. return b
  288. }
  289. // FmtDateMedium returns the medium date representation of 't' for 'ff'
  290. // returned as a []byte just in case the caller wishes to add more and can help
  291. // avoid allocations; otherwise just cast as string.
  292. func (ff *ff) FmtDateMedium(t time.Time) []byte {
  293. b := make([]byte, 0, 32)
  294. b = strconv.AppendInt(b, int64(t.Day()), 10)
  295. b = append(b, []byte{0x20}...)
  296. b = append(b, ff.monthsAbbreviated[t.Month()]...)
  297. b = append(b, []byte{0x2c, 0x20}...)
  298. b = strconv.AppendInt(b, int64(t.Year()), 10)
  299. return b
  300. }
  301. // FmtDateLong returns the long date representation of 't' for 'ff'
  302. // returned as a []byte just in case the caller wishes to add more and can help
  303. // avoid allocations; otherwise just cast as string.
  304. func (ff *ff) FmtDateLong(t time.Time) []byte {
  305. b := make([]byte, 0, 32)
  306. b = strconv.AppendInt(b, int64(t.Day()), 10)
  307. b = append(b, []byte{0x20}...)
  308. b = append(b, ff.monthsWide[t.Month()]...)
  309. b = append(b, []byte{0x20}...)
  310. b = strconv.AppendInt(b, int64(t.Year()), 10)
  311. return b
  312. }
  313. // FmtDateFull returns the full date representation of 't' for 'ff'
  314. // returned as a []byte just in case the caller wishes to add more and can help
  315. // avoid allocations; otherwise just cast as string.
  316. func (ff *ff) FmtDateFull(t time.Time) []byte {
  317. b := make([]byte, 0, 32)
  318. b = append(b, ff.daysWide[t.Weekday()]...)
  319. b = append(b, []byte{0x20}...)
  320. b = strconv.AppendInt(b, int64(t.Day()), 10)
  321. b = append(b, []byte{0x20}...)
  322. b = append(b, ff.monthsWide[t.Month()]...)
  323. b = append(b, []byte{0x20}...)
  324. b = strconv.AppendInt(b, int64(t.Year()), 10)
  325. return b
  326. }
  327. // FmtTimeShort returns the short time representation of 't' for 'ff'
  328. // returned as a []byte just in case the caller wishes to add more and can help
  329. // avoid allocations; otherwise just cast as string.
  330. func (ff *ff) FmtTimeShort(t time.Time) []byte {
  331. b := make([]byte, 0, 32)
  332. if t.Hour() < 10 {
  333. b = append(b, '0')
  334. }
  335. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  336. b = append(b, ff.timeSeparator...)
  337. if t.Minute() < 10 {
  338. b = append(b, '0')
  339. }
  340. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  341. return b
  342. }
  343. // FmtTimeMedium returns the medium time representation of 't' for 'ff'
  344. // returned as a []byte just in case the caller wishes to add more and can help
  345. // avoid allocations; otherwise just cast as string.
  346. func (ff *ff) FmtTimeMedium(t time.Time) []byte {
  347. b := make([]byte, 0, 32)
  348. if t.Hour() < 10 {
  349. b = append(b, '0')
  350. }
  351. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  352. b = append(b, ff.timeSeparator...)
  353. if t.Minute() < 10 {
  354. b = append(b, '0')
  355. }
  356. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  357. b = append(b, ff.timeSeparator...)
  358. if t.Second() < 10 {
  359. b = append(b, '0')
  360. }
  361. b = strconv.AppendInt(b, int64(t.Second()), 10)
  362. return b
  363. }
  364. // FmtTimeLong returns the long time representation of 't' for 'ff'
  365. // returned as a []byte just in case the caller wishes to add more and can help
  366. // avoid allocations; otherwise just cast as string.
  367. func (ff *ff) FmtTimeLong(t time.Time) []byte {
  368. b := make([]byte, 0, 32)
  369. if t.Hour() < 10 {
  370. b = append(b, '0')
  371. }
  372. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  373. b = append(b, ff.timeSeparator...)
  374. if t.Minute() < 10 {
  375. b = append(b, '0')
  376. }
  377. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  378. b = append(b, ff.timeSeparator...)
  379. if t.Second() < 10 {
  380. b = append(b, '0')
  381. }
  382. b = strconv.AppendInt(b, int64(t.Second()), 10)
  383. b = append(b, []byte{0x20}...)
  384. tz, _ := t.Zone()
  385. b = append(b, tz...)
  386. return b
  387. }
  388. // FmtTimeFull returns the full time representation of 't' for 'ff'
  389. // returned as a []byte just in case the caller wishes to add more and can help
  390. // avoid allocations; otherwise just cast as string.
  391. func (ff *ff) FmtTimeFull(t time.Time) []byte {
  392. b := make([]byte, 0, 32)
  393. if t.Hour() < 10 {
  394. b = append(b, '0')
  395. }
  396. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  397. b = append(b, ff.timeSeparator...)
  398. if t.Minute() < 10 {
  399. b = append(b, '0')
  400. }
  401. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  402. b = append(b, ff.timeSeparator...)
  403. if t.Second() < 10 {
  404. b = append(b, '0')
  405. }
  406. b = strconv.AppendInt(b, int64(t.Second()), 10)
  407. b = append(b, []byte{0x20}...)
  408. tz, _ := t.Zone()
  409. if btz, ok := ff.timezones[tz]; ok {
  410. b = append(b, btz...)
  411. } else {
  412. b = append(b, tz...)
  413. }
  414. return b
  415. }