ff_GN.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. package ff_GN
  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_GN struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyPositiveSuffix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'ff_GN' locale
  41. func New() locales.Translator {
  42. return &ff_GN{
  43. locale: "ff_GN",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: ",",
  48. group: " ",
  49. timeSeparator: ":",
  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 ", "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 ", "FG", "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 "},
  51. currencyPositiveSuffix: " ",
  52. currencyNegativeSuffix: " ",
  53. monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"},
  54. monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"},
  55. monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"},
  56. daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"},
  57. daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"},
  58. daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"},
  59. periodsAbbreviated: []string{"subaka", "kikiiɗe"},
  60. periodsWide: []string{"subaka", "kikiiɗe"},
  61. erasAbbreviated: []string{"H-I", "C-I"},
  62. erasNarrow: []string{"", ""},
  63. erasWide: []string{"Hade Iisa", "Caggal Iisa"},
  64. timezones: map[string]string{"CST": "CST", "CLT": "CLT", "ACWST": "ACWST", "GYT": "GYT", "CHADT": "CHADT", "CLST": "CLST", "TMT": "TMT", "ARST": "ARST", "AKDT": "AKDT", "AWST": "AWST", "AWDT": "AWDT", "ACWDT": "ACWDT", "ADT": "ADT", "BT": "BT", "LHST": "LHST", "COST": "COST", "ACST": "ACST", "BOT": "BOT", "WEZ": "WEZ", "EDT": "EDT", "WARST": "WARST", "MDT": "MDT", "WAST": "WAST", "COT": "COT", "ECT": "ECT", "AST": "AST", "∅∅∅": "∅∅∅", "UYST": "UYST", "WESZ": "WESZ", "AEST": "AEST", "ChST": "ChST", "SGT": "SGT", "IST": "IST", "OEZ": "OEZ", "JDT": "JDT", "PST": "PST", "NZDT": "NZDT", "CHAST": "CHAST", "AEDT": "AEDT", "HKST": "HKST", "OESZ": "OESZ", "HNT": "HNT", "AKST": "AKST", "NZST": "NZST", "VET": "VET", "CAT": "CAT", "EST": "EST", "ART": "ART", "PDT": "PDT", "LHDT": "LHDT", "MESZ": "MESZ", "WIB": "WIB", "ACDT": "ACDT", "JST": "JST", "WIT": "WIT", "EAT": "EAT", "MST": "MST", "MYT": "MYT", "SRT": "SRT", "WART": "WART", "HAST": "HAST", "HKT": "HKT", "GFT": "GFT", "WITA": "WITA", "TMST": "TMST", "WAT": "WAT", "HAT": "HAT", "CDT": "CDT", "MEZ": "MEZ", "UYT": "UYT", "HADT": "HADT", "SAST": "SAST", "GMT": "GMT"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (ff *ff_GN) Locale() string {
  69. return ff.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'ff_GN'
  72. func (ff *ff_GN) PluralsCardinal() []locales.PluralRule {
  73. return ff.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ff_GN'
  76. func (ff *ff_GN) PluralsOrdinal() []locales.PluralRule {
  77. return ff.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'ff_GN'
  80. func (ff *ff_GN) PluralsRange() []locales.PluralRule {
  81. return ff.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff_GN'
  84. func (ff *ff_GN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. n := math.Abs(num)
  86. i := int64(n)
  87. if i == 0 || i == 1 {
  88. return locales.PluralRuleOne
  89. }
  90. return locales.PluralRuleOther
  91. }
  92. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff_GN'
  93. func (ff *ff_GN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  94. return locales.PluralRuleUnknown
  95. }
  96. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff_GN'
  97. func (ff *ff_GN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  98. return locales.PluralRuleUnknown
  99. }
  100. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  101. func (ff *ff_GN) MonthAbbreviated(month time.Month) string {
  102. return ff.monthsAbbreviated[month]
  103. }
  104. // MonthsAbbreviated returns the locales abbreviated months
  105. func (ff *ff_GN) MonthsAbbreviated() []string {
  106. return ff.monthsAbbreviated[1:]
  107. }
  108. // MonthNarrow returns the locales narrow month given the 'month' provided
  109. func (ff *ff_GN) MonthNarrow(month time.Month) string {
  110. return ff.monthsNarrow[month]
  111. }
  112. // MonthsNarrow returns the locales narrow months
  113. func (ff *ff_GN) MonthsNarrow() []string {
  114. return ff.monthsNarrow[1:]
  115. }
  116. // MonthWide returns the locales wide month given the 'month' provided
  117. func (ff *ff_GN) MonthWide(month time.Month) string {
  118. return ff.monthsWide[month]
  119. }
  120. // MonthsWide returns the locales wide months
  121. func (ff *ff_GN) MonthsWide() []string {
  122. return ff.monthsWide[1:]
  123. }
  124. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  125. func (ff *ff_GN) WeekdayAbbreviated(weekday time.Weekday) string {
  126. return ff.daysAbbreviated[weekday]
  127. }
  128. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  129. func (ff *ff_GN) WeekdaysAbbreviated() []string {
  130. return ff.daysAbbreviated
  131. }
  132. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  133. func (ff *ff_GN) WeekdayNarrow(weekday time.Weekday) string {
  134. return ff.daysNarrow[weekday]
  135. }
  136. // WeekdaysNarrow returns the locales narrow weekdays
  137. func (ff *ff_GN) WeekdaysNarrow() []string {
  138. return ff.daysNarrow
  139. }
  140. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  141. func (ff *ff_GN) WeekdayShort(weekday time.Weekday) string {
  142. return ff.daysShort[weekday]
  143. }
  144. // WeekdaysShort returns the locales short weekdays
  145. func (ff *ff_GN) WeekdaysShort() []string {
  146. return ff.daysShort
  147. }
  148. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  149. func (ff *ff_GN) WeekdayWide(weekday time.Weekday) string {
  150. return ff.daysWide[weekday]
  151. }
  152. // WeekdaysWide returns the locales wide weekdays
  153. func (ff *ff_GN) WeekdaysWide() []string {
  154. return ff.daysWide
  155. }
  156. // FmtNumber returns 'num' with digits/precision of 'v' for 'ff_GN' and handles both Whole and Real numbers based on 'v'
  157. func (ff *ff_GN) FmtNumber(num float64, v uint64) string {
  158. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  159. }
  160. // FmtPercent returns 'num' with digits/precision of 'v' for 'ff_GN' and handles both Whole and Real numbers based on 'v'
  161. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  162. func (ff *ff_GN) FmtPercent(num float64, v uint64) string {
  163. return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  164. }
  165. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff_GN'
  166. func (ff *ff_GN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  167. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  168. symbol := ff.currencies[currency]
  169. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  170. count := 0
  171. inWhole := v == 0
  172. b := make([]byte, 0, l)
  173. for i := len(s) - 1; i >= 0; i-- {
  174. if s[i] == '.' {
  175. b = append(b, ff.decimal[0])
  176. inWhole = true
  177. continue
  178. }
  179. if inWhole {
  180. if count == 3 {
  181. for j := len(ff.group) - 1; j >= 0; j-- {
  182. b = append(b, ff.group[j])
  183. }
  184. count = 1
  185. } else {
  186. count++
  187. }
  188. }
  189. b = append(b, s[i])
  190. }
  191. if num < 0 {
  192. b = append(b, ff.minus[0])
  193. }
  194. // reverse
  195. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  196. b[i], b[j] = b[j], b[i]
  197. }
  198. if int(v) < 2 {
  199. if v == 0 {
  200. b = append(b, ff.decimal...)
  201. }
  202. for i := 0; i < 2-int(v); i++ {
  203. b = append(b, '0')
  204. }
  205. }
  206. b = append(b, ff.currencyPositiveSuffix...)
  207. b = append(b, symbol...)
  208. return string(b)
  209. }
  210. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff_GN'
  211. // in accounting notation.
  212. func (ff *ff_GN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  213. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  214. symbol := ff.currencies[currency]
  215. l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  216. count := 0
  217. inWhole := v == 0
  218. b := make([]byte, 0, l)
  219. for i := len(s) - 1; i >= 0; i-- {
  220. if s[i] == '.' {
  221. b = append(b, ff.decimal[0])
  222. inWhole = true
  223. continue
  224. }
  225. if inWhole {
  226. if count == 3 {
  227. for j := len(ff.group) - 1; j >= 0; j-- {
  228. b = append(b, ff.group[j])
  229. }
  230. count = 1
  231. } else {
  232. count++
  233. }
  234. }
  235. b = append(b, s[i])
  236. }
  237. if num < 0 {
  238. b = append(b, ff.minus[0])
  239. }
  240. // reverse
  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. if int(v) < 2 {
  245. if v == 0 {
  246. b = append(b, ff.decimal...)
  247. }
  248. for i := 0; i < 2-int(v); i++ {
  249. b = append(b, '0')
  250. }
  251. }
  252. if num < 0 {
  253. b = append(b, ff.currencyNegativeSuffix...)
  254. b = append(b, symbol...)
  255. } else {
  256. b = append(b, ff.currencyPositiveSuffix...)
  257. b = append(b, symbol...)
  258. }
  259. return string(b)
  260. }
  261. // FmtDateShort returns the short date representation of 't' for 'ff_GN'
  262. func (ff *ff_GN) FmtDateShort(t time.Time) string {
  263. b := make([]byte, 0, 32)
  264. b = strconv.AppendInt(b, int64(t.Day()), 10)
  265. b = append(b, []byte{0x2f}...)
  266. b = strconv.AppendInt(b, int64(t.Month()), 10)
  267. b = append(b, []byte{0x2f}...)
  268. b = strconv.AppendInt(b, int64(t.Year()), 10)
  269. return string(b)
  270. }
  271. // FmtDateMedium returns the medium date representation of 't' for 'ff_GN'
  272. func (ff *ff_GN) FmtDateMedium(t time.Time) string {
  273. b := make([]byte, 0, 32)
  274. b = strconv.AppendInt(b, int64(t.Day()), 10)
  275. b = append(b, []byte{0x20}...)
  276. b = append(b, ff.monthsAbbreviated[t.Month()]...)
  277. b = append(b, []byte{0x2c, 0x20}...)
  278. b = strconv.AppendInt(b, int64(t.Year()), 10)
  279. return string(b)
  280. }
  281. // FmtDateLong returns the long date representation of 't' for 'ff_GN'
  282. func (ff *ff_GN) FmtDateLong(t time.Time) string {
  283. b := make([]byte, 0, 32)
  284. b = strconv.AppendInt(b, int64(t.Day()), 10)
  285. b = append(b, []byte{0x20}...)
  286. b = append(b, ff.monthsWide[t.Month()]...)
  287. b = append(b, []byte{0x20}...)
  288. b = strconv.AppendInt(b, int64(t.Year()), 10)
  289. return string(b)
  290. }
  291. // FmtDateFull returns the full date representation of 't' for 'ff_GN'
  292. func (ff *ff_GN) FmtDateFull(t time.Time) string {
  293. b := make([]byte, 0, 32)
  294. b = append(b, ff.daysWide[t.Weekday()]...)
  295. b = append(b, []byte{0x20}...)
  296. b = strconv.AppendInt(b, int64(t.Day()), 10)
  297. b = append(b, []byte{0x20}...)
  298. b = append(b, ff.monthsWide[t.Month()]...)
  299. b = append(b, []byte{0x20}...)
  300. b = strconv.AppendInt(b, int64(t.Year()), 10)
  301. return string(b)
  302. }
  303. // FmtTimeShort returns the short time representation of 't' for 'ff_GN'
  304. func (ff *ff_GN) FmtTimeShort(t time.Time) string {
  305. b := make([]byte, 0, 32)
  306. if t.Hour() < 10 {
  307. b = append(b, '0')
  308. }
  309. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  310. b = append(b, ff.timeSeparator...)
  311. if t.Minute() < 10 {
  312. b = append(b, '0')
  313. }
  314. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  315. return string(b)
  316. }
  317. // FmtTimeMedium returns the medium time representation of 't' for 'ff_GN'
  318. func (ff *ff_GN) FmtTimeMedium(t time.Time) string {
  319. b := make([]byte, 0, 32)
  320. if t.Hour() < 10 {
  321. b = append(b, '0')
  322. }
  323. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  324. b = append(b, ff.timeSeparator...)
  325. if t.Minute() < 10 {
  326. b = append(b, '0')
  327. }
  328. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  329. b = append(b, ff.timeSeparator...)
  330. if t.Second() < 10 {
  331. b = append(b, '0')
  332. }
  333. b = strconv.AppendInt(b, int64(t.Second()), 10)
  334. return string(b)
  335. }
  336. // FmtTimeLong returns the long time representation of 't' for 'ff_GN'
  337. func (ff *ff_GN) FmtTimeLong(t time.Time) string {
  338. b := make([]byte, 0, 32)
  339. if t.Hour() < 10 {
  340. b = append(b, '0')
  341. }
  342. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  343. b = append(b, ff.timeSeparator...)
  344. if t.Minute() < 10 {
  345. b = append(b, '0')
  346. }
  347. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  348. b = append(b, ff.timeSeparator...)
  349. if t.Second() < 10 {
  350. b = append(b, '0')
  351. }
  352. b = strconv.AppendInt(b, int64(t.Second()), 10)
  353. b = append(b, []byte{0x20}...)
  354. tz, _ := t.Zone()
  355. b = append(b, tz...)
  356. return string(b)
  357. }
  358. // FmtTimeFull returns the full time representation of 't' for 'ff_GN'
  359. func (ff *ff_GN) FmtTimeFull(t time.Time) string {
  360. b := make([]byte, 0, 32)
  361. if t.Hour() < 10 {
  362. b = append(b, '0')
  363. }
  364. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  365. b = append(b, ff.timeSeparator...)
  366. if t.Minute() < 10 {
  367. b = append(b, '0')
  368. }
  369. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  370. b = append(b, ff.timeSeparator...)
  371. if t.Second() < 10 {
  372. b = append(b, '0')
  373. }
  374. b = strconv.AppendInt(b, int64(t.Second()), 10)
  375. b = append(b, []byte{0x20}...)
  376. tz, _ := t.Zone()
  377. if btz, ok := ff.timezones[tz]; ok {
  378. b = append(b, btz...)
  379. } else {
  380. b = append(b, tz...)
  381. }
  382. return string(b)
  383. }